31

I just installed ubuntu 13.10 and I was about to add my identity to my ssh-agent so I open up a Terminal and did this

bjorgvin@buntu:~$ ssh-add -l
The agent has no identities.
bjorgvin@buntu:~$ ssh-add
bjorgvin@buntu:~$ ssh-add -l
The agent has no identities.
bjorgvin@buntu:~$ 

any ideas?

4 Answers 4

34

From man ssh-add:

ssh-add adds private key identities to the authentication agent, ssh-agent(1). When run without arguments, it adds the files ~/.ssh/id_rsa, ~/.ssh/id_dsa, ~/.ssh/id_ecdsa and ~/.ssh/identity.[...]

Identity files should not be readable by anyone but the user. Note that ssh-add ignores identity files if they are accessible by others.

So, because of The agent has no identities. error, you probably don't have those files or maybe those files are accessible by others. You can check these using the following command:

ls -l ~/.ssh

Also, after you run ssh-add command, run echo $? to see the error status of the previous command. If exit status returned 0, the command was executed successfully. If exit status returned a non-zero value, the command failed to execute.

See man ssh-add for more info.

5
  • true, I don't have those files and the exit value of ssh-add was 1 but not 0. there is obviously some problem with my permissions since the files are not created. Any idea how I could fix this? the directory ~/.ssh exists (is empty) but it does not show up when I do ls -l
    – bjorgvin
    Oct 23, 2013 at 15:49
  • I ran this command ssh-keygen -q -t rsa -N 'password' -f ~/.ssh/id_rsa so man ssh-keygen helped, thanks.
    – bjorgvin
    Oct 24, 2013 at 10:15
  • 1
    That gave the import hint into the right direction for me. I had multiple ssh keys and first had to add the proper key using ssh-add <keyname>. Then it worked like a charme. thx
    – paulroho
    Nov 19, 2014 at 21:40
  • 4
    For some reason, I did not have any output when running ssh-add after entering passphrase, (it was failing according to $? returing 1. I tried to chmod 600 ~/.ssh/id_rsa* with no luck. I generated a new key from scratch with ssh-keygen and then it worked. Sad but at least it's ok now (The failing key was generated using ssh-keygen -t rsa -b 4096 -C "[email protected]", I only ran ssh-keygen instead this time).
    – GabLeRoux
    Jun 24, 2015 at 9:11
  • 2
    I had to do the following in this order: (if necessary, generate new ssh key, and make sure to add the .pub key to github), then cd ~/.ssh && ls -lah to see read/write permissions in the .ssh folder, change all key(s) with chmod 400 myKey then ssh-add **ABSOLUTE**pathToKey if you don't add the ABSOLUTE path, it won't work. Then, test it with ssh -vT [email protected]
    – jungledev
    Nov 22, 2016 at 22:19
5

Additional to the above considerations, I found that if you're using an alternate shell, you may need to configure it to load ssh-agent. For example, in Zsh, one must add ssh-agent to plugins in .zshrc.

This method works great on Ubuntu 17.10 with the latest Zsh

Others found that with id_ed25519 keys, rsa was working without a plugin. After adding ssh-agent to ~/.zshrc, restart the shell with exec "$SHELL" and execute: ssh-add ~/.ssh/id_ed25519

Enter passphrase for ~/.ssh/id_ed25519: 
Identity added: ~/.ssh/id_ed25519 (user@host)
1
2

As the OP states in a comment:

I ran this command ssh-keygen -q -t rsa -N 'password' -f ~/.ssh/id_rsa so man ssh-keygen helped, thanks.

0
0

In my case I had to create /home/ec2-user/.ssh/config file with 600 permission and

Host * 
  IgnoreUnknown UseKeychain
  AddKeysToAgent yes
  UseKeychain yes
  IdentityFile /home/ec2-user/.ssh/[my_private_key]

content to make ssh work.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .