We will setup our ssh key to connect to Github.
Typically you would have one key pair for your machine but sometimes you need multiple
ie: personal, work internal and client.
This files lets us setup diffent host to use our ssh key.
nano ~/.ssh/config
#~/.ssh/config
Host *
AddKeysToAgent yes
UseKeychain yes
# git clone git@github.com:[account]/[project].git
Host github.com
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa
IdentitiesOnly yes
ssh-add ~/.ssh/id_rsa
#List fingerprints of all identities.
ssh-add -l
#List public key parameters of all identities.
ssh-add -L
Add the Public key to the server you want to connect to. ie: github.com
#Copy Public key to clipboard.
pbcopy < ~/.ssh/id_rsa.pub
ssh -T github.com
For when you need to remove your identities.
#Delete all identities.
ssh-add -D
Example Host for different situations.
#EXAMPLES
# ssh cwc-server
Host cwc-server
HostName ssh.example.com
Port 1111
User cwc
IdentityFile ~/.ssh/id_rsa
IdentitiesOnly yes
# ssh cwc-client
Host cwc-client
HostName client.example.com
User cwc
IdentityFile ~/.ssh/id_rsa_client
IdentitiesOnly yes
# git clone git@gh-work:[account]/[project].git
Host gh-work
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa_work
IdentitiesOnly yes