Is there a portable (not specific to how networking is configured) way of detecting a network change and forcing ssh to close.What I do is to set a ServerAliveInterval in my ssh sessions.
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)
What I do is to set a ServerAliveInterval in my ssh sessions.
On 2026-01-12, tomas@tuxteam.de wrote:Ah, interesting. If OP wants to know about the disconnect "as early
What I do is to set a ServerAliveInterval in my ssh sessions.
I set it in .ssh/config with 2 other parameters
TCPKeepAlive yes
ServerAliveInterval 30
ServerAliveCountMax 360
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.
Is there a portable (not specific to how networking is configured) wayMosh (https://mosh.org/#techinfo or `apt info mosh`)
of detecting a network change and forcing ssh to close.
On 12 Jan 2026, at 11:07, Tim Woodall wrote:Mosh is one of the things I always wanted to try. The idea sounds
Is there a portable (not specific to how networking is configured) way
of detecting a network change and forcing ssh to close.
Mosh (https://mosh.org/#techinfo or `apt info mosh`)
carries persistent sessions over UDP, so that the sessions
don't hang whenever the client address changes.
I think it might meet your need.
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)
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.
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
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)
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.
| Sysop: | Jacob Catayoc |
|---|---|
| Location: | Pasay City, Metro Manila, Philippines |
| Users: | 5 |
| Nodes: | 4 (0 / 4) |
| Uptime: | 19:03:21 |
| Calls: | 117 |
| Calls today: | 117 |
| Files: | 367 |
| D/L today: |
540 files (253M bytes) |
| Messages: | 70,845 |
| Posted today: | 26 |