Live data from Hacker News

Closing a stale SSH connection

davidisaksson.dev

31–40 of 91 posts

Re: Closing a stale SSH connection

#31
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.

It was AES-OCB last time I looked at it. Not sure if this is good/bad.

Re: Closing a stale SSH connection

#33

I feel old. I remember when we moved from telnet and rlogin to ssh and this was in the man page. I'm also happy to learn kids are still using terminals and ssh.

Well... terminal emulators. Bonus points to everyone who has an actual VT240 on their physical desktop.

Re: Closing a stale SSH connection

#34
One caveat here is the note:

> (Note that escapes are only recognized immediately after newline.)

This means that it is easy to pick up a habit to smash the enter-button a few times before doing this dance, and as noted on a nordic layout it can be a bit tricky and since you might seldom do it you might do it a few times.

Problem can be that sometimes the connection is only broken one way, what you are typing goes to the server but the responses don't. So you might end up wreaking some kind of havoc on the remote server when you just want to kill the session. Maybe you had a half-written command. Maybe you had just done an up-arrow to get to the previous command, maybe you redid that up-arrow one or more times before you realized that the connection was broken. If you press enter now you will re-run one of your previous commands. Could be quite scary.

To save you from some of that, you could do a ctrl+c which will clear your current line, before pressing enter. But whether that is a good idea depends on the context...

The most apparent issue this has been for me is if on the remote you have IRC or something and you type a bunch of garbage to whatever channel you are on. No biggie, but the old restart the terminal isn't too bad either.

Re: Closing a stale SSH connection

#36

I wish there is an easy way to have the reverse: a “sticky” ssh session. It’s so annoying that the connection is lost when going to sleep or network issues. And the solutions to fix this are not really worth the effort.

et survives reboots and IP roaming, pretty much anything: https://eternalterminal.dev/

Re: Closing a stale SSH connection

#38
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.)

And if you use host A like that enough you can also change the ssh escape key in your config.

Re: Closing a stale SSH connection

#39
Pretty sure the answer is no, cause I've been searching for a way to do this for a while, but is there any way to trigger these escapes from script?

Use case is bouncing through to an RDS that only allows access from specific EC2 instances. The RDS endpoint in question is highly specific to the EC2 - not a big deal to hit ~L and create the forward manually, but doing this automatically would be great.

Re: Closing a stale SSH connection

#40
post #5

If you enjoyed this article, you may also find other useful tips in a piece I submitted to HN a while ago on "advanced SSH usage": https://johannes.truschnigg.info/writing/2022-07_advanced_ss...

Loved your article, thank you for writing it !
Post reply on HN