From fd00cff3d6e139ff31951ad3e60a95f8c358d6ff Mon Sep 17 00:00:00 2001 From: Mitch Riedstra Date: Wed, 14 Nov 2018 19:39:31 -0500 Subject: `pullkeys` was already verbose, make it painfully so and fail-safe on bad or no keys --- mkshrc | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'mkshrc') 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" -- cgit v1.2.3