aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMitch Riedstra <mitch@riedstra.us>2018-11-14 19:39:31 -0500
committerMitch Riedstra <mitch@riedstra.us>2018-11-14 19:39:31 -0500
commitfd00cff3d6e139ff31951ad3e60a95f8c358d6ff (patch)
tree673c22737729fed6c7ac641b929c2188f38b0ac2
parentc07992a45ff3205f2e576a5a8f6ff997d0c4f8c6 (diff)
downloaddotfiles-fd00cff3d6e139ff31951ad3e60a95f8c358d6ff.tar.gz
dotfiles-fd00cff3d6e139ff31951ad3e60a95f8c358d6ff.tar.xz
`pullkeys` was already verbose, make it painfully so and fail-safe on bad or no keys
-rw-r--r--mkshrc13
1 files changed, 9 insertions, 4 deletions
diff --git a/mkshrc b/mkshrc
index 5c7ead2..5d21187 100644
--- a/mkshrc
+++ b/mkshrc
@@ -364,14 +364,19 @@ pulldotfile() {
pull -u "${UPDATE_URL}${file}" -f "$HOME/.${file}"
}
pullkeys() {
+ _timestamp="$(timestamp)"
file="keys/$1"
+ auth_keys="$HOME/.ssh/authorized_keys"
+ set -x
if ! [ -d $HOME/.ssh ] ; then mkdir $HOME/.ssh ; fi
chmod 700 $HOME/.ssh
- chmod 600 $HOME/.ssh/authorized_keys
- mv "$HOME/.ssh/authorized_keys" "$HOME/.ssh/authorized_keys.$(timestamp)" || \
+ chmod 600 $auth_keys
+ mv "$auth_keys" "${auth_keys}.${_timestamp}" || \
echo "Authorized Keys do not exist"
- pull -u "${UPDATE_URL}${file}" -f "$HOME/.ssh/authorized_keys"
- chmod 600 $HOME/.ssh/authorized_keys
+ pull -u "${UPDATE_URL}${file}" -f "$auth_keys"
+ ssh-keygen -lf "$auth_keys" || mv "${auth_keys}.${_timestamp}" "$auth_keys"
+ chmod 600 $auth_keys
+ set +x
}
pullsshconfig() {
file="ssh/config"