how to add deploy key for 2 repo with 1 user on github

前端 未结 1 1703
北恋
北恋 2020-12-09 06:49

I create a deploy user, generate an ssh_key, I add id_rsa.pub as github deploy key.

this deploy user need pull 2 repo, so I add the same ssh

相关标签:
1条回答
  • 2020-12-09 07:17

    You can create two public/private keys with whatever name you want:

    ~/.ssh
      repo1
      repo1.pub
      repo2
      repo2.pub
    
      config
    

    (Ie it doesn't have to be named id_rsa(.pub) to work, provided you indicate ssh where to look.
    That is where 'config' comes into play: the config file includes the name of your two connections for GitHub repo1 and GitHub repo2 with, for each connection, the path to your private repo key, as described in "change github account mac command line" and in "Quick Tip: How to Work with GitHub and Multiple Accounts":

    Host githubRepo1
    HostName github.com
    User git
    IdentityFile ~/.ssh/repo1
    
    Host githubRepo2
    HostName github.com
    User git
    IdentityFile ~/.ssh/repo2
    

    That way you can pull from any of the two repos, as long as you are using their ssh addresses.

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