【发布时间】:2020-01-26 04:52:43
【问题描述】:
根本问题是我从来没有看到提示输入我的 SSH-Key 密码、SSH-Agent 或否。因此,它就像我输入了错误的密码并默认假装我没有钥匙。
这发生在多台计算机上。不久前我设置了我的 ssh 密钥,一切都很好,但每隔一段时间我会执行一次 git push(通常在重新启动计算机后),我会被要求输入我的 git 原始服务器的密码,而不是我的 ssh 密钥的密码。由于我的源服务器没有密码,这让我无法推送更改。
有时它会在重新启动后自行解决,有时则不会。通常我会做很多猜测,其中一个最终解决了问题,但我目前不记得哪些有效,哪些无效。
解决此问题的正确方法是什么?实际问题是什么?我的 SSH 密钥是否被锁定?某些 Windows 进程是否无法正确启动?路径变量被吃掉了吗?对windows了解不多(一般都是在linux上开发的),所以在这里比较茫然。
编辑:第一个答案提到了 ssh-agent。一些谷歌搜索让我到了这里:
https://help.github.com/articles/working-with-ssh-key-passphrases/#platform-windows
其中解释了如何设置 ssh-agent 以自动启动并了解您在 Windows 中的密钥。 (我什至不知道您可以在 Windows 中使用 bash 配置文件)。
这没有帮助。
我的 git bash 现在说“添加了身份:/c/Users/{{ME}}/.ssh/id_rsa”它不会询问我的密钥密码,我仍然无法推送到我的源服务器(它询问对于服务器密码,仍然)。
我可以确认我的 ssh 密钥确实存在于代理正在查找的位置。我还可以确认已添加密钥:ssh-add -l 从我的密钥存储位置显示单个密钥。
编辑:将 GIT_SSH 设置为指向 ssh 的可执行文件的环境变量也无济于事,但无论如何它是一个很长的尝试。
编辑: ssh git@git.myhost.com 输出:
$ 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:
输出屏幕帮助我确定 ssh 密钥正在被使用,但被服务器拒绝。我发现我的服务器知道的 ssh 密钥与我的机器所拥有的 ssh 密钥不匹配,尽管不到一个月前一切正常。我重新添加了我拥有的 ssh 密钥,并且能够推送我的更改。
有人知道在所有这些过程中如何重新生成 ssh 密钥(我很确定我没有明确地这样做)吗?
【问题讨论】:
-
请提供 ssh 的输出,并为失败的连接尝试设置 -v 标志。
-
完成。我无法确定原木的正面或反面。看起来它提供了我的 RSA 公钥……然后就忘记了它并直接跳到密码验证。没有错误,没有问题。如果“服务器不允许漫游”很重要,为什么我在 Linux 中没有问题,有时在我的 Windows 机器上也没有问题? ...也许是因为我在 wifi 上?
-
不,有线IP地址并不比wifi IP地址好。
-
...好吧,输出为我做的一件事是让我确认我的密钥实际上在服务器中。不知何故,它不是。我不记得重新生成了我的 windows 密钥,我向你保证我已经花了相当长的时间在我的 windows 机器上成功使用 git。我在我的 git 服务器上看到一个密钥,我相当确定它对应于我的 Windows 机器,它不是我当前的密钥。有什么线索吗?
-
感谢您的接受。我建议将后续问题移至另一个问题,因为它具有完全不同的要求。
标签: windows