Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I remember that I used to be able to do ssh and have a prompt asks me for a password to unlock the keyring for the whole GNOME session so subsequent ssh wouldn't need to enter the keyring password any longer (not quite sure if this is in Ubuntu or other distro).

But nowadays doing ssh would ask me, in the terminal, my keyring password every single time; which defeats the purpose of using SSH keys.

I checked

$ cat /etc/pam.d/lightdm | grep keyring
auth    optional
session optional auto_start

which looks fine, and

$ pgrep keyring
1784 gnome-keyring-d

so the keyring daemon is alive.

I finally found that SSH_AUTH_SOCK variable (and GNOME_KEYRING_CONTROL and GPG_AGENT_INFO and GNOME_KEYRING_PID) are not being set properly. What is the proper way to set this variable and why aren't they being set in my environment (i.e. shouldn't they be set in default install)?

I guess I can set it in .bashrc, but then the variables would only be defined in bash session, while that is fine for ssh, I believe the other environment variables are necessary for GUI apps to use keyring.

share|improve this question
I have 2 12.04 installs, one has a similar problem, the other doesn't. In my case, the environment variables seem to be correct. Most sofware is the same on both, but not all. Anyone got any idea about how to ask ssh/gnome-keyring to log attempts to contact the keyring? – drevicko Oct 10 '12 at 2:08

I found this on the Arch wiki:

Basically, you run gnome-keyring-daemon -s to get your specific keyring value, then to your .bashrc, add:

SSH_AUTH_SOCK=`netstat -xl | grep -o '/run/user/yourusername/keyring-xxxxxxx.*/ssh$'`
[ -z "$SSH_AUTH_SOCK" ] || export SSH_AUTH_SOCK

This should make ssh ask you for your password through the keyring GUI.

share|improve this answer

I use ssh a lot, mostly between my Ubuntu workstation and another Ubuntu web server with all the websites I work on. I once came upon the same symptoms you are having, and it turned out to be something in the way I was running the terminal. I had created a custom shortcut to run gnome-terminal because I wanted to pass a certain command line. But I think I had the same problem running xterm.

When I ran the terminal from the built-in shortcut (Alt-Ctrl-T), or from the menu, it worked correctly and prompted me with a GUI dialog for the password, but when I ran it from my custom shortcut, it always asked from the terminal itself, and didn't remember it.

share|improve this answer
Yes. You nailed it. This is the problem for me as well. I wonder why though? – levesque Jul 8 '14 at 15:24
@levesque: Glad it helped. I never figured out why, but since I had a fix, and didn't really need the command line that much, I never really investigated. Now I barely remember the problem. :-) – Marty Fried Jul 8 '14 at 15:42

I had this problem too. Appeared suddenly. Apparently caused by a saved (maybe wrong) (SFTP) login password for the same domain.


Open Password and Keys (Gnome keyring) and delete the password (was beneath Ubuntu one)

Paasword and Keys window

Reboot and everything was fine.

export | grep SOCK

Now returned again: SSH_AUTH_SOCK=/run/user/yourusername/keyring-xxxxxxx.*/ssh

share|improve this answer

Your Answer


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.