Live data from Hacker News

A visual guide to SSH tunnels

robotmoon.com

41–50 of 82 posts

Re: A visual guide to SSH tunnels

#43
post #12
post #11

SSH tunnels are my favorite tool for NAT-busting. I always have to look up the cryptic syntax, but with one strategically placed Raspberry Pi, you can basically get from anywhere to anywhere. And it works just as well on a locked down corporate network as it does on a home network. Why people put up with garbage VPN software is beyond me.

SSH isn’t a replacement for VPNs. I’d argue that they complement each other. For example, SSH port forwarding is TCP only, so if you need UDP, you‘ll need a VPN.

Actually, OpenSSH has built-in TUN/TAP support using -w:. You can create a layer 3/point-to-point/ TUN tunnel or layer 2/ethernet/TAP tunnel.

I used to run a site-to-site VPN between two sites a couple of decades ago with a simple script doing just this. These days we'd use OpenVPN or strongSwan for such use-cases but despite the 'hackiness' of the former approach, it worked reliably for years.

Re: A visual guide to SSH tunnels

#44
post #26

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.

Is ~ a literal ~ character? Or notation for some modifier key? I only knew about ^ to mean "control".

Re: A visual guide to SSH tunnels

#45
post #26

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.

Well, there's something I didn't know. Thank you for the time and tab savings!

Re: A visual guide to SSH tunnels

#47
Nice reference.

Reaching target hosts multiple jump-hosts away, and going the wrong way through multiple firewalls segregating those lans, is another use-case of tunnels I've found handy.

i.e.

your_remote_client_host->internet->fw1->lan1->fw2->lan2->fw3->target_host

Target_host can be reached by doing tunnel-in-tunnel-in-tunnel-in-tunnel. Each tunnel gets you past one firewall. The final tunnel you can just ssh to fw3 via a local tunnel and a local port on your_remote_client now takes you straight to target_host.

Re: A visual guide to SSH tunnels

#48
post #26

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.

Is ~ a literal ~ character? Or notation for some modifier key? I only knew about ^ to mean "control".

Literal ~. Its input as a sequencenot as a modifier. Iirc the sequence ~h or ~? prints a little help page

Re: A visual guide to SSH tunnels

#49

This[1] is probably the best, easiest and most (visually) effective way to learn about SSH tunnels. [1] : https://unix.stackexchange.com/a/118650/289353

This is the one I always come back to when I'm a bit confused about the ordering of ips and ports.

Re: A visual guide to SSH tunnels

#50
post #26

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.

Is ~ a literal ~ character? Or notation for some modifier key? I only knew about ^ to mean "control".

Yes, but you need to press enter before using it. Try typing `⏎~?' in an SSH session.
Post reply on HN