Create the user's authorized_keys file if it does not exist
Closes #2469
This commit is contained in:
@@ -16,3 +16,8 @@ verify_ssh_key_exists() {
|
|||||||
declare desc="Test that public key exists"
|
declare desc="Test that public key exists"
|
||||||
[[ -e ${DOKKU_ROOT}/.ssh/authorized_keys ]] || dokku_log_fail "No public keys found."
|
[[ -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>"
|
[[ -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")"
|
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>'
|
[ "$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
|
verify_ssh_key_exists
|
||||||
echo "$key_contents" | sshcommand acl-add dokku "$name" || dokku_log_fail "sshcommand returned an error: $?"
|
echo "$key_contents" | sshcommand acl-add dokku "$name" || dokku_log_fail "sshcommand returned an error: $?"
|
||||||
verify_ssh_key_file
|
verify_ssh_key_file
|
||||||
|
|||||||
Reference in New Issue
Block a user