Git 生成的密钥,添加到我的帐户,ssh不工作(权限被拒绝)

Git 生成的密钥,添加到我的帐户,ssh不工作(权限被拒绝),git,cloudbees,Git,Cloudbees,我使用的是MacOS10.9。 我用ssh-keygen生成了我的ssh密钥。我将pub密钥粘贴为我帐户中的新安全密钥。我重新启动了我的电脑。然后 $sshgit@git.cloudbees.com回音 权限被拒绝(公钥) 我试了好几次,都没有任何进展。 我浏览了一些想法,但没有找到任何帮助 以下是针对服务器的验证跟踪: MacBook-Pro-de-Ludovic:~ Ludo$ echo | ssh -v -i ~/.ssh/id_rsa git@git.cloudbees.com echo

我使用的是MacOS10.9。 我用ssh-keygen生成了我的ssh密钥。我将pub密钥粘贴为我帐户中的新安全密钥。我重新启动了我的电脑。然后 $sshgit@git.cloudbees.com回音 权限被拒绝(公钥)

我试了好几次,都没有任何进展。 我浏览了一些想法,但没有找到任何帮助

以下是针对服务器的验证跟踪:

MacBook-Pro-de-Ludovic:~ Ludo$ echo | ssh -v -i ~/.ssh/id_rsa git@git.cloudbees.com echo
OpenSSH_6.2p2, OSSLShim 0.9.8r 8 Dec 2011
debug1: Reading configuration data /etc/ssh_config
debug1: /etc/ssh_config line 20: Applying options for *
debug1: Connecting to git.cloudbees.com [54.235.125.211] port 22.
debug1: Connection established.
debug1: identity file /Users/Ludo/.ssh/id_rsa type 1
debug1: identity file /Users/Ludo/.ssh/id_rsa-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.2
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.0
debug1: match: OpenSSH_6.0 pat OpenSSH*
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<1024<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 34:fe:24:48:6c:46:ff:1c:96:fc:d0:b6:7f:f8:51:e5
debug1: Host 'git.cloudbees.com' is known and matches the RSA host key.
debug1: Found key in /Users/Ludo/.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
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /Users/Ludo/.ssh/id_rsa
debug1: Authentications that can continue: publickey
debug1: Offering RSA public key: /Users/Ludo/.ssh/id_rsa
debug1: Authentications that can continue: publickey
debug1: No more authentication methods to try.
Permission denied (publickey).
MacBookPro de Ludovic:~Ludo$echo | ssh-v-i~/.ssh/id_rsagit@git.cloudbees.com回音
OpenSSH_6.2p2,OSSLShim 0.9.8r 2011年12月8日
debug1:读取配置数据/etc/ssh\u config
debug1:/etc/ssh\u配置第20行:应用*
debug1:连接到git.cloudbees.com[54.235.125.211]端口22。
debug1:已建立连接。
debug1:identity file/Users/Ludo/.ssh/id\u rsa类型1
debug1:identity file/Users/Ludo/.ssh/id_rsa-cert type-1
debug1:启用协议2.0的兼容模式
debug1:本地版本字符串SSH-2.0-OpenSSH_6.2
debug1:远程协议版本2.0,远程软件版本OpenSSH_6.0
debug1:match:OpenSSH_6.0 pat OpenSSH*
debug1:SSH2\u MSG\u KEXINIT已发送
debug1:SSH2\u MSG\u KEXINIT已收到
debug1:kex:server->client aes128 ctr hmac-md5无
debug1:kex:客户端->服务器aes128 ctr hmac-md5无

debug1:SSH2\u MSG\u KEX\u DH\u GEX\u请求(1024根据您的日志,看起来确实使用了错误的ssh密钥

我创建了一个帐户,添加了一个用ssh-keygen生成的新ssh密钥(无参数)

调试代码段显示以下内容:

debug1: Offering RSA public key: /root/.ssh/id_rsa
debug1: Server accepts key: pkalg ssh-rsa blen 279
debug1: read PEM private key done: type RSA
debug1: Authentication succeeded (publickey).
ssh-keygen-l显示的指纹与cloudbees门户中显示的指纹相匹配

这有点牵强,但是……您能告诉我在生成密钥时您在“ssh keygen”中添加了哪些参数吗?您可能偶然发现了一种不受支持的密钥格式


否则,请使用新密钥重新启动。

权限被拒绝错误意味着没有向SSH服务器提供已知密钥

要测试CloudBees是否正确注册了您期望的密钥,请执行以下操作:

echo | ssh -v -i ~/.ssh/id_rsa git@git.cloudbees.com echo
这将显示SSH客户端活动的跟踪


如果这样做有效,那么可能是您的git客户端没有正确使用SSH。

我在Windows 7和MINGW32上遇到了相同的问题(完全相同的SSH日志,相同的cloudbees主机密钥指纹)

我知道你的是在Mac OS上,但我设法找到了一个解决办法,我希望这可能会帮助其他人

这篇文章描述了这个问题: 他们建议在git中使用PuTTY而不是OpenSSH,就像@d_rez90建议的那样,作为一种解决方法。
(对我来说很好)

我通常在Windows上使用Pageant。从您添加的日志中,我可以得出的唯一结论是,正在向远程ssh服务器提供密钥,而远程ssh服务器拒绝了该密钥。您是否重新检查/重新上传了密钥?github会显示我上传的公钥指纹,可能cloudbees也会这样做。请使用ssh-keygen-l/Users/Ludo/.ssh/id_rsa来显示私钥指纹。他们应该匹配,但这并不能解决问题。如果你想看的话,我在问题中添加了ssh-v的痕迹。它与mac os10.9.2相关,似乎存在一个bug。对于不适用于me的解决方法,你是绝对正确的。这让我很困惑,为什么每个人的体验都不同sed ssh、git、github、bitbucket和ssh到许多运行许多版本的服务器。我为所有服务器都提供了密钥(太多,无法加载到ssh代理,因为只尝试了前五个)。只有git.cloudbees.com对我失败。我甚至添加了“host git.cloudbees.com/identityfile cloudbees.key”到~/.ssh/config,它拒绝了它。我想我们将不得不等待苹果的修复。是的,如果你想检查结果,ssh-v也会失败。谢谢!你能跟踪一下你打开的支持票证上的
ssh-v
尝试的输出吗。