TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

SSH Tunneling Explained

363 pointsby twakefieldover 3 years ago

15 comments

opsdiskover 3 years ago
If you&#x27;re looking at going even deeper into SSH tunneling and port redirection, I recently made The Cyber Plumber&#x27;s Handbook free: <a href="https:&#x2F;&#x2F;github.com&#x2F;opsdisk&#x2F;the_cyber_plumbers_handbook" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;opsdisk&#x2F;the_cyber_plumbers_handbook</a><p>I made it free to the HN community a few years back [1]. There is a paid interactive lab portion (details in the repo) if you are looking for hands-on experience.<p>Book Overview<p>This book is packed with practical and real world examples of SSH tunneling and port redirection in multiple realistic scenarios. It walks you through the basics of SSH tunneling (both local and remote port forwards), SOCKS proxies, port redirection, and how to utilize them with other tools like proxychains, nmap, Metasploit, and web browsers.<p>Advanced topics included SSHing through 4 jump boxes, throwing exploits through SSH tunnels, scanning assets using proxychains and Metasploit&#x27;s Meterpreter, browsing the Internet through a SOCKS proxy, utilizing proxychains and nmap to scan targets, and leveraging Metasploit&#x27;s Meterpreter portfwd command.<p>[1] <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=19946941" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=19946941</a>
评论 #28829517 未加载
评论 #28819897 未加载
adrianmonkover 3 years ago
You can also change&#x2F;add them after the ssh session has started.<p>This uses the escape mechanism. For help on that, hit return, type &quot;~?&quot; and hit return again.<p>From there you will see that &quot;~#&quot; will list them. And &quot;~C&quot; takes you to a line-oriented command prompt where you can add them.<p>For example, type return &quot;~C&quot;, then at the prompt type &quot;-L1234:localhost:22&quot;. Then in another window, type &quot;telnet localhost 1234&quot;. Then back in the ssh window, type return &quot;~#&quot; and you will see the tunnel being used.<p>Another trick: if you don&#x27;t need a shell and only want to forward ports, run &quot;ssh -N&quot; instead of &quot;ssh&quot;.
评论 #28821372 未加载
评论 #28822542 未加载
wadkarover 3 years ago
I have read far too many ssh tunneling articles and all of them either forget about the bind address or just pretend that the only host that can be tunneled is localhost.<p>The fact is that ssh tunnels are bound to an interface on one side and the other can be any (reachable) host:port. So if example.com:1234 isn’t reachable from your host network, you can do a local port forward to example.com:1234 from an intermediary host that can reach example.com:1234
gnufxover 3 years ago
<a href="https:&#x2F;&#x2F;sshuttle.readthedocs.io&#x2F;" rel="nofollow">https:&#x2F;&#x2F;sshuttle.readthedocs.io&#x2F;</a> seems worth mentioning for convenient VPN-like tunnelling.
a-dubover 3 years ago
never knew ssh did tun&#x2F;tap. live and learn.<p>my personal preference has been to use ssh -D and tsocks for this. it doesn&#x27;t require root on either side and tsocks is elegant for inbueing just the processes you want with the ability to use the tunnel.
评论 #28817844 未加载
Y_Yover 3 years ago
I wanted to build a TeamViewer-type system using reverse tunnels so that I could access my possibly NAT&#x27;d or dynamic IP machines from each other in a simple way. The typical use would be SSH control, copying files each way, VNC. I came up with something where each machine connects to a an always-on server with a domain name, and offers a reverse tunnel I can use to SSH down, but it occurs to me that there might be a better way, or even a tool someone has already build. Does anyone know of something like this?<p>(pwnat is pretty cool, but I don&#x27;t think it does quite what I&#x27;m looking for)
评论 #28816763 未加载
评论 #28819381 未加载
评论 #28816800 未加载
评论 #28817436 未加载
评论 #28820446 未加载
评论 #28817026 未加载
评论 #28816728 未加载
评论 #28816920 未加载
评论 #28822670 未加载
评论 #28820328 未加载
评论 #28816743 未加载
评论 #28816966 未加载
sloshnmoshover 3 years ago
Excellent article!<p>What’s also very interesting is that the article links to page from TrendMicro about malicious Android apps using Java’s version of SSH to infiltrate internal corporate networks.<p>TrendMicro’s own Android app ALSO contained the same Java SSH sdk.
grifballover 3 years ago
For most use cases, you should also add a local bind, &quot;-Llocalhost:5900:localhost:5900&quot; or else everyone at the coffee shop will be able to access your insecure Vnc server
评论 #28820729 未加载
reacharavindhover 3 years ago
At work, we have a handful of VPCs that we all work with. At the moment, we have a bastion host in every VPC. When something needs attention while on call, the engineer needs to first figure out which bastion host to ash into and then the actual work starts.<p>I was wondering if there is a better way to setup a central bastion host with RBAC such that the attack vector is also not centralised. Does anyone here have ideas?
评论 #28817127 未加载
评论 #28817223 未加载
评论 #28817891 未加载
评论 #28822043 未加载
评论 #28819321 未加载
catillacover 3 years ago
So, I’m kind of dumb and this article helped me in a tangible way. When I work with jupyter notebooks on an ec2 (where I already have ssh access), I go into terraform or the console and add my personal ip to allowed ips in the security group, and then access the notebook via EC2_PUBLIC_IP:JUPYTER_PORT in my browser. This is annoying in particular, in addition to needing to add an IP, in that when I move from the office to home or vice versa there’s always a brain fart where I cannot access because I’m on a new ip.<p>After reading this article I started a port forwarding session and can access the remote notebook without issue. All it took was the ssh port forwarding. Amazing.
dls2016over 3 years ago
I setup an RPI in a field at my dad’s w&#x2F; 900MHz internet bridge and wanted 24&#x2F;7 remote access but didn’t want to pay for and configure VPN. At first I opened a router port but the RPI showed access attempts every few minutes, which was troubling. Learned enough about ssh tunneling to setup a systemd service to auto-attach the RPI to an AWS instance. (Also have an RPI on the bench attached as well.)<p>I always laugh when I ssh into AWS, then into the RPI (over the internet and then a 900MHz bridge). Then sometimes I ssh or ftp into a data logger running in the field. Good times and has worked relatively flawlessly for a few months. (I don’t have any uptime metrics for the network connection but no noticeable problems.)<p>I’m planning a few more which would be much more remote. Any other suggestions for managing such a setup? Some sites may have cellular connections and so I’m not sure I want 24&#x2F;7 ssh tunnel (though I don’t think it uses too much data).<p>Edit: I see others recommending WireGuard for similar situation. Never heard of it will check out.
评论 #28819057 未加载
评论 #28818849 未加载
评论 #28819106 未加载
brightballover 3 years ago
Interesting read. Funny to see this on HN today while I’m reading up on Teleport anyway.
bloqsover 3 years ago
This is a great post, intriguing.
gue-niover 3 years ago
I see this page has built in chat functionality, such an annoying and useless feature.
denkiover 3 years ago
Hackers are like so cool and popular