Live data from Hacker News

A Practical Guide to SSH Tunnels: Local and Remote Port Forwarding

labs.iximiuz.com

21–30 of 83 posts

Re: A Practical Guide to SSH Tunnels: Local and Remote Port Forwarding

#22
If you have many different remote devices behind NATs or firewalls, a cool trick to access them all via EC2 server (or such) is to setup Remote Forwarding via UNIX socket on the server side, to devices' port 22. Preferably, UNIX socket filenames should start with a common prefix, so an SSH config can be written that will use ssh+socat in a ProxyCommand to establish the connection.

It's amazing how lightweight this method actually is. I have managed to connect hundreds of devices using a single EC2 nano instance.

Re: A Practical Guide to SSH Tunnels: Local and Remote Port Forwarding

#23
post #2

It’s amazing what you can learn by reading the manual.

It is, because manuals are often not the best way to learn things. Most software manuals are reference manuals. SSH man page isn't too bad. I learned most of my SSH knowledge from it, but I'm not sure it's the best way to do it.

[deleted]

Re: A Practical Guide to SSH Tunnels: Local and Remote Port Forwarding

#24
post #6

There's a asymmetry here that "-R" works both for reverse static and dynamic (using SOCKS protocol) forwarding, but "-D" is required for dynamic forwarding which "-L" cannot do. Why is that?

It's historical. Some older flags could be easily extended for dynamic port support and others could not.

Re: A Practical Guide to SSH Tunnels: Local and Remote Port Forwarding

#26
post #21

I never pass up an opportunity to recommend the Cyber Plumber's Handbook: https://github.com/opsdisk/the_cyber_plumbers_handbook Goes over similar content as TFA, in perhaps a little more depth. Indispensable sysadmin knowledge.

Appreciate the mention wbadart!

Re: A Practical Guide to SSH Tunnels: Local and Remote Port Forwarding

#28
post #21

I never pass up an opportunity to recommend the Cyber Plumber's Handbook: https://github.com/opsdisk/the_cyber_plumbers_handbook Goes over similar content as TFA, in perhaps a little more depth. Indispensable sysadmin knowledge.

so good, I learn new things.

Re: A Practical Guide to SSH Tunnels: Local and Remote Port Forwarding

#29

I'll mention it here, because I learned about it here. "~C" will drop you into the SSH command line, allowing you to, among other things, effect port forwarding -L8080:localhost:443 Learning that "~C" exists, and what you can do with it, has supercharged my use of SSH tunnels, which were already awesome on their own. But for some reason this has been disabled by default in more recent ssh configurations... to ensure…

Important to note that `~` SSH commands work only right after you press Enter - it doesn’t trigger everywhere you press `~`. Also EnableEscapeCommandline fortunately only affects `~C` - the all-important `~.` to kill a hung SSH session still works with it disabled.

so many time i have inadvertently ended a session with a fat fingered ~.
Post reply on HN