2016-11-25 84 views
0

我在Github上的同一个帐户上的一台机器上有两个存储库。我为我的帐户添加了一个ssh密钥,并推送到存储库A,但我无法将其推送到存储库B.github上的SSH密钥未与特定的repos iirc关联。使用SSH推送到2个不同的回购使用相同的帐户?

有点研究让我发现我需要两个不同的密钥。如何编辑我的配置文件,以便git在推向第二个回购时使用正确的密钥?

+1

加入你不要” t需要2个键。你遇到了什么错误? – SLaks

+0

权限被拒绝(公钥)。但推动回购A工作正常 –

+0

确保两个回购处于同一个帐户下。你可以为你的回购附加'git ls-remote --get-url origin'的输出吗? –

回答

0

我到了解决方案通过修改你的.ssh/config文件中附加此

Host repo2.github.com 
    User git 
    Port 22 
    Hostname github.com 
    IdentityFile ~/.ssh/id_rsa2 
    TCPKeepAlive yes 
    IdentitiesOnly yes 
    UserKnownHostsFile /dev/null 
    StrictHostKeyChecking no 

,然后通过附加下面的git的/ config文件

[remote "origin"] 
    url = [email protected]:[Username]/G2-FrontEnd.git 
    fetch = +refs/heads/*:refs/remotes/origin/* 
相关问题