You are not logged in.
I was reading over the SSH Wiki about automatically logging off all SSH users when the daemon exits, however the fix that is provided is depreciated. I was wondering if there is another way to gracefully logoff all connected SSH users when the server is restarted, shutdown, or the daemon exits. Currently if any of the fore-mentioned actions take place no message is sent to the client to produce a "Disconnected" error message. This basically makes the ssh client appear like something froze on the server side.
Thanks!
- Aaron
Last edited by artomason (2013-02-07 20:22:48)
Offline
This is a gap. If you use netcfg see, https://wiki.archlinux.org/index.php/Ne … d_via_sshd
CPU-optimized Linux-ck packages @ Repo-ck • AUR packages • Zsh and other configs
Offline
I don't suppose there is a way to do this without using netcfg?
Offline
Not to my knowledge. I actually asked about this either in these forums or in the bug tracker. The link above was the best solution at the time. It seems like the sshd.service should handle this to me...
CPU-optimized Linux-ck packages @ Repo-ck • AUR packages • Zsh and other configs
Offline
I think removing bash.bash_logout from /etc and .bash_logout from /home/$USER/ seemed to do the trick, but I'm not completely sure. Both of the files were empty but I did not keep a backup when I removed them, which I should have to test this fix. Can someone give this a try and see if it worked for them?
Offline
sshd.service cannot inform the client that it is shutting down:
it is being stopped when the network is already down, so it has no way to reach the client.
You must configure your network service (netcfg, NetworkManager, ... ) to stop sshd.service before bringing down the network.
Offline
The problem is that I'm not using netcfg or Network Manager. Once I removed the above mentioned, things started working as I originally intended them too. I'm sure in the case of using netcfg or Network Manager I would have to configure sshd to drop before deconfiguring the network interface. I think I might try to modify the sshd.service to do this but I'm going to have to play around with it to get it working. I don't suppose there is a way to make your network.service wait until all the other services that require it are shutdown first.
Offline
Dunno. Use netctl which seems to be the future anyway. It is currently in the AUR. Read the arch projects ML for more. I should add the netctl uses the same profiles as netcfg.
CPU-optimized Linux-ck packages @ Repo-ck • AUR packages • Zsh and other configs
Offline
Thanks for the info. I'm pretty new to arch. Debian pretty much just had one way to get things done.
Offline
Wel, the old behavior is back.
From my understanding of the problem at hand, systemd brings down the sshd.service and network.service, but the SSH connections are never killed. Instead the connection just hangs until the TCP timeout is reached in which case you will get a software connection error if you are using Putty. It would *NOT* be recommended to create a script within SSHD to kill all connections whenever the SSHD is stopped or restarted due to the fact that there are situations where you need to restart the daemon while logged in via SSH, without killing your own connection.
On the other hand it may be possible to create a script that is executed whenever the system is restarted or shutdown that would canvas the system for logged in SSH users and kill the connections, however I do not have the foggiest idea where to start or how to go about doing this, and that is if it is even possible via systemd or some other means.
Anyone have any other suggestions?
On a side note, there are quite a few bugs listed for this specific problem on different distributions, however no solutions were mentioned.
Offline
Found a fix for this type of behavior
edit /lib/systemd/system/systemd-user-sessions.service and append network.target to the after line.
[Unit]
Description = Permit User Sessions
Documentation = man:systemd-user-sessions.service(8)
After = network.target remote-fs.target
then symlink /lib/systemd/system/systemd-user-sessions.service to /etc/systemd/system/
Hope this helps someone else.
Last edited by artomason (2013-02-07 20:34:11)
Offline
@artomason - You should open a feature request against systemd if you feel this is a general solution.
CPU-optimized Linux-ck packages @ Repo-ck • AUR packages • Zsh and other configs
Offline
I don't have the link anymore, but from my understanding this is already in the works for the next upstream version.
Offline
I don't have the link anymore, but from my understanding this is already in the works for the next upstream version.
Would be great to confirm so that the wiki pages that teach the method I suggested above can be edited.
CPU-optimized Linux-ck packages @ Repo-ck • AUR packages • Zsh and other configs
Offline
Found a fix for this type of behavior
edit /lib/systemd/system/systemd-user-sessions.service and append network.target to the after line.
[Unit]
Description = Permit User Sessions
Documentation = man:systemd-user-sessions.service(8)
After = network.target remote-fs.targetthen symlink /lib/systemd/system/systemd-user-sessions.service to /etc/systemd/system/
Hope this helps someone else.
This was already rejected upstream: http://lists.freedesktop.org/archives/s … 06900.html
Arch Linux is more than just GNU/Linux -- it's an adventure
pkill -9 systemd
Offline