Skip to content

Instantly share code, notes, and snippets.

@dtgoitia
Last active July 21, 2019 09:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dtgoitia/ddcae5e416851a3df36cee34bb09ea07 to your computer and use it in GitHub Desktop.
Save dtgoitia/ddcae5e416851a3df36cee34bb09ea07 to your computer and use it in GitHub Desktop.
BASH snippet to set up a new RSA key
#!/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 git@github.com"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment