DEV Community

silverboi
silverboi

Posted on

How to Add Your SSH Key to Your GitHub Account

This is just a self reminder of how to do this and not have to google it every time I need to add a new one.
These steps are solid as they are, but might change over time to create more robust documentation on it.
These steps are all performed from the terminal.

Create your ssh key with your github email

ssh-keygen -t ed25519 -C "your_email@example.com"
Enter fullscreen mode Exit fullscreen mode

Optional

  • Name your file name and route when prompted this:(use the site name you are creating the key for id purposes).
Enter file in which to save the key (/Users/dgplatac/.ssh/id_ed25519):
Enter fullscreen mode Exit fullscreen mode
  • Enter a passphrase for added security when prompted this:
Enter passphrase (empty for no passphrase):
Enter fullscreen mode Exit fullscreen mode

Add Your SSH Key to the ssh-agent

eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519
Enter fullscreen mode Exit fullscreen mode

Copy your ssh key to the clipboard

cat ~/.ssh/ed25519.pub | pbcopy
Enter fullscreen mode Exit fullscreen mode

Remember to use the correct file name and path.

Add Your SSH Key to Your GitHub Account

  • On GitHub, navigate to your settings by clicking your profile photo, then click Settings.
  • In the user settings sidebar, click SSH and GPG keys.
  • Click New SSH key or Add SSH key.
  • In the “Title” field, add a descriptive label. For example, if you’re using your personal laptop, you might call this key “Personal Laptop”.
  • Paste your key into the “Key” field.
  • Click Add SSH key.

Test Your SSH Connection

ssh -T git@github.com
Enter fullscreen mode Exit fullscreen mode

The following message should display

The authenticity of host 'github.com (IP ADDRESS)' can't be established.
RSA key fingerprint is SHA256:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.
Are you sure you want to continue connecting (yes/no/[fingerprint])?
Enter fullscreen mode Exit fullscreen mode

answer yes and the following should display:

Hi username! You've successfully authenticated, but GitHub does not provide shell access.
Enter fullscreen mode Exit fullscreen mode

Silverboi

Top comments (0)