I want to use gnome-keyring in KDE to provide access to ssh passphrases. It is unlocked properly on login and the ssh agent socket is there. My problem is that the openSSH ssh-agent shadows this. Apparently the KDE session is started with ssh-agent

$ ps aux | grep ssh-agent
beaujean  2029  0.0  0.0  11140   316 ?        Ss   11:22   0:00 /usr/bin/ssh-agent /usr/bin/dbus-launch --exit-with-session /usr/bin/im-launch /usr/bin/startkde

Then in the kde session,


the ssh-agent is empty, and I'm prompted for my password. Incidentally, the gnome-keyring ssh socket is active, too

$ ss -xl | grep ssh
u_str  LISTEN     0      128    /run/user/1000/keyring/ssh 25108       * 0
u_str  LISTEN     0      128    /tmp/ssh-Jv2eneUNSlQ6/agent.3739 36471      * 0 

I can manually switch the socket

export SSH_AUTH_SOCK=`ss -xl | grep -o '/run/user/1000/keyring/ssh'`

and access to the ssh key w/o password works in this shell. How do I achieve this for the entire KDE session on startup? There are several questions around on how to achieve the opposite; i.e., prevent gnome-keyring from overwriting the ssh-agent. For me, it unfortunately doesn't overwrite SSH_AUTH_SOCK. Perhaps if I could avoid kde being started by ssh-agent, things would be fine but I don't know at what point of the start-up process this command

/usr/bin/ssh-agent /usr/bin/dbus-launch --exit-with-session /usr/bin/im-launch /usr/bin/startkde

is executed


I didn't really find a solution, others had the same question on the KDE forum but a simple workaround is to set the ssh agent in .profile

export SSH_AUTH_SOCK=`ss -xl | grep -o '/run/user/1000/keyring/ssh'`

this is not overwritten by the rest of the start-up procedures and at least sets it correctly in a (startup) shell. In the rest of window system, it's still the other ssh agent, unfortunately.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.