Because I always find myself forgetting how to setup SSH, here is a short guide so that I don't forget.

Setup the SSH folder

Locate the folder that will store all SSH keys.

In the command line of Git BASH or Terminal, navigate to this folder with cd ~/.ssh.

If the directory doesn't exist, make it with cd ~ + mkdir .ssh + cd .ssh.

At the end of this step, the command line should be inside the .ssh folder.

Generate a SSH key pair

Inside the .ssh folder, use the ssh-keygen command to start the setup process for a new SSH key.

Enter a file name to store the SSH key. The naming convention is usually id_<name>, where <name> is a descriptive keyword.

Once a file name is entered it will prompt for a pass phrase. Enter a passphrase to generate the SSH key. To change an existing key's pass phrase run the ssh-keygen -p command.

Authorise the public key on the server

After creating a public SSH key it must be authorised. This means copying the contents of into a file called authorized_keys. If this file does not exist, create a blank one in the .ssh folder on the server.

Paste in the contents of the public key into authorized_keys. If the public key was uploaded to the server the contents of can be appended by running cat >> authorized_keys

Otherwise, if you just need to copy the contents to your clipboard, use pbcopy <

Update the SSH config

With an SSH created, update the config file within the .ssh folder on the local computer to link the server to the private SSH key. If this file does not exist, create it.

Add the following lines to the config file:

Host <domain-name>
  IdentityFile ~/.ssh/id_rsa

Where <domain-name> is the server to connect to over SSH.

Add the SSH key

Using the SSH key is a matter of adding it to the authentication agent with the ssh-add id_rsa command.

Enter the key's pass phrase and the SSH key will be setup.

To confirm which keys are currently added, run the ssh-add -l command.

To add all SSH keys at once, run the ssh-add -A command.