Why isn't my keyring in Ubuntu working?

I have encrypted my id_rsa with a password. I think Ubuntu has a keyring system which prevents me from inputting password every time I have to use id_rsa, like git push. Sometimes I don't need to type in the password, sometimes I do.

When I execute

$ ssh-add -l
Could not open a connection to your authentication agent.

$ gnome-keyring import ~/.ssh/id_rsa
WARNING: gnome-keyring:: couldn't connect to: /run/user/1000/keyring-wUoO5j/pkcs11: Connection refused
p11-kit: gnome-keyring: module failed to initialize, skipping: An error occurred on the device
gnome-keyring: couldn't find any place to import files

$ echo $SSH_AUTH_SOCK 
/run/user/1000/keyring-wUoO5j/ssh
$ echo $SSH_AGENT_PID
<empty>

In seahorse, the key is listed in openssh keys

Does any body has the same problem? Or how to solve this?


Solution 1:

I recently had a similar issue (I'm using ElementaryOS), where I had to enter my key's password every time I used it in the terminal. It used to ask me for the password via the GUI and kept that in memory for a while, but this somehow stopped working.

I tried many of the suggestions found by Googling this (eg. adjust deamon config via gconf-settings, checked startup applications, add to .bashrc, install keychain, ..) but to no avail.

I did find this article on Cup of Linux which suggested checking the pam.d settings in /etc/pam.d/. Since my configuration was definitely different as in the article, I search for pam_gnome_keyring and commented all occurences in all files of the lines

auth    optional        pam_gnome_keyring.so
session optional        pam_gnome_keyring.so auto_start

After a reboot / relogin, I was finally asked by the GUI again for the password..

grep before changes:

:~$ grep -r pam_gnome_keyring /etc/pam.d/
/etc/pam.d/common-password:password optional    pam_gnome_keyring.so
/etc/pam.d/lightdm-greeter:auth    optional        pam_gnome_keyring.so
/etc/pam.d/lightdm-greeter:session optional        pam_gnome_keyring.so auto_start
/etc/pam.d/lightdm:auth    optional        pam_gnome_keyring.so
/etc/pam.d/lightdm:session optional        pam_gnome_keyring.so auto_start

grep after changes (note the # in the last 4 lines):

:~$ grep -r pam_gnome_keyring /etc/pam.d/
/etc/pam.d/common-password:password optional    pam_gnome_keyring.so
/etc/pam.d/lightdm-greeter:#auth    optional        pam_gnome_keyring.so
/etc/pam.d/lightdm-greeter:#session optional        pam_gnome_keyring.so auto_start
/etc/pam.d/lightdm:#auth    optional        pam_gnome_keyring.so
/etc/pam.d/lightdm:#session optional        pam_gnome_keyring.so auto_start