mirror of
https://github.com/dokku/dokku.git
synced 2025-12-29 00:25:08 +01:00
Merge pull request #2495 from dokku/jg-2469-create-authorized-keys
Create the user's `authorized_keys` file if it does not exist
This commit is contained in:
@@ -16,3 +16,8 @@ verify_ssh_key_exists() {
|
||||
declare desc="Test that public key exists"
|
||||
[[ -e ${DOKKU_ROOT}/.ssh/authorized_keys ]] || dokku_log_fail "No public keys found."
|
||||
}
|
||||
|
||||
create_ssh_key_file() {
|
||||
declare desc="Ensure the public key file exists"
|
||||
touch "${DOKKU_ROOT}/.ssh/authorized_keys"
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ add_keys() {
|
||||
[[ -n "$name" && -n "$key_contents" ]] || dokku_log_fail "Two arguments are required if not piping, ie: dokku ssh-keys:add <NAME> <KEY_FILE>"
|
||||
local count="$(wc -l <<< "$key_contents")"
|
||||
[ "$count" -eq 1 ] || dokku_log_fail 'Too many keys provided, set one per invocation of dokku ssh-keys:add <NAME> <KEY_FILE>'
|
||||
create_ssh_key_file
|
||||
verify_ssh_key_exists
|
||||
echo "$key_contents" | sshcommand acl-add dokku "$name" || dokku_log_fail "sshcommand returned an error: $?"
|
||||
verify_ssh_key_file
|
||||
|
||||
Reference in New Issue
Block a user