git pushes with wrong user from terminal

前端 未结 22 1493
夕颜
夕颜 2020-12-07 07:51

I have an issue with git and my terminal.

Here\'s a gallery to show you my issue : http://imgur.com/a/6RrEY

When I push commits from my terminal, git says I

22条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-07 08:14

    The solution for me was to add an entry in my ~/.ssh/config file for github. I had to do this because:

    1. I had multiple github accounts with the same key (don't do this!)
    2. when you 'git push' using ssh, your computer grabs id_rsa by default and uses that as its ssh identity.
    3. github can't (unsurprisingly) deconflict which account you mean, since it's basing the account off the key it is presented, which if tied to more than one account, leads to pain like this. The killer is, for a long time, I was getting away with this and things just worked out.

    The entry I added is:

    Host github.com
        Hostname github.com
        Port 22
        User waterproofpatch
        IdentityFile ~/.ssh/id_rsa_waterproofpatch
    

    I had created a new key, unique to my account, as id_rsa_waterproofpatch. This entry in my ssh config specifies that for connections to github.com, I wish to present this key.

    Another solution would probably have been for me to log into the other account, delete the duplicate ssh key.

提交回复
热议问题