From ec4cf925edfa9b1145146d7c8fed41b84ac68949 Mon Sep 17 00:00:00 2001 From: mollusk Date: Tue, 20 Nov 2018 23:58:22 -0700 Subject: [PATCH] gensshkey.sh: add remote key copy support Former-commit-id: 9c2c15d54c24ae2bdd79d56ee0872c2ad2ebc580 Former-commit-id: cedefcf1980ec465f902293abccf01b3ed4c20d4 --- gensshkey.sh | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/gensshkey.sh b/gensshkey.sh index 195dbdd..17a3cb9 100755 --- a/gensshkey.sh +++ b/gensshkey.sh @@ -1,7 +1,37 @@ #!/bin/bash +keyPath="/home/$USER/.ssh" case $1 in --e ) ssh-keygen -t rsa -b 4096 -C "${2}";; -*) echo "${0}" -e [email];; +-e | --email) + ssh-keygen -t rsa -b 4096 -C "${2}" +;; + +-s | --send) + echo -ne "\nEnter server details [e.g user@host]: " + read serverPath + + + echo "==================" + + ls ~/.ssh | grep -v .pub | grep -v "config" | grep -v "known_hosts" + + echo -e "======================\n\n" + + echo -n "Choose a key: " + read keyName + + ssh-copy-id -i ${keyPath}/${keyName} ${serverPath} + + echo -e "\nDone!\n" + exit 0; + + + +;; + +* | -h | --help | help) + echo "${0} -e [name@email.com]" + echo "${0} -s copy key to remote server" +;; esac