Last updated on

Using the SSH protocol, you can connect and authenticate to remote servers and services. With SSH keys, you can connect to GitHub without providing your username and password at each commit or push as well, which can save you a lot of time. This tutorial will walk you through setting up an SSH key pair on your server, and GitHub.

Generating a key pair via SSH

  1. Login to your terminal via SSH
  2. Generate a key pair by running the following command, substituting in your GitHub email address between the quotes
    ssh-keygen -t rsa -b 4096 -C "your_email@domain.com"
  3. When you’re prompted to “Enter a file in which to save the key,” press Enter to save it in the default location. If you wish to use a different location, you can provide the path to be used here as well.
  4. At the prompt, type a secure passphrase that will be used when your key is authenticating, and confirm it

Congratulations! You now know how to generate an SSH key pair. Now we are going to walk you through the steps needed to supply your public key to GitHub for authentication.

Adding your public key to GitHub

  1. View your public key by running the following command, substituting the file path with the one you used in the previous tutorial if you did not use the default location
    cat ~/ssh/id_rsa.pub
  2. Select and copy the entire key to your clipboard
  3. Login to your GitHub account
  4. In the upper-right corner the GitHub website, click your profile photo, then click Settings.
  5. On the left hand side, select SSH and GPG Keys.
  6. Select New SSH key or Add SSH key.
  7. In the “Title” field, add a label for the new key.
  8. Paste your key into the “Key” field.
  9. Select Add SSH key.
  10. If prompted, confirm your GitHub password.

Congratulations! You now know how to set up your SSH key pair on your server, and use your public key to connect via SSH to GitHub.

 

SIGNUP FOR

BOLDGRID CENTRAL  

   200+ Design Templates + 1 Kick-ass SuperTheme
   6 WordPress Plugins + 2 Essential Services

Everything you need to build and manage WordPress websites in one Central place.

4 thoughts on “How to set up your SSH key with GitHub

Leave a Reply

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