Live data from Hacker News

Closing a stale SSH connection

davidisaksson.dev

61–70 of 91 posts

Re: Closing a stale SSH connection

#62
post #55
post #37

Another good tip; when randomly generating passwords (especially for other users), filter out anything starting with a tilde to prevent strange behavior.

Your new password is: +++ATH0

This doesn't work.

The Hayes modem protocol specifies that a significant pause must be inserted after "+++" for it to have signaling effect.

https://en.wikipedia.org/wiki/Hayes_AT_command_set#Hayes'_so...

Re: Closing a stale SSH connection

#63
post #55

Earlier quoted context omitted.

Your new password is: +++ATH0

This doesn't work. The Hayes modem protocol specifies that a significant pause must be inserted after "+++" for it to have signaling effect. https://en.wikipedia.org/wiki/Hayes_AT_command_set#Hayes'_so...

... that link describes why it does sometimes work

Re: Closing a stale SSH connection

#64

Earlier quoted context omitted.

Another note for nordic layouts and Linux: tilde (~) is considered to be a "dead key" on most nordic layouts, meaning you may need to follow AltGr + ~ with a space before typing out the dot. Otherwise you might get weird looks from the terminal trying to figure what you meant with the tilde-dot. Incidentally, while testing on Windows (in both WSL and cmd.exe) with a Finnish layout: you do not need a space after typin…

~ is also the (very common) shorthand for home directory. How do Nordic keyboard users deal with that?

Maybe I'm misunderstanding, but it's not an issue on a Mac. The Option + ^ will produce a ~ with no need for a space. I don't recall it ever being an issue for me on Linux either, so I wonder if there's a difference between a Nordic and a purely Danish keyboard.

Personally I always found that ^] for various terminal commands was much more of a hassle, to the point where it's easier to just close the terminal window.

Some Danes will just use a US keyboard layout, but that's not really as common as sites like HN will have you believe. In terms of programming it does make a little sense though. The 8 and 9 key is doing a lot of heavy lifting, Shift + 8 is (, Option + 8 is [ and Shift + Option + 8 is { and the matching close characters on 9.

There's not a lot of room for special characters on a Nordic keyboard, all most all of the require a modifier key. I don't know if that makes Nordic keyboard users more adverse to the use of these characters in commands and programming languages.

Re: Closing a stale SSH connection

#65

Earlier quoted context omitted.

Another note for nordic layouts and Linux: tilde (~) is considered to be a "dead key" on most nordic layouts, meaning you may need to follow AltGr + ~ with a space before typing out the dot. Otherwise you might get weird looks from the terminal trying to figure what you meant with the tilde-dot. Incidentally, while testing on Windows (in both WSL and cmd.exe) with a Finnish layout: you do not need a space after typin…

~ is also the (very common) shorthand for home directory. How do Nordic keyboard users deal with that?

${HOME}

Re: Closing a stale SSH connection

#66
post #58

Earlier quoted context omitted.

> Bonus points to everyone who has an actual VT240 on their physical desktop. Bonus points to anyone who can find one and get it to work. I want one, but it's a huge investment (both in price and effort)

The MAME emulator will actually run a VT260 rom, allowing the emulated serial port to be output to a socket.

Are guides available on how to setup and use?

Edit: Found this https://zork.net/~st/jottings/Real-VT102-emulation-with-MAME...

Re: Closing a stale SSH connection

#67

Earlier quoted context omitted.

Can you not use SSH proxyjump? https://www.redhat.com/sysadmin/ssh-proxy-bastion-proxyjump

Yup. Though doesn't help much for my use case (I don't think) - I have an ever change set of ec2's, each with access to a single RDS endpoint. Most debug/config is done via sqlcl which is straight forward as that's run from the ec2 and so has access to the DB, but sometimes I need to fall back to eg TOAD or sqldeveloper which require the forward to be setup - either adhoc via ~L or -L or via .ssh/config Each ec2 know…

ssh only looks for those escape sequences on the input side / on the controlling pty.

I think you would have to do something like have the script on the remote ec2 instance emit some pattern that you configure your local terminal emulator to watch for and then somehow tell your terminal to emit the ~L sequence of keystrokes.

iterm2 can do this kind of thing, see https://iterm2.com/triggers.html .

Re: Closing a stale SSH connection

#68
post #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)

Oh, I didn't know about the -J option. At $WORK, after ssh-ing onto the jump host, we've to do 'sudo -u special_user sudosh' (no password) before we ssh further. I don't suppose there's any way around that, is there?

Re: Closing a stale SSH connection

#69

Earlier quoted context omitted.

~ is also the (very common) shorthand for home directory. How do Nordic keyboard users deal with that?

Maybe I'm misunderstanding, but it's not an issue on a Mac. The Option + ^ will produce a ~ with no need for a space. I don't recall it ever being an issue for me on Linux either, so I wonder if there's a difference between a Nordic and a purely Danish keyboard. Personally I always found that ^] for various terminal commands was much more of a hassle, to the point where it's easier to just close the terminal window.…

“Personally I always found that ^] for various terminal commands was much more of a hassle (…)”

Yeah, tell me ’bout it. Back when I used Windows at work, a friend told me that instead of Ctrl ] one should press Ctrl ¨ – because on a regular Swedish keyboard, ¨ is on the same location that has ] on a US keyboard. (Not sure if this works with Linux/Mac, never tried there.)

Re: Closing a stale SSH connection

#70

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.

WireGuard[1] might help here, at least with network issues. It's literally designed to be able to keep a connection even when moving to one network to another ("roaming").

And as a side-benefit, if your SSH daemon only listens on the WireGuard interface, that's another layer of defense you get for free (not to mention you'll stop getting noise in your logs).

Ironically though, here you actually need to know about `~.` because if the remote host actually goes down, WG will keep trying to contact the remote peer for some time; this is the same behavior that allows you to keep a connection open even when roaming, but seen from the other side.

[1]: https://www.wireguard.com/

Post reply on HN