Configure GitHub SSH Keys
This is a quick post on how to configure GitHub SSH keys. The GitHub documentation is pretty good with this, so this post is more of a personal note.
The advantage of using GitHub SSH keys is that you do not need to provide the username and password of your GitHub account each time. This makes it easier to work with GitHub, more specifically private repositories in my opinion.
To add the SSH keys you need to
- Create SSH keys
- Import the SSH key to GitHub
- Save SSH key in Linux
1. Create SSH Keys
Here we have the option of using RSA 4096 bit keys, or we can use Eliptic Curve 25519 algorithm. The EC-25519 curve is the one that is used in the famous Eliptic Curve Diffie-Hellman key exchange algorithm.
# EC-25519 ssh-keygen -t ed25519 -C "email@example.com" # RSA 4096 ssh-keygen -t rsa -b 4096 -C "firstname.lastname@example.org"
2. Import the SSH Key to GitHub
Go to your icon on the top right, Settings, then SSH and GPG keys. Click New SSH Key on the top right. Then copy and paste your public key into the text box, like in the screenshots below.
3. Configure Linux with Key
Two simple commands! The agent PID is likely going to be different for you. Also you need to make sure that you use the correct path to your private key. If you configured a passphrase for your SSH key, you need to type it in here.
$ eval `ssh-agent -s` # Agent PID #### $ ssh-add /home/user/.ssh/id_ed_25519
Optional: Persistent SSH Keys
If you would like your configured SSH keys to remain persistent, such as after system reboot, then you should execute the commands listed below. I would like to note that this is for ZSH, it could be different for the Bash shell. Thanks to @UnRunDead for this tip!
.zshrc and go to
plugins=(...) and add
IMPORTANT: put these settings before the line that sources oh-my-zsh
zstyle :omz:plugins:ssh-agent identities id_rsa id_rsa2 id_github
Then reload your terminal:
And that’s all it takes! Now you can test it out 🙂
Test it out
Note that you will need to create a repo in the GitHub website for this.
git config --global user.name YourUserName mkdir project-folder cd project-folder git init echo "# Hello World" > README.md git add README.md git commit -m "Frosty Labs Demonstration" git remote add origin email@example.com:YourUserName/project-folder.git git push -u origin master
2 Replies to “Configure GitHub SSH Keys”
thank you for the very helpful blog entry: “CONFIGURE GITHUB SSH KEYS”.
I was able to follow this very well and have now successfully adhered to the tutorial several times.
With kind regards
Dear Pascal. Thank you for your kind words. This is great to hear! Happy GitHubbing.