多年来,每当我(或我公司的任何人,似乎)尝试在Windows上使用git时,一切都会正常工作一段时间,直到突然它的行为就像它不知道什么是ssh键了。它会停止提示我输入密码,而是要求我提供git服务器的密码。
ssh -v向我指出了正确的方向,即windows知道我的ssh密钥,但我的服务器似乎没有接受它。
$ ssh -v git@git.myhost.lan
OpenSSH_6.6.1, OpenSSL 1.0.1i 6 Aug 2014
debug1: Reading configuration data /c/Users/eschjen/.ssh/config
debug1: /c/Users/eschjen/.ssh/config line 1: Applying options for git.myhost
.lan
debug1: Connecting to git.myhost.lan [10.116.22.40] port 22.
debug1: Connection established.
debug1: identity file /c/Users/eschjen/.ssh/id_rsa type 1
debug1: identity file /c/Users/eschjen/.ssh/id_rsa-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.6.1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.3
debug1: match: OpenSSH_5.3 pat OpenSSH_5* compat 0x0c000000
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<3072<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Server host key: RSA ae:81:77:0d:1c:8e:6a:aa:a8:69:36:1b:e4:ca:33:ee
debug1: Host 'git.myhost.lan' is known and matches the RSA host key.
debug1: Found key in /c/Users/eschjen/.ssh/known_hosts:1
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mi
c,password
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /c/Users/eschjen/.ssh/id_rsa
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mi
c,password
debug1: Next authentication method: password
git@git.myhost.lan's password:
查看我的服务器,我可以看到我的旧Windows公共ssh密钥已上传,但它不再与我的计算机上的那个匹配。像新计算机一样上传新密钥可以完全解决问题。
这是Windows偶尔会做的吗?为什么我的钥匙突然变得无效?我在不到一年前创建它。
答案 0 :(得分:2)
Windows本身不会重置ssh密钥。
但id_rsa
/ id_rsa.pub
是默认 ssh私钥和公钥文件名。
这意味着如果任何其他应用程序生成一组新密钥,则所述密钥将被覆盖。
为了提高ssh设置的稳健性,可能的解决方法是:
%HOME%\.ssh
中重命名您的密钥:%HOME%\.ssh\config
中添加私钥的完整路径类似的东西:
Host git.myhost.lan
HostName git.myhost.lan
User git
IdentityFile C/Users/<yourLogin>/.ssh/git.myhost.lan
然后尝试ssh -Tv git.myhost.lan
(不需要git@
)
答案 1 :(得分:0)
另一种可能的选择是你的ssh-agent由于某种原因而被停止,所以你必须启动它
// restart ssh agent
eval $(ssh-agent)
// verify that your ssh keys are added to the agent
// if you dont specify key it will use the default keys
ssh-add