Last active
July 21, 2019 09:25
-
-
Save dtgoitia/ddcae5e416851a3df36cee34bb09ea07 to your computer and use it in GitHub Desktop.
BASH snippet to set up a new RSA key
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
#!/bin/bash | |
key_name="id_rsa" | |
key_path="$HOME/.ssh/$key_name" | |
echo "Creating a RSA key" | |
read -p " > Enter your email: " email | |
echo "" | |
ssh-keygen -t rsa -b 4096 -C "$email" -f "$key_path" > /dev/null 2>&1 | |
echo "" | |
echo "Starting the ssh-agent in the background" | |
eval "$(ssh-agent -s)" | |
echo "" | |
echo "Adding your SSH key to the ssh-agent" | |
ssh-add "$key_path" | |
echo "" | |
echo "Copy the public SSH key content to your clipboard" | |
echo "Linux: xclip -sel clip < $key_path.pub" | |
echo "Windows: clip < $key_path.pub" | |
echo "" | |
echo "Test your connection:" | |
echo "GitHub: ssh -T [email protected]" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment