diff options
author | Kjetil Orbekk <kjetil.orbekk@gmail.com> | 2015-09-10 15:00:46 -0400 |
---|---|---|
committer | Kjetil Orbekk <kjetil.orbekk@gmail.com> | 2015-09-10 15:00:46 -0400 |
commit | 0eb4ad801d540835bc37da64c2a1d25b64502689 (patch) | |
tree | dfabe3a0b1f440127e527f71b900c1320e3f8b5a | |
parent | 3b4a41acf668ffe51a0c2a4fb59247b19fa6e668 (diff) |
Add some documentation and polish to the sync_authorized_keys script.
-rwxr-xr-x | bin/kj_sync_authorized_keys.sh | 11 |
1 files changed, 10 insertions, 1 deletions
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" |