Live data from Hacker News

Closing a stale SSH connection

davidisaksson.dev

21–30 of 91 posts

Re: Closing a stale SSH connection

#21

Adding 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

Alpine Linux user here, i could not reproduce that. How does the used shell even matter for that? The ssh client talks to the tty directly, not via shell.

This thread [1] explains the issue people run into. I ran into it and thus found that explanation. Verified I can still reproduce it on Alpine 3.17.3 up to date on patches

For clarification regarding what I mean with menu and output will not display the disconnect command will still work but there will be no feedback. So disconnecting will work but one won't get the menu or feedback on changing verbosity or dropping to a command line or displaying forwarded connections, etc... and a few of the sub-commands will not work.

[1] - https://superuser.com/questions/985437/ssh-escape-key-only-w...

Re: Closing a stale SSH connection

#25
post #4

One 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/

You can turn on TCP keeyalive on ssh using a handful of -o flags if that's the behavior you prefer.

https://news.ycombinator.com/item?id=5017108

Re: Closing a stale SSH connection

#26

Why is this better than CTRL-C?

It's client-side, so works even if the remote system is totally hung and did not clearly disconnect.

For example, running `systemctl suspend` will not terminate active SSH connections before putting the destination machine into a sleep state, and thus Ctrl+C (which isn't processed by SSH) will do nothing until the remote host is woken up by some mechanism.

Re: Closing a stale SSH connection

#28
post #15

Earlier quoted context omitted.

The main thing about Mosh is you need both on the sever and the client. Installing on random servers you might be ssh -in only once feels gross.

Has Mosh crypto been reviewed? Last I checked they were using some custom crypto on top of UDP instead of using something like DTLS or QUIC. Given SSH is one of the most battle tested protocols out there I am wary of replacing it with something else.

https://mosh.org/#faq:~:text=Q%3A%20What%20is%20Mosh%27s%20s...

The cryptography is standard AES-128 in OCB3 mode. It's been around long enough, and has had enough security scrutiny to at least discover a few minor DoS vulnerabilities, that it isn't entirely unreviewed.

For the cipher itself, see https://en.wikipedia.org/wiki/OCB_mode#Attacks

Re: Closing a stale SSH connection

#29
post #6

Pro tip: if you used ssh to get into host A and then another ssh to get from host A into host B, to break the A-B connection you need to issue `~~.` ("control up-arrow Q" song playing in the background.)

Alternatively just use jump hosts: $(ssh -J bastion target)
Post reply on HN