DEV Community

Discussion on: Setting up multiple GitHub accounts, the nicer way

Collapse
 
q9 profile image
Afri

This does not work for me and it took me half a day to debug to figure out why. Here's the thing:

Even though you have an ssh -i section in the git config, this does not work for pushing to remote repositories. This is because for some reason that git always prefers .ssh/config and this defaults to my "user" key and not my "work" key. Therefore, pushing to a work-repository, even with ssh -i, it finds the personal user key first and I'll get a persmission denied for "user" error from github.

Only setting up different hosts in .ssh/config fixed this for me. I know it was your entire point of this post to say, "the nicer way," but maybe you have just forgotten about this config?

Or are you using the same SSH key for different accounts? I would not recommend doing that. Anyways, thank you for this article. :)