4 ms·
This approach works very well. I've had dozens of extremely remote systems hooked up this way for about 8 years. The only problem I've seen is that occasionally
by 8xeh 2y ago
This approach works very well. I've had dozens of extremely remote systems hooked up this way for about 8 years. The only problem I've seen is that occasionally the server ssh process will get stuck, so you have to log in to the server and kill it. It seems to happen when a remote goes offline and reconnects without closing the old connection first.
If I were doing it now, I'd probably use wireguard, probably. This is simpler to set up and works great.
- elashri 2y agoCan't you just add something like ServerAliveCountMaxto help with solving stale connections? So something like that would solve that [Unit] Description=look ma, no autossh After=network.target [Service] Type=exec ExecStart=/usr/bin/ssh -o ServerAliveInterval=60 -o ServerAliveCountMax=3 -o ExitOnForwardFailure=yes -Nn -R 7070:localhost:22 pc 'sleep 20m' Restart=always RestartSec=20 RuntimeMaxSec=30m [Install] WantedBy=default.target
- xk3 2y agoThe default of ServerAliveCountMax is already 3
- xk3 2y ago> ssh process stuck systemd's RuntimeMaxSec should help in this case but I've never had trouble with sshd personally To add more context I use the above service to ssh from my phone to my laptop via my desktop PC. The service runs on my laptop and binds port 22 of my laptop to port 7070 of my PC but wiregaurd would probably work similarly
- lloeki 2y agoRuntimeMaxSec would have systemd kill a live forwarded connection though?
- xk3 2y agoclosing ssh doesn't close the ports if they are being used, at least with ControlMaster. You need to run something like this to force the ssh daemon to close the port ssh -O cancel -L 4102:localhost:4000 pc but if ControlMaster is stuck maybe autossh is better in that case, or use this: Host * ServerAliveInterval 11
- boris 2y ago> The only problem I've seen is that occasionally the server ssh process will get stuck, so you have to log in to the server and kill it. You also need ClientAliveInterval on the server side (in addition to ServerAliveInterval on the client). In other words, both the client and the server need to be configured to monitor the connection. With this setup I had no issues with reconnections.