On Mon, 12 Jan 2026, Tim Woodall wrote:
Is there a portable (not specific to how networking is configured) way of
detecting a network change and forcing ssh to close.
At work I have an ubuntu laptop, when at my desk I'm using wired connection,
when I go to a meeting it switches to wifi.
All my ssh sessions hang when this happens. Obviously, I can close them with
<cr>~. and then reconnect, but I'm wondering if there's a neat way to
automate the disconnect? Sometimes I'm waiting for a job to finish and the
terminal never updates because nothing tries to transmit. It might be hours
before I notice because I'm missing that flicker when something happens.
(I'm using screen to reestablish the session, that part is all working, it's
just the explicit disconnect I want to automate)
Thanks all, trying those ssh config settings now.
I can't use VPN from the in office network. While I can use VPN from the
guest wifi, I do see annoying latency spikes, much more so than WFH.
Mosh is something to think about if this doesn't work well. I don't
really care about having to reconnect, more that I don't realise a
window has "hung" and will never update.
I used to be on windows using cygwin and the connections dropped as soon
as I unplugged the laptop so I'm used to that.
Tim.