Live data from Hacker News

Closing a stale SSH connection

davidisaksson.dev

41–50 of 91 posts

Re: Closing a stale SSH connection

#41

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.

I suspect many linux users nowadays don't even know that manpages exist or don't want to use them. Otherwise blogposts like this would not exist.

Re: Closing a stale SSH connection

#42

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.

Maybe take a look at expect:

https://linux.die.net/man/1/expect

Re: Closing a stale SSH connection

#43

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.

I suspect many linux users nowadays don't even know that manpages exist or don't want to use them. Otherwise blogposts like this would not exist.

They know the man pages exist and they want to use them, but most are written to merely be consistent in format and not necessarily in content. The worst thing to omit is examples.

What users do nowadays is rely on alternatives such as https://tldr.inbrowser.app/

Re: Closing a stale SSH connection

#44
post #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…

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 typing out the tilde.

Re: Closing a stale SSH connection

#45

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.

Can you not use SSH proxyjump?

https://www.redhat.com/sysadmin/ssh-proxy-bastion-proxyjump

Re: Closing a stale SSH connection

#46
post #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…

[deleted]

Re: Closing a stale SSH connection

#47
post #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…

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?

Re: Closing a stale SSH connection

#48

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.

I’ve been around Unixes since the early 90s and was around for the transition away from telnet and I only learned about this about 5 years ago. Shoulda read the whole man page, I guess.

Re: Closing a stale SSH connection

#50

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.

> 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)

Post reply on HN