Created
January 26, 2016 04:46
-
-
Save troyxmccall/bd7e93fa63565edf0cbb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function keyme () { | |
if [ -z "$1" -o -z "$2" ]; then | |
echo "Please provide your email and a name for the key (preferably the server domain) - usage: newkey <email> <keyname>" | |
return 1 | |
fi | |
ssh-keygen -t rsa -b 4096 -C "$1" -f "$HOME/.ssh/${2}_rsa" | |
read -r -p "Would you like to upload this key to a server now? [y/N] " response | |
response=${response} # tolower | |
if [[ $response =~ ^(yes|y)$ ]]; then | |
echo -n "Enter the server hostname or IP address and press [ENTER]: " | |
read server | |
echo -n "Enter your username for $server and press [ENTER]: " | |
read username | |
ssh-copy-id -i "$HOME/.ssh/${2}_rsa.pub" "$username@$server" | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment