Adding SSH-key to GitHub🔐🗝️
Tags: webdev, tutorial, github, git
Published: 2022-05-09 10:56:23

In this blog, I am going to be teaching you exactly how you could add an SSH key to your GitHub which could prevent you from constantly typing in your email and password anytime you want to push to Github. 

**SSH key** which stands for *Secure Socket Shell or Secure Shell* is just an access credential which resembles a password used to gain access to an encrypted connection between systems and and use that connection to manage a remote system.

## Setting it up on your machine

- First thing you would need to do is to generate the public and private key which would be used for the connection between your computer and Github. Your private key is meant not to be shared. If something is to be shared here, that should probably be your public key as the name suggests.
- And to do this, run this command:

```bash
ssh-keygen -t rsa -b 4096 -C 'type your email here'
```

You would be asked the location to store the file. You can specify where you want it to be stored or press ENTER to store it in the default location.

Establish your passphrase which is nothing different from password. It adds to the security of your connection so it is good you set it up. 

Press Enter after confirming your passphrase and you should see something like this.



![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5rybm4zra3r8oy8kh1qj.png)

- We need to add a key-manager which would hold our private keys for public keys authentication and would also save us some time typing our passphrase over and over again.

```bash
eval $(ssh-agent -s)
```

Now, we need to add the key-pair to the SSH.

```bash
ssh-add ~/.ssh/id_rsa
```

Hit enter and enter the passphrase.

*If you change your directory, you would need to specify that dir here also*

Copy the public key to use in Github

```bash
clip < ~/.ssh/id_rsa.pub
```

If you couldn’t copy the key with your terminal, you can simply go the .pub file via the dir you saved the keys to. With what we have here, I will navigate to root dir and *show all hidden files and dir. Go into the .ssh folder and open and copy the key in **id_rsa.pub***

### How to add the keys to Github.

- Open your Github and go to settings. (Top right corner by clicking on your avatar | image)



![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e4uyhtfsfnrrocqxajhn.png)

- On your left pane, you would find SSH and GPG key. Click on thin 



![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o9u44625ro0dk0txy24r.png)

- Add new SSH key



![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ggg1gh1qfy0l1o6p40up.png)

- Fill in the title and paste the copied ssh key from your clipboard.
    
    The title could be *anything* of your choice but should be a name that would easily identified.
    

You would be redirect to confirm the operation by entering your Github password.



![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4aynfi5hj1oxtd22cio7.png)

## CONCLUSION

You have now set up a secure and encrypted connection for data transfer between your computer and Github.