-2

I have different users for different github organizations, each with their own ssh keys. How can I easily switch between ssh keys for different accounts?

chad steele
  • 708
  • 8
  • 11

1 Answers1

1

Its quite possible with a little configuration in the ~/.ssh/config file.

The trick is - the Host in the .ssh config does not have to be the real Hostname

# add the ~/.ssh/id_altUsername file for the new user on Github
# ssh -T git@github-altUsername # test it can connect
# git clone git@github-altUsername:alt_username/[repo].git

Host github-altUsername
    HostName github.com
    User git
    IdentityFile ~/.ssh/id_altUsername
    IdentitiesOnly yes
Alister Bulman
  • 33,278
  • 9
  • 69
  • 109