5 ms·
Great write up! One thing to add is that you can even open tunnels during an interactive session without disconnection. To do this, type the escape command se
by fooblat 6y ago
Great write up!
One thing to add is that you can even open tunnels during an interactive session without disconnection.
To do this, type the escape command sequence ~C (will not show) and it will drop you to the control prompt. You can then add tunnels.
ssh>
ssh> -L 8000:localhost:9000
Forwarding port.
- macintux 6y agoI’ve been using ssh for 25+ years, I wrote a (in hindsight, pretty awful) article about it for Linux Journal, and I never knew this.
- nerdponx 6y agoIs ~ a literal ~ character? Or notation for some modifier key? I only knew about ^ to mean "control".
- comradesmith 6y agoLiteral ~. Its input as a sequencenot as a modifier. Iirc the sequence ~h or ~? prints a little help page
- rzzzt 6y agoWarning, if you read comradesmith's comment even more literally and type "~." (tilde and period) in an SSH session, that will close the connection and exit the client. It is useful when a remote application hangs and does not let you exit gracefully: https://apple.stackexchange.com/questions/35524/what-can-i-do-when-my-ssh-session-is-stuck#35543 https://apple.stackexchange.com/questions/35524/what-can-i-d...
- jtvjan 6y agoYes, but you need to press enter before using it. Try typing `⏎~?' in an SSH session.
- xvf22 6y agoWell, there's something I didn't know. Thank you for the time and tab savings!
- fooblat 6y agoSince this tip is popular I'll share another related tip. When using nested ssh session, you can send escape commands to any of them by the number of tildes. For example, if you ssh into Server A and then from Server A to Server B: ~~. # drop session from Server A to Server B ~. # drop original session into Server A
- stjohnswarts 6y agoI sometimes have to hit a <return> before the ~. disconnect works. Not sure why.
- BenjiWiebe 6y agoBecause iirc, ssh only interprets the tilde if it's immediately preceded by a newline.