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

  1. Create SSH keys
  2. Import the SSH key to GitHub
  3. 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 "your_email@example.com"
# RSA 4096
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"

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.

Import public key

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

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 git@github.com:YourUserName/project-folder.git
git push -u origin master

It works!

2 Replies to “Configure GitHub SSH Keys”

  1. Hello Oliver,

    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
    Pascal

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.