How to set up SSH with Github

Before we delve into how to set up SSH, we must understand what SSH means and the benefit it serves us. SSH or Secure Shell is a network communication protocol that enables two computers to communicate securely. An inherent feature of SSH is that the communication between the two computers is encrypted meaning that it is suitable for use on insecure networks. SSH is used to secure, configure, manage, maintain, and operate network servers, routers, firewalls, switches, operating systems, and applications. Now that you know what SSH means, and its benefit, let us learn how we can set it up to use with Github. In connecting your Github account via SSH, two keys (i.e, public and private keys) will be generated and stored on your local machine. You will then be required to copy the public key to your Github server. After you finish setting up, every operation will be authenticated using the keys.

To generate your SSH keys, you must do the following: Whether you are using Windows or Mac;

  1. Open the terminal

  2. Enter the following: ssh-keygen -t ed25519 -C "your@email.com"

  3. Replace the email with your own and press enter.

  4. It will prompt you to enter a password. Hit enter to skip setting a password and do the same for entering the same passphrase again. Generating public/private ed25519 key pair. Enter passphrase (empty for no passphrase): Enter the same passphrase again: Your identification has been saved in ./ssh/private_key. Your public key has been saved in ./ssh/public_key.pub. The key fingerprint is: SHA256:UDQI5N1FL3QSq7Gj1o12mkr9Me7qGMZAeE1s9BWIln4 your@email.com The key's randomart image is: +--[ED25519 256]--+ | .o+o=+oOo. | | o +B+.= = | | . +++ + o. | | o ..E+ . | | . .S | | o + + | | B = = | | + + * o | | oo=o+ | +----[SHA256]-----+

  5. Once you have confirmed it will generate the above to confirm the keys have been created.

  6. Both keys will be stored in the .ssh folder.

  7. To add our key to Github, you need to get a copy of the public key which is always identified as .pub in your local directory. Find the name of the key file using the below command. ls ~/.ssh/ Then, use the below command to copy the file, replacing the with the name of the key file on your device. pbcopy < ~/.ssh/.pub

Steps to add a public key to Github: • Log on to Github • Click on the profile icon in the top right of the screen and select Settings.

image.png

• On the Settings screen, on the left-hand side under the Access section, click SSH and GPG Keys.

image.png

Click the New SSH key button in Green on the right-hand side of the screen.

image.png

• Enter a title and paste in your public key that you copied previously.

image.png

Click the Add SSH key button. Congratulations! You have just set up your SSH access with Github.

Kindly note that whenever you are accessing a repository and using SSH authentication, make sure to always use the SSH address of the repository (as shown in the picture below).

image.png

I hope you found this article helpful. Thank you for sticking to the end, you are indeed a passionate developer!