-3

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?

Adrian Mole
  • 49,934
  • 160
  • 51
  • 83
chad steele
  • 828
  • 9
  • 13

1 Answers1

2

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
  • 34,482
  • 9
  • 71
  • 110