Closing a stale SSH connection
davidisaksson.dev
Closing a stale SSH connection
1–10 of 91 posts
Re: Closing a stale SSH connection
#2Re: Closing a stale SSH connection
#3Re: Closing a stale SSH connection
#4[0]: https://mosh.org/
Re: Closing a stale SSH connection
#5Re: Closing a stale SSH connection
#6("control up-arrow Q" song playing in the background.)
Re: Closing a stale SSH connection
#7One of the most useful SSH tricks I've ever learned. I wonder if there's a way to detect a stale session and force reconnect when I turn on the computer? Like mosh[0], but with SSH. [0]: https://mosh.org/
SSH uses TCP and if the session is gone it will be an invalid session in iptables/nftables and likely have timed out on the remote end depending on state table timeouts and how long your laptop were offline. If there were no firewall in the path then one could play with long SO_KEEPALIVE sessions which I have done in the past when rebooting datacenter-wide diskless NFS clients and NAS's but I dont believe this will work with SSH due to session keys. As you alluded to, Mosh is the best current way to deal with broken or roaming sessions as Mosh uses a nonce and is designed to be stateless.
If the sshd and ssh client timeouts are high enough, a UDP VPN can at times work around intermittent timeouts.
Re: Closing a stale SSH connection
#8Adding for completeness sake, if using Alpine Linux the ssh escape sequence menu and output will not display correctly if using /bin/ash from BusyBox as your login shell. One work-around is to type 'cat [Return]' and then use the escape sequences, or to carefully change your shell to /bin/bash
Re: Closing a stale SSH connection
#9Re: Closing a stale SSH connection
#10Adding for completeness sake, if using Alpine Linux the ssh escape sequence menu and output will not display correctly if using /bin/ash from BusyBox as your login shell. One work-around is to type 'cat [Return]' and then use the escape sequences, or to carefully change your shell to /bin/bash