Live data from Hacker News

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

labs.iximiuz.com

61–70 of 83 posts

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

#61
post #29

Earlier quoted context omitted.

so many time i have inadvertently ended a session with a fat fingered ~.

Not ssh related but I regularly suspend my terminal with Ctrl-S by accident, usually when going for Ctrl-C/V. That was a nightmare to triage back in the late 90s when I did it. Thankfully Ctrl-Q (I think it’s Q) “resumes”, so, easy fix if you know what you’ve done.

Correct.

- software flow control user

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

#62

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…

Eh, once I started using master sockets, I never went back. Problem with ~C is it's hard to keep track of what you have open.

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

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

Not mentioning the ssh -w option in that book should be a crime.

Whoa that’s useful, learnt something new!

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

#66
The best part of this is you can daisy chain tunnels and have a network connection between any machines you can ssh into.

If you have a private server with a public IP, you don't need localtunnel etc.. you can just use ssh tunnels to expose your home network services over public IP.

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

#67

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 me…

I think the more modern ProxyJump rule is superior for this. Just let it manage the actual TCP forwarding for you automatically. It's just the normal "bastion host" concept. Particularly, you can use name patterns to apply the same rule broadly, assuming you have some systematic naming scheme for your eventual target devices.

How would you use ProxyJump with Reverse Forwarding?

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

#68

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 me…

Do you have more info on this method? How is the remote forwarding actually done?

There's an old blogpost I wrote at the time I came up with this method [0]. I think it contains most of the technical details.

Let me know if anything is confusing, I'll answer it here.

[0] https://paskozdilar.github.io/blog/entries/zero_code_ssh_jum...

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

#69

My favorite use of this is peer-to-peer transfer of Docker images. The Docker CLI only allows you to use registries authenticated with HTTPS but there's an exception where it allows HTTP transfers over localhost. So, if you use SSH tunneling to forward a port from localhost to a remote, then Docker unwittingly pushes to a remote. This is super useful "off the grid" with robotics/embedded applications where you don't…

This is what kamal does when you use localhost as registry [0] [1].

Pretty cool thing, I ship plenty of services to my tiny $5/mo vps with it without having to pay for a docker registry.

[0] https://kamal-deploy.org/docs/configuration/docker-registry/...

[1] https://github.com/basecamp/kamal/blob/eee0083b38661c3707c6b...

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

#70
post #39

Earlier quoted context omitted.

You might as well handover the images to hackers.

A tad hyperbolic for a LAN registry

Not really since all it takes is one person with misconfigured device and your LAN is now accessible from who-knows-where unless the LAN is under very strict lockdown.
Post reply on HN