服务器 git clone 提示 Permission denied,用同样的 key 却在 MacBook 可以克隆下来,请大家提供下思路

2017-04-17 20:11:11 +08:00
 YK46PTT

用 Bitbucket 托管代码,服务器 git clone git@bitbucket.org:xxx/xxx.git 提示

Permission denied (publickey).
fatal: Could not read from remote repository.

ssh -v git@bitbucket.org

结果如下

OpenSSH_6.6.1, OpenSSL 1.0.1e-fips 11 Feb 2013
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 56: Applying options for *
debug1: Connecting to bitbucket.org [104.192.143.1] port 22.
debug1: Connection established.
debug1: identity file /home/root/.ssh/id_rsa type 1
debug1: identity file /home/root/.ssh/id_rsa-cert type -1
debug1: identity file /home/root/.ssh/id_dsa type -1
debug1: identity file /home/root/.ssh/id_dsa-cert type -1
debug1: identity file /home/root/.ssh/id_ecdsa type -1
debug1: identity file /home/root/.ssh/id_ecdsa-cert type -1
debug1: identity file /home/root/.ssh/id_ed25519 type -1
debug1: identity file /home/root/.ssh/id_ed25519-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 conker_1.0.288-e9ef8ea app-152
debug1: no match: conker_1.0.288-e9ef8ea app-152
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-sha1 none
debug1: kex: client->server aes128-ctr hmac-sha1 none
debug1: kex: curve25519-sha256@libssh.org need=20 dh_need=20
debug1: kex: curve25519-sha256@libssh.org need=20 dh_need=20
debug1: sending SSH2_MSG_KEX_ECDH_INIT
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: RSA 97:8c:1b:f2:6f:14:6b:5c:3b:ec:aa:46:46:74:7c:40
debug1: Host 'bitbucket.org' is known and matches the RSA host key.
debug1: Found key in /home/root/.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: 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: /home/root/.ssh/id_rsa
debug1: Server accepts key: pkalg ssh-rsa blen 279
debug1: Authentication succeeded (publickey).
Authenticated to bitbucket.org ([104.192.143.1]:22).
debug1: channel 0: new [client-session]
debug1: Entering interactive session.
debug1: Sending environment.
debug1: Sending env LANG = en_US.UTF-8
PTY allocation request failed on channel 0
authenticated via a deploy key.


You can use git or hg to connect to Bitbucket. Shell access is disabled.

This deploy key has read access to the following repositories:

okchum/enbo: root@west -- root@west
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
debug1: channel 0: free: client-session, nchannels 1
Connection to bitbucket.org closed.
Transferred: sent 3600, received 1872 bytes, in 3.6 seconds
Bytes per second: sent 1003.6, received 521.9
debug1: Exit status 0

但是奇怪的是 MacBook 上用同样的 private key 克隆,没问题。看起来是服务器问题。 已经多次生成 key pairs ,将 public key 放到 bitbucket 了,没解决问题。 也试过 chmod 600 ~/.ssh/id_rsa

ssh-add -l 也有这个 private key

大家帮忙看下还有什么思路解决?

谢谢大伙

2587 次点击
所在节点    问与答
7 条回复
SoloCompany
2017-04-17 23:16:22 +08:00
先升级一下你本地的 ssh 吧
sagaxu
2017-04-17 23:32:45 +08:00
用 sudo 了?
msg7086
2017-04-18 01:24:59 +08:00
/home/root/.ssh/id_rsa

会不会和这个奇怪的路径有关?
Valyrian
2017-04-18 01:38:59 +08:00
可以试试 ssh -A
DravenJohnson
2017-04-18 04:42:08 +08:00
`chmod 400 ~/.ssh/id_rsa`
DravenJohnson
2017-04-18 04:43:14 +08:00
@DravenJohnson
先确定你的 ~ 和 `/home/root/` 是一样的,如果服务器登陆用户不是 root 而且又用了 sudo 的话, key 的位置可能会不一样
BOYPT
2017-04-18 10:16:12 +08:00
似乎是在 git 里面跑了不一样的 ssh 命令,先看看~/.gitconfig 等全局配置看看有什么奇怪的东西不

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/355470

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX