2016-06-30 17:34:07 -07:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
|
|
|
|
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
|
|
|
|
|
2016-12-03 19:36:11 +00:00
|
|
|
list_ssh_keys() {
|
|
|
|
|
declare desc="List ssh key hashes"
|
|
|
|
|
local cmd="ssh-keys:list"
|
|
|
|
|
verify_ssh_key_file
|
|
|
|
|
sshcommand list dokku
|
|
|
|
|
}
|
|
|
|
|
|
2016-06-30 17:34:07 -07:00
|
|
|
verify_ssh_key_file() {
|
|
|
|
|
declare desc="Test that public key is valid"
|
|
|
|
|
[[ -s ${DOKKU_ROOT}/.ssh/authorized_keys ]] || dokku_log_fail "No public keys found."
|
2016-10-15 23:55:43 +02:00
|
|
|
local key line=0
|
|
|
|
|
while read key ; do
|
|
|
|
|
line=$((line + 1))
|
|
|
|
|
ssh-keygen -l -f /dev/stdin <<< "$key" &> /dev/null || dokku_log_fail "${DOKKU_ROOT}/.ssh/authorized_keys line $line failed ssh-keygen check."
|
|
|
|
|
done <"${DOKKU_ROOT}/.ssh/authorized_keys"
|
2016-06-30 17:34:07 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
verify_ssh_key_exists() {
|
|
|
|
|
declare desc="Test that public key exists"
|
|
|
|
|
[[ -e ${DOKKU_ROOT}/.ssh/authorized_keys ]] || dokku_log_fail "No public keys found."
|
|
|
|
|
}
|
2016-11-21 19:08:33 -07:00
|
|
|
|
|
|
|
|
create_ssh_key_file() {
|
|
|
|
|
declare desc="Ensure the public key file exists"
|
|
|
|
|
touch "${DOKKU_ROOT}/.ssh/authorized_keys"
|
|
|
|
|
}
|