Multiple SSH Keys on the same device

后端 未结 1 2028
一整个雨季
一整个雨季 2021-01-06 05:01

I registered a personal SSH key months ago and everything worked fine. Now I\'m working for a company. They created their own GitHub account and I have started a new reposit

相关标签:
1条回答
  • 2021-01-06 05:09

    Since my comment resolved OPs issue, I'm writing this as an answer.

    The problem seems to be in the fact that you have multiple ssh keys for the same host. In your .ssh/config you have configured 2 hosts - github.com and github-companyname. In your company repository, you need to change the remote url in .git/config from git@github.com:... to git@github-companyname:.... Then ssh will use the correct key and you should have no problems with authentication.

    For further reading:

    • https://gist.github.com/jexchan/2351996 especially the comments
    • http://nerderati.com/2011/03/17/simplify-your-life-with-an-ssh-config-file/

    When you need to clone an existing repository with your company key, you can apply the same approach.

    git clone git@github-companyname:companyname/repositoryname.git
    

    Notice that instead of github.com, the command uses github-companyname.

    0 讨论(0)
提交回复
热议问题