I just upgraded my Ubuntu System from 15.10 to 16.04 by completely wiping the Ubuntu 15 partition from my system.

After installing Ubuntu 16.04 I recreated my ssh keys as I forgot to back them up, but whenever I attempt to use ssh I get sign_and_send_pubkey: signing failed: agent refused operation this is slightly annoying as it lets me through to my ssh server, but git refuses to push code using ssh.

I have already pushed the keys to the server by using ssh-copy-id.

The Server I am connecting to is a Ubuntu 16.04 Server upgraded through the do-release-upgrade command. Any help will be greatly appreciated.

share|improve this question
up vote 127 down vote accepted

Looks like an ssh-agent is running already but it can not find any keys attached. To solve this add the private key identities to the authentication agent like so:

ssh-add

Then you can ssh into your server.

in addition, you can see the list of fingerprints of all identities currently added by:

ssh-add -l
share|improve this answer
    
it's not -1 (number <one>), it's -l (lowercase L) in your second command – Daniel Alder Jun 11 '16 at 15:31
2  
@Daniel Alder It IS indeed lower case l. – Ron Jun 11 '16 at 15:38
    
You are right, sorry. Problem is the lower-case L of the font "Liberation Mono" :-( – Daniel Alder Jun 12 '16 at 13:42
    
I do not think you should use ssh-add other than to use ssh-add -l because you can end up with too many entries in the ssh-agent. There is no need to manually add. Dash > Startup Applications shows that ssh-agent is already running and it will automatically detect the files such as ~/.ssh/id_rsa and ~/.ssh/id_rsa.pub. To prove this you can use ssh-add -l before and after using ssh-keygen. You will see that it monitors the for the files so you don't have to add them manually. – H2ONaCl Jan 26 '17 at 8:20
    
Likewise do not use ssh-add -d and ssh-add -D to perform manual deletion. Just delete the key files ~/.ssh/id_rsa and ~/.ssh/id_rsa.pub and the ssh-agent will notice. To prove that you can do ssh-add -l before and after deleting the key files. – H2ONaCl Jan 26 '17 at 8:24

I was getting the sign_and_send_pubkey: signing failed: agent refused operation when logging into several servers, read VonC's answer on Stack Overflow for more information about related bugs, solution for me was to remove gnome-keyring, deleting identities from ssh-agent and reboot.

sudo apt-get autoremove gnome-keyring
ssh-add -D

Then all my keys started to work perfectly.

share|improve this answer
1  
Yes but this removes all the ssh-agent functionality which is super useful – Martin Konecny Jan 17 '17 at 15:42
    
please note us in which PC to use sudo apt-get, our own computer or remote server. thanks. – Shicheng Guo Jun 15 '17 at 3:52
    
Keyring on your own local PC, because Keyring is part of GNOME, it is not usually installed on server at all. – Mike Jun 15 '17 at 6:20

Happened to me because my private key had a passphrase. Had to run ssh-add and then it asked for the passphrase and added correctly. However, it now does not ask for my passphrase when ssh'ing to a machine.

share|improve this answer

Adding comment as I had the same issue with ed25519 keys. The issue is indeed gnome-keyring. To fix this I did the following:

  • Unchecked ssh-key-agent (gnome-keyring) in "startup applications"
  • Killed off the ssh-agent and gnome agent: (killall ssh-agent ; killall gnome-keyring-daemon)
  • Re-started the daemon: (eval ssh-agent -s)
  • Add your key: $ ssh-add id_ed25519 Enter passphrase for id_ed25519: Identity added: id_ed25519
  • Profit!!
share|improve this answer

I ended up dropping my known hosts file and it worked. Had to put in a password again, but it finally accepted the right password. It was after a new install.

share|improve this answer

I had the same problem (same symptoms)

sam@xxxxx:~/.ssh$ ssh centos@123.123.123.123
sign_and_send_pubkey: signing failed: agent refused operation
Permission denied (publickey,gssapi-keyex,gssapi-with-mic).

... but the solution was different.

The problem was coming from the use of GNOME-KEYRING. The post referring to the solution may be read here.

In short:

  1. Detect the problem by adding SSH_AUTH_SOCK=0 in front of the ssh command. sam@xxxxx:~/.ssh$ SSH_AUTH_SOCK=0 ssh centos@123.123.123.123
  2. In case it succeed to connect. Open the application StartUp Application (by using the search function of the Desktop for example) and disable the use of gnome-keyring.
  3. Reboot

The page provide other details in case of similar problem with different solution.

share|improve this answer

I tried a couple of things, among others ssh-add, resetting SSH (deleting .ssh/ on the server, and such, but no luck. So it turned out I just had to sleep over it for one night. It helped! Why? I guess the ssh-agent running on the server had something in its cache which was refreshed later that night with the now proper values. Anyhow, it now works like a charm. To wrap up, it did this (Ubuntu 16.04 on localhost, 14.04 on server).

# on local host:
$ ssh-keygen
# (yes, overwrite the default file, and let the passphrase be empty)
$ ssh-copy-id ***.***.*.**
# (insert proper server IP address)
# now test
$ ssh ***.***.*.**
# this should have erected in .ssh/ on the server:
# -rw------- 1 *** *** 2000 aug.  11 09:55 authorized_keys
# no other magic going on! :)
share|improve this answer

On my system (also Ubuntu 16.04, trying to connect to github), I had a file id_ed25519 in my .ssh folder which made ssh-add failing:

$ ssh-add
Identity added: ~/.ssh/id_rsa (~/.ssh/id_rsa)
Could not add identity "~/.ssh/id_ed25519": communication with agent failed

After removing the files ~/.ssh/id_ed25519* (didn't need them anymore, it was from an earlier test) everything went fine again.

share|improve this answer
1  
And what if you do need them? – Gringo Suave Oct 20 '16 at 23:33
    
@GringoSuave Good question. Did you try? Maybe the format changed or is not supported anymore by ssh - or it's a bug. Personally, I was happy that I didn't have to test it out... – Daniel Alder Oct 21 '16 at 9:39
    
Still not working for me, I have no solution: Could not add identity "~/.ssh/id_ed25519": communication with agent failed, agent running and configured as far as I can tell. – Gringo Suave Oct 21 '16 at 19:09

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.