27 Jan 2023 · 2 min read
Before you generate your SSH key, you should start by checking if you don't already have an existing key; You can do this by running the following command on your terminal:
ls -al ~/.ssh
If you have any existing SSH keys this command will list them,if you don't have any existing SSH keys don't worry, just follow along.
If you don't have an existing SSH key, you can easily generate one by running the following command:
ssh-keygen -t rsa -b 4096 -C "your email"
After running this command you will be prompted to enter the file name and the passphrase for the new SSH key, you can just click enter to use the default filename(id_rsa) and the passphrase is optional if you want some extra security.
After your SSH key has been successfully generated, you will now have to add it to your github account. Login to your github account and go to your account settings, then click on the "SSH and GPG Keys" tab; see screenshot below.
After that now click the "Add new SSH key" button and give your new SSH key a title, the title can be anything you like. Next copy the key from the "id_rsa.pub" file located in your "~/.ssh" folder and paste it into the "Key" field. The ssh folder was created when you generated your new SSH key and this is where your key is stored. Please note that the 'ssh' folder might be hidden by default,if this is the case for you just simply click on the "show hidden files" checkbox under the views tab on your taskbar:
Now finally, if you successfully copied your SSH Key to your github, click the "Add SSH key" button.
SSH keys provide a secure and convenient way to authenticate your access when using github. By following the steps from this article, you will be able to easily setup your SSH keys.