Create an ssh key:
ssh-keygen -t rsa -b 4096 -C "[email protected]"
Start the ssh-agent in the background:
eval "$(ssh-agent -s)"
If you're using macOS Sierra or later, you will need to modify your ~/.ssh/config
file to automatically load keys into the ssh-agent and store passphrases in your keychain.
Host *
AddKeysToAgent yes
UseKeychain yes
IdentityFile ~/.ssh/id_rsa
Add your SSH private key to the ssh-agent and store your passphrase in the keychain.
ssh-add -K ~/.ssh/id_rsa
Then copy the public key to your clipboard:
pbcopy < ~/.ssh/id_rsa.pub
and add it to your github/bitbucket/gitlab/server.
Test ssh connection:
ssh -T [email protected]