2016-03-25 28 views
1

我从github上两个不同的私有仓库工作的工作,我已经产生了为他们每个人的两把钥匙和我有如下一个配置文件时管理SSH密钥:如何与github上

Host github.com-frontend 
HostName github.com 
User lulzimfazlija2 
IdentitiesOnly yes 
IdentityFile ~/.ssh/id_rsa_frontend 

Host github.com-backend 
HostName github.com 
User lulzimfazlija2 
IdentitiesOnly yes 
IdentityFile ~/.ssh/id_rsa_backend 

的事情是当我尝试从任何项目推送它仍然要求我从id_rsa而不是id_rsa_frontend或id_rsa_backend写入密码。

我该如何告诉git总是通过一个单一的键来识别。

我也想这样:

$ ssh -T [email protected] 

关键输入密码 '/c/Users/lulzim/.ssh/id_rsa_frontend': 嗨lulzimfazlija2 /风险投资前端!您已成功通过身份验证,但GitHub不提供shell访问权限。

但是,当我做混帐推它仍然要求我从id_rsa键写密码。

有没有什么办法可以让我从每个项目的特定键总是问我。

+0

什么是您试图推入的URL?给我们输出'git remote -v' –

+0

另外,这是什么问题?你需要每次输入密码吗? –

+0

其:[email protected]:lulzimfazlija2/venture-backend.git –

回答

0

ssh -T [email protected]是有效的,并将根据您的~/.ssh/config推送到github.com。

但是:

  • 请确保您的~/.ssh/config包括User git,不User lulzimfazlija2:你总是推到GitHub上(在SSH)为git,而不是xxx:GitHub的将SSH密钥验证您的身份(that is associated to your GitHub account)。
    您的有效测试(ssh -T [email protected])实际上包含用户git(这是正确的)。
    如果User git包括在~/.ssh/config,你的测试实际上是:
    ssh -T github.com-frontend

  • 关键输入密码意味着你的SSH私钥是密码保护。
    如果您想避免每次使用时输入密码,您需要add that ssh key to your ssh agent
    在一个git bash下

    eval $(ssh-agent -s) 
    ssh-add ~/.ssh/id_rsa_frontend 
    

然后你可以使用源URL,例如:

github.com-frontend:lulzimfazlija2/my_frontend_project 
github.com-backend:lulzimfazlija2/my_backend_project 

(不需要一个 '[email protected]' 前缀,如User git将在声明~/.ssh/config