-
Create a
ssh
key:ssh-keygen -t rsa -b 4096 -C "<email>"
-
Enter the
name
and thepassphrase
.
-
Creating a
config
file (~/.ssh/
):touch config
-
Editing the
config
file:nano config
-
Adding into
config
file:# 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