2018-03-15 04:01:29 -07:00
|
|
|
#!/bin/bash
|
2018-11-20 23:58:22 -07:00
|
|
|
keyPath="/home/$USER/.ssh"
|
2018-03-15 04:01:29 -07:00
|
|
|
|
|
|
|
case $1 in
|
|
|
|
|
2018-11-20 23:58:22 -07:00
|
|
|
-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"
|
|
|
|
;;
|
2018-11-17 07:37:34 -07:00
|
|
|
esac
|