Creating an SSH Key for Github

SSH is a nice program that lets you update your repository from Github without asking you for the password every single time. However, SSH has 2 different protocols that work differently.

Generating an SSH key

Generating an SSH key is quite simple. Most people use RSA 4096, but there are different methods as well, including DSA, ECDSA, and ED25519. In order to generate a public/private key pair, run

$ ssh-keygen -t (generation method) -b (number of bits) -C "Label this key"
Generating public/private (generation method) key pair.
Enter file in which to save the key (/home/your_name/.ssh/id_(generation method)): (Enter file to put keys in)
Enter passphrase (empty for no passphrase): (Enter passphrase)
Enter same passphrase again:  (Again, for luck)
Your identification has been saved in /home/your_name/.ssh/(File you entered)
Your public key has been saved in /home/your_name/.ssh/(File you entered).pub.
The key fingerprint is:
QWERTQWETRQWRYERYEHFDSYRAHUWYREQWEGTGA@%$#TQW Your label
The key's randomart image is:
+[(gen meth.)(bit)]+
|asff  fsfda    df |
| sdfsdfasdfsaf    |
|      .qoaff*   . |
| asf  saf= + B +  |
|  .o    q = asB . |
| q+      0 + h o  |
|wo      . oah . o |
|sdf sfs aq efw adf|
+-----[SHA256]-----+  

Adding the key to SSH IdentityFile

Because SSH now ships with SSH Protocol 2 as default, keys are not automatically added to the IdentityFile, which identifies which keys are available to use. This means that if you don’t name your key as the default, SSH won’t be able to know that your key exists. To fix this unsightly issue, create a config file in your .ssh/ folder using your favorite text editor. Then, add the following line:

IdentityFile (full path of file)

This will let SSH recognize your keys.

Adding the key to Github

Github has a guide to adding the SSH public key to Github here.

After adding the key to Github, you can now clone the repository using SSH instead of HTTPS. Have fun no longer entering your password every single time.

Written on July 31, 2018
Back