How to Add SSH Keys to Your GitHub Account

GitHub offers a convenient SSH key feature for accessing your repositories on the command line. Instead of using usernames and passwords every time you push to or pull from your repository, you can use your key. In this article we’ll learn how to add SSH keys to your GitHub account.

Why use an SSH key?

Using an SSH key is a convenient and secure way to access your account. It’s convenient because you don’t need to remember a long password. And you can make your actual password so brutally long and secure that no human or bot could guess it. The SSH key works like an actual key that only you possess.

How to Create an SSH Key

In order to use an SSH key with Git, you must first create the key on your computer. If you already have an SSH key, you can skip these steps. In order to check if you have a key, you can run this command:

 [email protected]# ssh-add -l

Follow along with the steps below to create the key and copy its contents. You will need to open your computer’s default terminal application.

  1. Open the terminal app on your computer.
  2. Enter the following command, substituting [email protected] with your email address:
     [email protected]# ssh-keygen -t rsa -b 4096 -C "[email protected]"
  3. Press Enter to accept the default file location.
  4. Enter a secure passphrase.
  5. Press Enter.
  6. Enter this command to display the contents of your public key:
     [email protected]# cat .ssh/
  7. Copy the contents of your key to your clipboard (we will need it later).

It’s important to remember that the SSH key has two parts: a private key and a public key. As the name suggests, the private key is only for private use. Never ever share your private key with anyone (with exceptions made for your system administrator or other trusted people within your organization). This will be important later.

How to Add an SSH Key to your Github Account

Now we have already seen why you might want to use an SSH key. We also demonstrated how to create an SSH key on your computer.

As mentioned above, we have a private key and a public key. In the steps below you’ll learn how to upload your public key to GitHub.

  1. Log into your GitHub account.
  2. Click your avatar and choose Settings
    GitHub Settings

  3. Select SSH and GPG keys
    SSH and GPG Keys

  4. Click New SSH key
    New SSH Key

  5. Enter a title in the field
    Enter Title

  6. Paste your public key into the Key field
    Paste public key

  7. Click Add SSH key
    Add SSH key

Next Steps

Well done! You now know how to add SSH keys to your GitHub account. Make sure to check out some of our other Git articles:

Christopher Maiorana Content Writer II

Christopher Maiorana joined the InMotion community team in 2015 and regularly dispenses tips and tricks in the Support Center, Community Q&A, and the InMotion Hosting Blog.

More Articles by Christopher

Thoughts on “How to Add SSH Keys to Your GitHub Account

Was this article helpful? Let us know!