SSH Key for GitHub (How-To)

Andrew Musholt
3 min readJan 8, 2022


Quick-and-Easy Reference:

(If you’ve done this before, and just need a quick reference)

Run these 3 commands:

ssh-keygen -t rsa -b 4096 -C “”

eval “$(ssh-agent -s)”

ssh-add ~/.ssh/id_rsa

Go to Click your profile icon (top-right), select “Settings”. On the left, click the “SSH and GPG Keys” tab. Click “New SSH Key”. Give it a title. Copy/paste the contents of ~/.ssh/ into the large text field, and click “Add SSH key”. You are done!

Much Longer Version, with Screenshots:

(If you’ve never done this)

GitHub is a website that lets you store code projects. Git is a command-line tool you use to interact with it.

GitHub is remote, Git is on your computer.

SSH keys allow you to connect them together.

You can run Git commands from your computer (such as “git clone” and “git push”) and interact with your GitHub repository directly…without ever entering a password.

Generating an SSH key is quite painless. Do it once, and you won’t have to do it again.

Make sure you download and install Git Bash (a command-line tool made specifically for using Git). These examples will be using Git Bash.

1) Run this command to generate the key:

ssh-keygen -t rsa -b 4096 -C “”

Hit enter a couple times (or type out a passphrase if desired). It will tell you that it created two files (id_rsa and in your home directory:

Your “home directory” on Windows will be something like: C:\Users\yourName

In Git Bash (or any Linux-like CLI) you will often be using “~” (tilde) as a shortcut instead of typing out the home-directory path each time.

(You can type “~” instead of “C:\Users\yourName”…just makes life easier!)

2) Next, run this command to start the SSH Agent

eval “$(ssh-agent -s)”

3) Then, add your key to the agent:

ssh-add ~/.ssh/id_rsa

Again, “~” is just a shortcut for your home directory (C:\Users\yourName)

We are now done generating the key, and next we will add it to GitHub.

4) Log into GitHub, click your profile icon in the top-right corner, and go to the “Settings” page:

5) Click the “SSH and GPG” tab on the left, and click the “New SSH key” button

6) Give it a title, then copy the contents of your file…..

….and paste it into the corresponding field on GitHub:

Click the “Add SSH key” button and you are done! You will see your key here:



Andrew Musholt

Full-time web developer, part-time business owner.