Create and Publish SSH Keys

Secure SHell keys are used to authenticate yourself to a system. You will need them to secure your access to a system without the use of a password. SSH keys come in two pairs. The public keyand the private key.

Generate a Key Pair

First we generate our key pair. Open Terminal or Command Prompt and enter this command:

ssh-keygen -t ed25519 -C [YOUR EMAIL]

Adding the -C is optional. It will help you identify the keys in the future.

In our example below we accepted the defaults and kept hitting enter until it finished.

┌[ forthright@macOS ] ~
└➤ ssh-keygen -t ed25519 -C the@forthright.engineer
Generating public/private ed25519 key pair.
Enter file in which to save the key (/Users/forthright/.ssh/id_ed25519): 
Enter passphrase for "/Users/forthright/.ssh/id_ed25519" (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /Users/forthright/.ssh/id_ed25519
Your public key has been saved in /Users/forthright/.ssh/id_ed25519.pub
The key fingerprint is:
SHA256:------------[REDACTED]-------------PDRQ/BTA the@forthright.engineer
The key's randomart image is:
+--[ED25519 256]--+
|                 |
|                 |
|                 |
|                 |
|   [REDACTED]    |
|                 |
|                 |
|                 |
|                 |
+----[SHA256]-----+

Now you have a new directory .ssh/

In the new directory you will have a public key named id_ed25519.pub and a private key named id_ed25519.

Publishing a Public Key to GitHub

You will need a GitHub account. This is needed in order to secure your install of a Linux system during setup. You will be asked for your GitHub username and it will retrieve the SSH Public Key. 

After you log into GitHub, you can click on your avatar, then Settings > SSH and GPG Keys.

Click on the green button to add a “New SSH Key.” Give it a name can copy the contents of .ssh/id_ed25519.pub into the Keyfield and click “Add SSH Key.” 

Publishing a Public Key to an Existing System

In Ubuntu and most Linux distributions, you will need to log into your system then copy the contents of .ssh/id_ed25519.pubfrom your local system to .ssh/authorized_keys on your remote system. You can add a new key to each line of the file.