erickchali
6/4/2018 - 6:33 AM

Add multiple ssh keys

For multiple services like:

  • Github
  • Bitbucket
  • etc
Host github.com
	HostName github.com
	PreferredAuthentications publickey
	IdentityFile ~/.ssh/github_rsa

Host bitbucket.org
	HostName bitbucket.org
	PreferredAuthentications publickey
	IdentityFile ~/.ssh/bitbucket_rsa
# generate ssh keys 
ssh-keygen 
# add passphrase, etc


# add passphrase and repeat for n keys
ssh-keygen -t rsa -f ~/.ssh/service_rsa

# change permissions inside .ssh/ folder
chmod 600 *

# add keys to services


# if there is only one account per service no config file is required, otherwise a config file
# inside .ssh keys

# on the machine add ,by add for each key.
ssh-add ~/.ssh/service_rsa

# list current added keys on local machine
ssh-add -L