Add a new SSH Key to your GitHub profile from the settings page by
clicking the New SSH key button and paste in your key. Save it…

Then authenticate with:

1ssh -T git@github.com

If you go back to the GitHub setting page and refresh the key icon
should go from black to green. 🎉

SSH Keys With Passwords

If you add a password to your SSH key you will find yourself entering
the password to authenticate on each [pull, push] operation. This can
get tedious, especially if you have a long password in your keys.

Add the following line to your ~/.ssh/config/ file:

1AddKeysToAgent yes

Open or create the ~/.ssh/config file with:

1nano ~/.ssh/config

The SSH agent will also need to be started on each terminal session
now to store the keys in, add the following to your ~/.bashrc file:

1[ -z "$SSH_AUTH_SOCK"]&&eval"$(ssh-agent -s)"

Open the ~/.bashrc file with:

1nano ~/.bashrc

Now the SSH agent will start on each terminal session and you will
only be prompted for the password on the first pull, push
operation.

Use multiple SSH keys

If you have more than one GitHub account or if you have AWS code
commit account then you will need to set up a config file, add your
SSH key the same as detailed in
How to authenticate with GitHub using SSH
and give the key a different name:

1# ls ~/.ssh

2~/.ssh/id_rsa_github_1

3~/.ssh/id_rsa_github_2

4~/.ssh/id_rsa_git_aws

You can delete all cached keys before, with:

1ssh-add -D

You can check your saved keys, with:

1ssh-add -l

Set up the SSH config file, check to see if you haven’t got a config
file already set up with: