Bitbucket ssh 克隆权限被拒绝(公钥)

时间:2021-03-10 19:20:36

标签: git ubuntu ssh bitbucket

我在使用 bitbucket 时遇到了一些麻烦,我正在尝试使用 ssh 连接配置 ubuntu 服务器。连接测试工作正常,但 git 命令返回权限被拒绝。

知道如何修复它吗?

<块引用>

sudo git clone git@bitbucket.org:workspace/repo.git

Cloning into 'repo'...
git@bitbucket.org: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
<块引用>

ssh -T git@bitbucket.org

logged in as user

You can use git to connect to Bitbucket. Shell access is disabled
<块引用>

ssh -v git@bitbucket.org

OpenSSH_7.6p1 Ubuntu-4ubuntu0.3, OpenSSL 1.0.2n  7 Dec 2017
debug1: Reading configuration data /home/ubuntu/.ssh/config
debug1: /home/ubuntu/.ssh/config line 1: Applying options for bitbucket.org
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to bitbucket.org [18.205.93.1] port 22.
debug1: Connection established.
debug1: identity file /home/ubuntu/.ssh/bitbucket type 0
debug1: key_load_public: No such file or directory
debug1: identity file /home/ubuntu/.ssh/bitbucket-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_7.6p1 Ubuntu-4ubuntu0.3
debug1: Remote protocol version 2.0, remote software version conker_fd15f4a5a7-dirty conker-3000
debug1: no match: conker_fd15f4a5a7-dirty conker-3000
debug1: Authenticating to bitbucket.org:22 as 'git'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256@libssh.org
debug1: kex: host key algorithm: ssh-rsa
debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ssh-rsa SHA256:zzXQOXSRBEaDSDKLSKAJSaxvSc0ojez9YXaGp1A
debug1: Host 'bitbucket.org' is known and matches the RSA host key.
debug1: Found key in /home/ubuntu/.ssh/known_hosts:1
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering public key: RSA SHA256:lZBehjvQfr95nWiLDASDKJSSAmQ1BHwebaPeZfzrxw /home/ubuntu/.ssh/bitbucket
debug1: Server accepts key: pkalg ssh-rsa blen 279
debug1: Authentication succeeded (publickey).
Authenticated to bitbucket.org ([18.205.93.1]:22).
debug1: channel 0: new [client-session]
debug1: Entering interactive session.
debug1: pledge: network
debug1: Sending environment.
debug1: Sending env LANG = C.UTF-8
debug1: Sending env LC_CTYPE = C.UTF-8
PTY allocation request failed on channel 0
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
logged in as user

You can use git to connect to Bitbucket. Shell access is disabled
debug1: channel 0: free: client-session, nchannels 1
Connection to bitbucket.org closed.
Transferred: sent 3020, received 1804 bytes, in 0.0 seconds
Bytes per second: sent 515896.1, received 308171.1
debug1: Exit status 0
  • Ubuntu 18.04.5 LTS

1 个答案:

答案 0 :(得分:1)

首先不要使用 sudo:如果您的 ssh -Tv 工作正常,则它作为您当前的用户工作,使用 /home/current-user/.ssh/<yourKey>

但是使用 sudo,您将切换到超级用户,使用 /root/.ssh/ 键,这些键可能不存在或未注册到 BitBucket。