Home > Software engineering >  Permission denied (publickey). Bitbucket git pull doesn't work
Permission denied (publickey). Bitbucket git pull doesn't work

Time:11-10

I have been trying to debug this problem I am facing since 2 days now. I noticed this problem when I was trying to pull something from bitbucket. It says

[email protected]: Permission denied (publickey).
fatal: Could not read from remote repository.

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

I have tried every solution form deleting old ssh keys and adding new ones to adding the existing keys to the ssh-agent. Also, ssh -T [email protected] command again throws [email protected]: Permission denied (publickey) as the error and ssh -vT [email protected] throws the following as the error:

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: [email protected]
debug1: kex: host key algorithm: rsa-sha2-512
debug1: kex: server->client cipher: [email protected] MAC: <implicit> compression: none
debug1: kex: client->server cipher: [email protected] 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: [email protected] 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,[email protected],[email protected],[email protected],[email protected],[email protected],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: [email protected] RSA SHA256:1YofMNkb/JQpdGd8OZlyyjaX9RQR0h9c6ZWzZMDlWes agent
debug1: Authentications that can continue: publickey
debug1: No more authentication methods to try.
[email protected]: Permission denied (publickey).

Note: I observed this error to come after updating my Mac to MacOs Ventura.

CodePudding user response:

If you have already added SSH key then try setting URL

get the SSH URL from bit-bucket then,

git remote set-url origin "SSHURL"

paste URL without quotes.

CodePudding user response:

Make sure that the ~/.ssh folder and the keys have the correct permissions set.

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

Remember that you can specify which key to use, in case you got more than one key-pair. Specify the private key, not the public key:

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