5

I'm currently trying to make multiple keys for a single host, but I am running into an an odd issue where the first SSH key that I decide to use, becomes the only SSH key that I can use. I then have to restart my laptop just to change SSH keys.

I'm using a Macbook Pro with Mojave v10.14.6

My SSH config looks like this -

Host github.com-personal
  Hostname github.com
  UseKeychain yes
  AddKeysToAgent yes
  User git
  IdentityFile ~/.ssh/personal
Host github.com-work
  Hostname github.com
  UseKeychain yes
  AddKeysToAgent yes
  User git
  IdentityFile ~/.ssh/work

Since these keys happen to be used for github, I used the following command to test.

ssh -T github.com-work

and

ssh -T github.com-personal

The problem is, if I run the work command first, the response is -

Hi <<work account>>! You've successfully authenticated, but GitHub does not provide shell access.

After that, if I run either of the above commands, the output is the same.

If I run the personal command first, then the output references my personal account until I restart my computer.

Does anyone know what's going on here?

Colin
  • 101
  • 5
  • This isn't Git's fault. :-) Try adding `IdentitiesOnly` to your `.ssh/config` entries. Make sure you do this in *all* places where you need to. See https://stackoverflow.com/q/36363325/1256452 – torek Dec 17 '19 at 18:36
  • @phd I do not. I've tried adding that for both ssh rules and no change was made in my ability to login with different accounts. – Colin Dec 17 '19 at 19:01
  • @torek holy moly that worked! Thank you so much! – Colin Dec 17 '19 at 19:03

1 Answers1

2

@Torek Pointed out that I was missing IdentitiesOnly yes as a line in my SSH rules. Thanks for the help!

Colin
  • 101
  • 5