Clean up key registration output

This commit is contained in:
Michael Stanclift 2020-06-03 14:38:50 -05:00
parent 1ab2a4ffe9
commit 2fcaeb4428

View File

@ -718,22 +718,20 @@ function generate_sshkey {
MESSAGE="Generating ~/${SSH_PKIF} (SSH-KEYGEN)" MESSAGE="Generating ~/${SSH_PKIF} (SSH-KEYGEN)"
echo_stat echo_stat
ssh-keygen -q -P "" -t rsa -f $HOME/${SSH_PKIF} ssh-keygen -q -P "" -t rsa -f $HOME/${SSH_PKIF} >/dev/null 2>&1
error_validate error_validate
elif hash dropbearkey >/dev/null 2>&1 elif hash dropbearkey >/dev/null 2>&1
then then
MESSAGE="Generating ~/${SSH_PKIF} (DROPBEARKEY)" MESSAGE="Generating ~/${SSH_PKIF} (DROPBEARKEY)"
echo_info echo_stat
if [ ! -d $HOME/.ssh ] if [ ! -d $HOME/.ssh ]
then then
mkdir $HOME/.ssh >/dev/null 2>&1 mkdir $HOME/.ssh >/dev/null 2>&1
fi fi
echo -e "========================================================"
echo -e "========================================================" dropbearkey -y -t rsa -f $HOME/${SSH_PKIF} >/dev/null 2>&1
dropbearkey -t rsa -f $HOME/${SSH_PKIF} error_validate
echo -e "========================================================"
echo -e "========================================================"
else else
MESSAGE="No SSH Key Generator Located" MESSAGE="No SSH Key Generator Located"
echo_warn echo_warn
@ -751,11 +749,9 @@ function export_sshkey {
MESSAGE="Registering Key-Pair on ${REMOTE_HOST}" MESSAGE="Registering Key-Pair on ${REMOTE_HOST}"
echo_info echo_info
MESSAGE="Enter ${REMOTE_USER}@${REMOTE_HOST} Password Below" #MESSAGE="Enter ${REMOTE_USER}@${REMOTE_HOST} Password Below"
echo -e "${NEED} ${MESSAGE}" #echo -e "${NEED} ${MESSAGE}"
echo -e "========================================================"
echo -e "========================================================"
if hash ssh-copy-id 2>/dev/null if hash ssh-copy-id 2>/dev/null
then then
ssh-copy-id -f -p ${SSH_PORT} -i $HOME/${SSH_PKIF}.pub ${REMOTE_USER}@${REMOTE_HOST} ssh-copy-id -f -p ${SSH_PORT} -i $HOME/${SSH_PKIF}.pub ${REMOTE_USER}@${REMOTE_HOST}
@ -764,11 +760,9 @@ function export_sshkey {
dropbearkey -y -f $HOME/${SSH_PKIF} | grep "^ssh-rsa " > $HOME/${SSH_PKIF}.pub dropbearkey -y -f $HOME/${SSH_PKIF} | grep "^ssh-rsa " > $HOME/${SSH_PKIF}.pub
cat $HOME/${SSH_PKIF}.pub | dbclient ${REMOTE_USER}@${REMOTE_HOST} 'cat - >> .ssh/authorized_keys' cat $HOME/${SSH_PKIF}.pub | dbclient ${REMOTE_USER}@${REMOTE_HOST} 'cat - >> .ssh/authorized_keys'
fi fi
echo -e "========================================================"
echo -e "========================================================"
else else
MESSAGE="Error Creating Key-Pair" MESSAGE="Error Registering Key-Pair"
echo -e "${FAIL} ${MESSAGE}" echo_warn
fi fi
fi fi
} }