From 0eb4ad801d540835bc37da64c2a1d25b64502689 Mon Sep 17 00:00:00 2001 From: Kjetil Orbekk Date: Thu, 10 Sep 2015 15:00:46 -0400 Subject: Add some documentation and polish to the sync_authorized_keys script. --- bin/kj_sync_authorized_keys.sh | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/bin/kj_sync_authorized_keys.sh b/bin/kj_sync_authorized_keys.sh index 9cedd56..8db3bb2 100755 --- a/bin/kj_sync_authorized_keys.sh +++ b/bin/kj_sync_authorized_keys.sh @@ -1,8 +1,13 @@ #!/bin/bash +# +# This script syncs authorized keys (found in the $authorized_keys_file below) +# to a list of remote hosts. It does not touch existing keys unless overwrite +# is set to true, but creates a special section containing the keys. declare -r begin_marker="### BEGIN MANAGED_BY_KJ_SYNC_AUTHORIZED_KEYS.SH ###" declare -r end_marker="### END MANAGED_BY_KJ_SYNC_AUTHORIZED_KEYS.SH ###" -declare -r overwrite=true +# If overwrite=true, the entire authorized_keys file is overwritten. +declare -r overwrite=false declare -r tmpdir=$(mktemp -d /tmp/kj_sync_authorized_keys.XXXXX) targets=( @@ -15,6 +20,10 @@ targets=( moyo.orbekk.com ) authorized_keys_file=$HOME/dotfiles/authorized_keys +if [[ ! -f "${authorized_keys_file}" ]]; then + echo "could not find authorized_keys_file: ${authorized_keys_file}" + exit 1 +fi add_keys_to_file() { filename="$1" -- cgit v1.2.3