git ssh :Permission denied (publickey)

24,767

Solution 1

Searching google for "Agent admitted failure to sign using the key." suggests that logging out of your current session and then back in, or using ssh-add should solve the problem

Rationale: Ubuntu uses ssh-agent program:

 ssh-agent is a program to hold private keys used for public key authentication (RSA, DSA, ECDSA).  The idea
 is that ssh-agent is started in the beginning of an X-session or a login session, and all other windows or
 programs are started as clients to the ssh-agent program.  Through use of environment variables the agent can
 be located and automatically used for authentication when logging in to other machines using ssh(1).

If you just generated a key, ssh-agent does not know about it so it can't sign using the key - exactly what the error message says.

To add the key, you either need to restart ssh-agent (i.e. log out and log back in) or to use ssh-add to re-scan the keys.

See man ssh-add and man ssh-agent for more info

Solution 2

Did you properly set up git and the ssh keys. If not see here.

Taken from github:

This problem can also be caused when ssh cannot find your keys. Make sure your key is in the default location, ~/.ssh. If you run ssh-keygen again and just press enter at all 3 prompts it will be placed here automatically. Then you can add the contents of id_rsa.pub to your account. If id_rsa.pub doesn’t work try id_dsa.pub. You might need to generate a new dsa key with ssh-keygen -t dsa if you just have an rsa key.

P.S. Also sometimes the URL is typed wrong. URLs are case sensitive. Make sure to type them properly.


See this also.

Share:
24,767

Related videos on Youtube

Gnijuohz
Author by

Gnijuohz

Updated on September 18, 2022

Comments

  • Gnijuohz
    Gnijuohz over 1 year

    I tried to use github so I followed the help doc. But when I used this command : ssh -vT [email protected] I got error like this:

    jacos@Jing:~/.ssh$ ssh -vT [email protected]
    OpenSSH_5.8p1 Debian-7ubuntu1, OpenSSL 1.0.0e 6 Sep 2011
    debug1: Reading configuration data /home/jacos/.ssh/config
    debug1: Applying options for github.com
    debug1: Reading configuration data /etc/ssh/ssh_config
    debug1: Applying options for *
    debug1: Connecting to ssh.github.com [207.97.227.248] port 443.
    debug1: Connection established.
    debug1: identity file /home/jacos/.ssh/id_rsa type 1
    debug1: Checking blacklist file /usr/share/ssh/blacklist.RSA-2048
    debug1: Checking blacklist file /etc/ssh/blacklist.RSA-2048
    debug1: identity file /home/jacos/.ssh/id_rsa-cert type -1
    debug1: identity file /home/jacos/.ssh/id_dsa type -1
    debug1: identity file /home/jacos/.ssh/id_dsa-cert type -1
    debug1: identity file /home/jacos/.ssh/id_ecdsa type -1
    debug1: identity file /home/jacos/.ssh/id_ecdsa-cert type -1
    debug1: Remote protocol version 2.0, remote software version OpenSSH_5.1p1 Debian-5github2
    debug1: match: OpenSSH_5.1p1 Debian-5github2 pat OpenSSH*
    debug1: Enabling compatibility mode for protocol 2.0
    debug1: Local version string SSH-2.0-OpenSSH_5.8p1 Debian-7ubuntu1
    debug1: SSH2_MSG_KEXINIT sent
    debug1: SSH2_MSG_KEXINIT received
    debug1: kex: server->client aes128-ctr hmac-md5 none
    debug1: kex: client->server aes128-ctr hmac-md5 none
    debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
    debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
    debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
    debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
    debug1: Server host key: RSA 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48
    debug1: Host '[ssh.github.com]:443' is known and matches the RSA host key.
    debug1: Found key in /home/jacos/.ssh/known_hosts:4
    debug1: ssh_rsa_verify: signature correct
    debug1: SSH2_MSG_NEWKEYS sent
    debug1: expecting SSH2_MSG_NEWKEYS
    debug1: SSH2_MSG_NEWKEYS received
    debug1: Roaming not allowed by server
    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/jacos/.ssh/id_rsa
    debug1: Remote: Forced command: gerve gnijuohz 54:da:c2:c1:ca:4a:b9:4d:21:10:5b:42:3f:5a:8e:f7
    debug1: Remote: Port forwarding disabled.
    debug1: Remote: X11 forwarding disabled.
    debug1: Remote: Agent forwarding disabled.
    debug1: Remote: Pty allocation disabled.
    debug1: Server accepts key: pkalg ssh-rsa blen 279
    Agent admitted failure to sign using the key.
    debug1: Trying private key: /home/jacos/.ssh/id_dsa
    debug1: Trying private key: /home/jacos/.ssh/id_ecdsa
    debug1: No more authentication methods to try.
    Permission denied (publickey).
    

    Agent admitted to sign using the key? No more authentication methods to try?

    Can someone explain what's wrong here?

    Thanks.

  • grosshat
    grosshat almost 12 years
    It works as Sergey explains and both solution are good. Thanks.
  • dolmen
    dolmen about 9 years
    No, Ubuntu doesn't uses ssh-agent. Instead it uses an alternate implementation of the SSH agent feature: gnome-keyring-daemon (which has its own issues)
  • dolmen
    dolmen about 9 years
    Suggesting to create an SSH key without password is a very bad security advice.