[英]Adding an SSH-key permanently in msysgit windows
我处在一种情况下,我需要我的msysgit使用不同的密钥与github对话。 但是git bash坚持只使用名为id_rsa的密钥文件。 如果我使用ssh -vT git@github.com,则只会看到id_rsa。
因此,每当我需要使用其他任何键时,我都必须做所有这些事情,
ssh-agent bash
ssh-add ~/.ssh/mygithubkey
git clone git@github.com:myaccount/myrepo.git
或在需要时将mygithubkey
重命名为id_rsa
,以将原始id_rsa备份到另一个文件anotherkey
当然这很痛苦,尤其是因为常规git bash的命令历史也有所不同。
stackoverflow中的其他答案仅有助于达到我的上述解决方法。 如果我做
ssh-add ~/.ssh/mygithubkey
直接在我的git bash中,它说无法连接到ssh-agent。 如果我做
ssh-agent ssh-add ~/.ssh/mygithubkey
git pull
ssh -vT git@github.com
直接在我的git bash中,它说权限被拒绝,看来ssh-add
并没有真正永久添加密钥! 在详细模式下查看调试消息时,没有提供添加的密钥。
在ssh到github时,是否有永久添加要提供的ssh密钥的列表? 我今天主要是Windows用户,因此请在答案中花点时间。
我建议使用类似于此答案的~/.ssh/config
文件。 就像是:
Host github1
User git
Hostname github.com
IdentityFile ~/.ssh/mygithubkey
Host github2
User git
Hostname github.com
IdentityFile ~/.ssh/myothergithubkey
这样,您可以通过键入ssh github1
或ssh github2
进行连接来轻松切换键。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.