LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   ssh-agent on -current: starts at Xfce login, never exits (https://www.linuxquestions.org/questions/slackware-14/ssh-agent-on-current-starts-at-xfce-login-never-exits-4175686847/)

ljb643 12-14-2020 05:31 PM

ssh-agent on -current: starts at Xfce login, never exits
 
Using Slackware64-current with recent updates, Xfce-4.14, login via xdm into xfce4 session, no KDE.

Every time I log in, ssh-agent starts. It does not stop when I log out. The number of ssh-agents currently running, as well as the number of /tmp/ssh-* directories, equals the number of times I have logged in since boot-up.

It looks like xfce4-session starts these up, but they are not exiting at logout like they should, for some reason.

I found that I can disable ssh-agent startup at login with this:

Code:

$ xfconf-query --channel xfce4-session --property /startup/ssh-agent/enabled --create --type bool --set false
Or re-enable it with this:
Code:

$ xfconf-query --channel xfce4-session --property /startup/ssh-agent/enabled --reset
I disabled it, since I don't seem to need it. But does anyone know why it isn't stopping at logout?

mumahendras3 12-17-2020 08:55 AM

Yep, I tried launching Xfce using startx and then logging out. The ssh-agent is not stopped here too. Maybe it's a normal behaviour? Since the ssh-agent is reparented to PID 1 (init) so the main Xfce process doesn't know its PID to be able to stop it properly at logout.

Interestingly, running
Code:

echo $SSH_AGENT_PID
in the terminal emulator inside Xfce prints out the PID of the started ssh-agent, which means that environment variable is already set and accessible by processes started by the user. I don't know why the main Xfce process doesn't use that environment variable to kill the started ssh-agent when the user logs out.

Probably not really helpful, just giving my thoughts.

ljb643 12-17-2020 06:57 PM

Thanks for your reply and checking on it. I did take a look at the xfce4-session source code, and found that there is a function for shutting down the session that kills off ssh-agent. But as far as I can tell it never gets called. I put some tracing print calls in there, and they never appeared; I searched the source code and found no place that calls it (xfsm_startup_shutdown()). The next step would be to open a bug on the xfce4-session tracker... I'm thinking about it.

As far as I understand, $SSH_AGENT_PID allows processes in your login session to communicate with the ssh-agent. Once you log out, the still-running ssh-agent is probably inaccessible because no process still has its PID in $SSH_AGENT_PID. Which makes the extra ones useless.

mumahendras3 12-17-2020 10:23 PM

Quote:

Originally Posted by ljb643 (Post 6196806)
As far as I understand, $SSH_AGENT_PID allows processes in your login session to communicate with the ssh-agent. Once you log out, the still-running ssh-agent is probably inaccessible because no process still has its PID in $SSH_AGENT_PID. Which makes the extra ones useless.

I think that should be $SSH_AUTH_SOCK, the path to the running ssh-agent's socket file. In KDE Plasma, I usually use $SSH_AGENT_PID to kill ssh-agent when logging out by putting "kill $SSH_AGENT_PID" in a shutdown script and put that script in $XDG_CONFIG_HOME/plasma-workspace/shutdown. Although after I was able to emulate systemd's user-level services functionality that start/stop user's services at user's login/logout using s6 + s6-rc together with elogind DBus interface, I just added ssh-agent to the list of services that should be started when I login and then deleted that shutdown script since it's not needed any more :D.


All times are GMT -5. The time now is 11:56 PM.