-
Create a
sshkey:ssh-keygen -t rsa -b 4096 -C "<email>" -
Enter the
nameand thepassphrase.
-
Creating a
configfile (~/.ssh/):touch config
-
Editing the
configfile:nano config
-
Adding into
configfile:# Personal account Host personal.github.com HostName github.com AddKeysToAgent yes UseKeychain yes # KeyChain (for macOS) PreferredAuthentications publickey IdentityFile ~/.ssh/<personal_key> # Enterprise account Host enterprise.github.com HostName github.com AddKeysToAgent yes UseKeychain yes # KeyChain (for macOS) PreferredAuthentications publickey IdentityFile ~/.ssh/<enterprise_key>
-
Start the ssh-agent in the background:
eval "$(ssh-agent -s)"
-
Add your SSH private key to the ssh-agent:
ssh-add -K ~/.ssh/<ssh_filename>
-
On
macOS, ssh-agent will "forget" this key, once it gets restarted during reboots. But you can import your SSH keys into Keychain using this command:/usr/bin/ssh-add -K ~/.ssh/<ssh_filename>
-
-
Copy the SSH key to your clipboard:
pbcopy < ~/.ssh/<ssh_filename>.pub
ssh -T git@<config_host>.github.com