I want to use the real ssh-agent instead of gnome-keyring in xubuntu. I followed the steps from http://dtek.net/blog/how-stop-gnome-keyring-clobbering-opensshs-ssh-agent-ubuntu-1204, but gnome keyring still registers itself as ssh-agent. I still want to keep using gnome-keyring for other passwords
It turns out that if gnome compatibility is turned on in xfce, xfce4-session will unconditionally start gnome-keyring-daemon. This is hardcoded, there is at the moment no way to configure this. Disabling the gnome compatibility mode results in keyring not starting on login and you will need to provide your password again if you start it.
The simplest solution seems to be to intercept the call to gnome-keyring-daemon, and insert a script that will insert the
--components
flag into the arguments to prevent gnome keyring from replacing ssh-add.Run the following to move gnome-keyring-daemon:
create a new gnome-keyring-daemon with
and insert the following content:
Make the new gnome-keyring-daemon executable with
sudo chmod +x /usr/bin/gnome-keyring-daemon
.Now gnome keyring will no longer try to replace ssh-add.
Note that upgrading your system will reinstate the default gnome-keyring-daemon, so you will probably need to execute the above steps again after upgrading.
edit:
In xubuntu 14.10 startup works slightly different in that g-k-d is also started from the session upstart. It is possible to override the upstart configuration so it won't start the ssh component, but even so g-k-d will start its ssh component when xfce4-session also tries to start it. So if you want to have xfce also automatically start gnome services you will still need the above hack. An alternative is to disable gnome services (Setings -> Session and Startup -> advanced -> Launch GNOME services on startup), configure upstart to start g-k-d with the
--components=pkcs11,secrets,gpg
flag, and optionally also configure the gnome services you do want to start manually.(Apart from the two places that launch g-k-d mentioned above, the g-k-daemon is also started before that from lightdm/PAM in order to receive the user's login password. But that launch does not fully configure g-k-d and it still expects to be fully configured by a second attempt to start it, so that start attempt is not relevant to the current problem.)
It's an old thread but my workaround for this problem on Xubuntu 14.04 is simple by just respawning
gnome-keyring-daemon
on Session and Startup. What you need to do is simply running command below:We remove "ssh" from the component of Gnome keyring.
gnome-keyring-daemon --replace --daemonize --components=pkcs11,secrets,gpg
Try to log out your XFCE session and log in back. To make sure Gnome keyring does not manage ssh anymore just run.
If you got that message means Gnome keyring is not manage your SSH and you're free to use the original OpenSSH ssh-agent implementation.
To build on the answer by @JanKanis, I traced it down to xfce4-session being the culprit for initiating the gnome-keyring-daemon --start command.
When run that way gnome-keyring-daemon does not check for SSH_AUTH_SOCK already being set, which is a "feature", since you then can have both ssh-agent and gnome-keyring-daemon providing a socket.
First things first:
Add
~/.config/upstart/gnome-keyring.conf
:Now replace gnome-keyring-daemon with a wrapper (I moved the original to /usr/libexec/):
The debug code is there for you to figure out why it stopped working. Since none of these programs have sane configuration methods, there is just no way around hacking commands. In this case, I can't find any documented configuration method for xfce4-session to not envoke gnome-keyring-daemon --start, that has no other side-effects. They all make ass-sumptions about things being installed and thus go ahead read the user's mind.
I've just encountered this problem on Xubuntu 16.04, and I too wanted both
ssh-agent
andgpg-agent
working.Firstly, I didn't care about gnome-keyring, so I removed all related packages. eg.
At this point
ssh-agent
andgpg-agent
were both running successfully, but gpg could not connect togpg-agent
due to$GPG_AGENT_INFO
not being set. That's really weird because if we look in/etc/X11/Xsession.d/90gpg-agent
it's clearly getting set initially. Something must be un-setting it.To help find the culprit I created a custom session file:
I then created a custom
${HOME}/.xsession
file and made it executable, with something like the following:I logged out, restart lightdm and logged in again (with the "Xsession" session selected), and inspected
${HOME}/GPG_AGENT_INFO
. Sure enough, the environment variable was still set. So it was something silly Xfce4 was doing.Poking around, I eventually stumbled upon this:
Seems
xfce4-session
is probably un-setting the variable when it tries to launchgnome-keyring-daemon
, so the solution requires two steps. First, go toApplications -> Settings -> Session and Startup -> Advanced
and tickLaunch GNOME services on startup
. Next, create an executable file calledgnome-keyring-daemon
somewhere in your$PATH
with the following contents:Log out and in once more, and you should be sorted. You should also now be able to delete
/usr/share/xsessions/xsession.desktop
and${HOME}/.xsession
if you created those too, as they were just for debugging.Here's a less invasive version of the script JanKanis posted. It accepts whatever components were passed to it, but yanks out the SSH component.