Ubuntu – ssh-add command does not add the identity to ssh-agent

sshssh-agent

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?

Best Answer

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.