I decided to start switching my machines over from Ubuntu to pure Debian but I'm currently stuck at a hurdle with configuring my git repositories related to ssh. I created a new key and added it to the remote server but whenever I attempt to pull a repository, I receive the error:
xxx@xxx:~/Documents/my-repo$ git pull sign_and_send_pubkey: signing failed: agent refused operation Permission denied (publickey). fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. My permissions all seem to be correct:
xxx@xxx:~$ ls -al .ssh total 20 drwx------ 2 xxx xxx 4096 Apr 4 12:50 . -r-------- 1 xxx xxx 3381 Apr 4 12:46 id_rsa -rw-r--r-- 1 xxx xxx 740 Apr 4 12:46 id_rsa.pub Also, the key is listed:
xxx@xxx:~$ ssh-add -l 4096 SHA256:my-hash my-comment (RSA) However, if I do the following it works:
xxx@xxx:~/Documents/my-repo$ ssh-agent git pull Already up-to-date. I've found several articles with the same ssh error, but the resolutions in those articles have not helped (i.e. my permissions already seem to be correct, my key is added/recognized, etc). I've been at this off-and-on in my free time for several weeks and haven't been able to resolve.
Based on the suggestion in the comments, I ran the following:
xxx@xxx:~/Documents/my-repo$ GIT_TRACE=true git pull 12:46:02.190213 git.c:371 trace: built-in: git 'pull' 12:46:02.192426 run-command.c:350 trace: run_command: 'fetch' '--update-head-ok' 12:46:02.192653 exec_cmd.c:116 trace: exec: 'git' 'fetch' '--update-head-ok' 12:46:02.198382 git.c:371 trace: built-in: git 'fetch' '--update-head-ok' 12:46:02.200462 run-command.c:350 trace: run_command: 'ssh' '[email protected]' 'git-upload-pack '\''xxx/my-repo.git'\''' sign_and_send_pubkey: signing failed: agent refused operation Permission denied (publickey). fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. Followed by:
xxx@xxx:~/Documents/my-repo$ ssh -v [email protected] git-upload-pack xxx/my-repo.git OpenSSH_7.4p1 Debian-10+deb9u6, OpenSSL 1.0.2r 26 Feb 2019 debug1: Reading configuration data /etc/ssh/ssh_config debug1: /etc/ssh/ssh_config line 19: Applying options for * debug1: Connecting to gitlab.com [35.231.145.151] port 22. debug1: Connection established. debug1: identity file /home/xxx/.ssh/id_rsa type 1 debug1: key_load_public: No such file or directory debug1: identity file /home/xxx/.ssh/id_rsa-cert type -1 debug1: key_load_public: No such file or directory debug1: identity file /home/xxx/.ssh/id_dsa type -1 debug1: key_load_public: No such file or directory debug1: identity file /home/xxx/.ssh/id_dsa-cert type -1 debug1: key_load_public: No such file or directory debug1: identity file /home/xxx/.ssh/id_ecdsa type -1 debug1: key_load_public: No such file or directory debug1: identity file /home/xxx/.ssh/id_ecdsa-cert type -1 debug1: key_load_public: No such file or directory debug1: identity file /home/xxx/.ssh/id_ed25519 type -1 debug1: key_load_public: No such file or directory debug1: identity file /home/xxx/.ssh/id_ed25519-cert type -1 debug1: Enabling compatibility mode for protocol 2.0 debug1: Local version string SSH-2.0-OpenSSH_7.4p1 Debian-10+deb9u6 debug1: Remote protocol version 2.0, remote software version OpenSSH_7.2p2 Ubuntu-4ubuntu2.8 debug1: match: OpenSSH_7.2p2 Ubuntu-4ubuntu2.8 pat OpenSSH* compat 0x04000000 debug1: Authenticating to gitlab.com:22 as 'git' debug1: SSH2_MSG_KEXINIT sent debug1: SSH2_MSG_KEXINIT received debug1: kex: algorithm: [email protected] debug1: kex: host key algorithm: ecdsa-sha2-nistp256 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: Server host key: ecdsa-sha2-nistp256 SHA256:HbW3g8zUjNSksFbqTiUWPWg2Bq1x8xdGUrliXFzSnUw debug1: Host 'gitlab.com' is known and matches the ECDSA host key. debug1: Found key in /home/xxx/.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_EXT_INFO received debug1: kex_input_ext_info: server-sig-algs=<rsa-sha2-256,rsa-sha2-512> debug1: SSH2_MSG_SERVICE_ACCEPT received debug1: Authentications that can continue: publickey debug1: Next authentication method: publickey debug1: Offering RSA public key: /home/xxx/.ssh/id_rsa debug1: Server accepts key: pkalg rsa-sha2-512 blen 535 sign_and_send_pubkey: signing failed: agent refused operation debug1: Trying private key: /home/xxx/.ssh/id_dsa debug1: Trying private key: /home/xxx/.ssh/id_ecdsa debug1: Trying private key: /home/xxx/.ssh/id_ed25519 debug1: No more authentication methods to try. Permission denied (publickey).
GIT_TRACE=true git pullto see what SSH command it tries to run, then issue it yourself (with added-voptions, if necessary) to debug the problem. Add all this info to your question if the problem persists.echo $SSH_AUTH_SOCKoutputs/run/user/1000/keyring/sshyou use gnome-keyring. Disabling agent usage likeSSH_AUTH_SOCK= git pullshould work if your key isn't protected by a passphrase (which isn't recommended). You need to fix your desktop environment, bugs.launchpad.net/ubuntu/+source/gnome-keyring/+bug/1586835 may help with that.