权限 被 拒绝 ( 公钥 ) , Bitbucket git pull 不 起 作用

yyyllmsg  于 2022-11-20  发布在  Git
关注(0)|答案(3)|浏览(453)

我一直在尝试调试这个问题,我面临的,因为2天了。我注意到这个问题,当我试图拉的东西从bitbucket。它说

git@code.pruconnect.net: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

我已经尝试了各种解决方案,从删除旧的ssh键并添加新的ssh键到将现有的键添加到ssh-agent。同样,ssh -T git@bitbucket.org命令再次抛出git@bitbucket.org: Permission denied (publickey)错误,ssh -vT git@bitbucket.org抛出以下错误:

OpenSSH_9.0p1, LibreSSL 3.3.6
debug1: Reading configuration data /Users/amijeetthakur/.ssh/config
debug1: /Users/amijeetthakur/.ssh/config line 1: Applying options for *bitbucket.org
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 21: include /etc/ssh/ssh_config.d/* matched no files
debug1: /etc/ssh/ssh_config line 54: Applying options for *
debug1: Authenticator provider $SSH_SK_PROVIDER did not resolve; disabling
debug1: Connecting to bitbucket.org port 22.
debug1: Connection established.
debug1: identity file /Users/amijeetthakur/.ssh/id_rsa type 0
debug1: identity file /Users/amijeetthakur/.ssh/id_rsa-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_9.0
debug1: Remote protocol version 2.0, remote software version conker_44eee6a33e b7cd6ff70e1a
debug1: compat_banner: no match: conker_44eee6a33e b7cd6ff70e1a
debug1: Authenticating to bitbucket.org:22 as 'git'
debug1: load_hostkeys: fopen /Users/amijeetthakur/.ssh/known_hosts2: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts2: No such file or directory
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256@libssh.org
debug1: kex: host key algorithm: rsa-sha2-512
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: SSH2_MSG_KEX_ECDH_REPLY received
debug1: Server host key: ssh-rsa SHA256:zzXQOXSRBEiUtuE8AikJYKwbHaxvSc0ojez9YXaGp1A
debug1: load_hostkeys: fopen /Users/amijeetthakur/.ssh/known_hosts2: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts2: No such file or directory
debug1: Host 'bitbucket.org' is known and matches the RSA host key.
debug1: Found key in /Users/amijeetthakur/.ssh/known_hosts:1
debug1: rekey out after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey in after 134217728 blocks
debug1: get_agent_identities: bound agent to hostkey
debug1: get_agent_identities: agent returned 2 keys
debug1: Will attempt key: /Users/amijeetthakur/.ssh/id_rsa RSA SHA256:nux65XHIgoNnct40pwEJWQ+kLrA2W2r0oqm9PHGvH1Q explicit agent
debug1: Will attempt key: amijeet.thakur@wedopulse.co.in RSA SHA256:1YofMNkb/JQpdGd8OZlyyjaX9RQR0h9c6ZWzZMDlWes agent
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-rsa-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,ssh-dss-cert-v01@openssh.com,ecdsa-sha2-nistp256-cert-v01@openssh.com,ssh-rsa,rsa-sha2-256,rsa-sha2-512,ssh-dss,ecdsa-sha2-nistp256>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering public key: /Users/amijeetthakur/.ssh/id_rsa RSA SHA256:nux65XHIgoNnct40pwEJWQ+kLrA2W2r0oqm9PHGvH1Q explicit agent
debug1: Authentications that can continue: publickey
debug1: Offering public key: amijeet.thakur@wedopulse.co.in RSA SHA256:1YofMNkb/JQpdGd8OZlyyjaX9RQR0h9c6ZWzZMDlWes agent
debug1: Authentications that can continue: publickey
debug1: No more authentication methods to try.
git@bitbucket.org: Permission denied (publickey).

注意:我观察到这个错误来后,更新我的Mac到MacOs文图拉。

vxbzzdmp

vxbzzdmp1#

如果已添加SSH密钥,请尝试设置URL
从比特桶中获取SSH URL,

git remote set-url origin "SSHURL"

粘贴不带引号URL。

h7appiyu

h7appiyu2#

请确保 ~/.ssh 文件夹和注册表项设置了正确的权限。

$ chmod 700 ~/.ssh
$ chmod 400 ~/.ssh/id_rsa
$ chmod 400 ~/.ssh/id_rsa.pub

记住,如果你有多个密钥对,你可以指定使用哪个密钥。指定私钥,而不是公钥:

$ ssh -i ~/.ssh/id_rsa user@host

当处理多个密钥对时,ssh客户端需要知道使用哪个密钥。在 ~/.ssh/config 中添加以下行:

Host bitbucket.org
    PreferredAuthentications publickey
    IdentityFile ~/.ssh/another_private_key
v1uwarro

v1uwarro3#

您可以通过在/etc/ssh/ssh_config文件的末尾添加以下两行来修复它:

HostkeyAlgorithms +ssh-rsa
PubkeyAcceptedAlgorithms +ssh-rsa

或者,您可以将它们添加到所有主机的~/.ssh/config文件或仅添加到特定主机(将*更改为所需的主机):

Host *
  HostkeyAlgorithms +ssh-rsa
  PubkeyAcceptedAlgorithms +ssh-rsa

相关问题