Skip to content(if available)orjump to list(if available)

Keeping SSH sessions alive with systemd-inhibit

zokier

I think this could be made into systemd (user) service fairly easily. Then you wouldn't need to worry about `disown` or tracking the PID, you'd just `systemctl --user start|stop prevent-sleep.service`

If you want to be extra fancy, you could even write small program that calls the dbus api directly and then just waits to be killed. Avoids the turducken of waiting processes.

blueflow

Of course systemd killing your SSH session is a intentional feature, not a bug.

Consider disabling suspend from the logind.conf and suspend, if at all, only at explicit user request.

jeroenhd

systemd doesn't kill your SSH session (if you'd WoL your PC there's a good chance you can continue typing unless your local terminal detects that the other end goes down).

It's more that when you configure systemd to suspend your computer when there is no physical activity, it will suspend your computer when there is no physical activity.

The author wants their computer to suspend automatically.

I think modifying your system configuration to never suspend is a much worse solution than using the tool designed to prevent suspending the computer while a specific program is running to prevent suspending the computer while that specific program is running.

It'd be easier if `sshd` would permit you to wrap the incoming command line/shells so `sshd` would spawn your session with systemd-inhibit, but I don't think that's possible?

blueflow

Unwarranted suspends by logind have always been a menace, i have been fighting them for a decade.

> It'd be easier if `sshd` would permit you to wrap the incoming command line/shells so `sshd` would spawn your session with systemd-inhibit, but I don't think that's possible?

sshd already links against systemd (by distro patches, not per upstream) but since SSH is a "legacy protocol" and its users are "uneducated troglodytes", this is not going to happen.

I think this is because OpenSSH is an OpenBSD project, and both systemd and OpenBSD refuse to support each other.

jon-wood

I think the author’s point was that this is usually desired behaviour because it’s a desktop and only occasionally do they want to stop that.

1970-01-01

Why not fix the keep alive time? Yes, there's no wrong way to do it, but IMHO the nix philosophy states you should at least try to stick your problem and your solution together.

https://www.golinuxcloud.com/keep-alive-ssh-sessions-in-linu...

https://en.wikipedia.org/wiki/Keepalive

null

[deleted]

1oooqooq

i think i used a laptop for a few hours in my life before I decided to simply disable all autosleep features.

computer is on, it's on. lid close, screen is off. done.