Top
Best
New

Posted by signa11 4 days ago

A Practical Guide to SSH Tunnels: Local and Remote Port Forwarding(labs.iximiuz.com)
185 points | 43 comments
tangotaylor 2 hours ago|
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 want to bother with a registry and a good Internet connection.

Example, docker pussh: https://github.com/psviderski/unregistry

mmh0000 1 hour ago||
That's not quite true, you just need to add the `insecure-registries`[1] option with a list of either IP (or ip ranges) or hostnames that you want to allow without TLS.

```/etc/docker/daemon.json

  {
    "insecure-registries": ["10.100.0.0/24", "registry.yourmom.example.com:5000"]
  }
```

[1] https://docs.docker.com/reference/cli/dockerd/#insecure-regi...

QGQBGdeZREunxLe 1 hour ago|||
This is really useful as you don't have to add an entry under insecure-registries for local registries that don't have valid certificates.
bitlad 1 hour ago||
You might as well handover the images to hackers.
Kampfschnitzel 2 hours ago||
iirc there's a setting to allow docker to trust and use http registries

i set it up a few years ago for my homelab

afiori 43 minutes ago||
Which makes me think that I have never heard of signed images/artefacts
buredoranna 4 hours ago||
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 its available

  -o EnableEscapeCommandline=yes
or, in your ~/.ssh/config

  EnableEscapeCommandline yes
(edit: formatting)
telotortium 4 hours ago|
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.

ptaffs 3 hours ago||
so many time i have inadvertently ended a session with a fat fingered ~.
wbadart 4 hours ago||
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.

opsdisk 3 hours ago||
Appreciate the mention wbadart!
ranger_danger 2 hours ago|||
Not mentioning the ssh -w option in that book should be a crime.
susu1111 3 hours ago||
so good, I learn new things.
smw 3 hours ago||
Need to mention sshuttle [0] here, as it magically solves a bunch of these problems without constant reconfiguration

[0] https://github.com/sshuttle/sshuttle

mystifyingpoi 14 minutes ago|
sshuttle is amazing. I've used it extensively on stupidly configured networks, super useful tool.
ktm5j 8 minutes ago||
Weird.. I have almost this exact same "cheat sheet" printed out and stuck up on my whiteboard.. except it's slightly different. Only 4 panels instead of 6 and the panels don't have titles.

I know this is a solid "cool story bro" moment, but whatever hah

chasil 5 hours ago||
The article mentions bastions, but no jumphosting?

  ssh -J user1@bastion1,user2@bastion2 targetuser@targethost
Edit: Jumphosting was introduced in OpenSSH 7.3 2016-08-01.

https://www.openssh.org/releasenotes.html

saltcured 30 minutes ago||
For me, this is always used via ProxyJump rules in my ~/.ssh/config

It is also nice that it works recursively, so I can logically structure my rules so that the one for my regular targets say to use bastion1, then the rule for bastion1 says to go via bastion 2, etc.

I find this easier to reason about and maintain rather than juggling a bunch of these multi-step rules.

dspillett 5 hours ago|||
It is surprising how many times I see this content (this version might be marked “Published: Jun 19, 2026” but I've definitely seen those exact diagrams before, starting at least a few years ago, and the same content around them in many tutorials before that) without it being updated to mention jump-hosts.

Support was added to OpenSSH about a decade ago? Even on a low moving Linux distro like Debian/LTS everyone should have support by now.

m348e912 1 hour ago||
>ssh -J user1@bastion1,user2@bastion2 targetuser@targethost

Are you using SSH key auth or password authenticating three times when you do this?

chasil 37 minutes ago|||
If you don't have an agent running with an accessible key, then you will get three password prompts, with suggestions for any default keys.

The final target is a pre-elliptic curve OpenSSH server, so legacy is enabled. I could probably have removed that for clarity.

  C:\Users\me\>ssh -J me@bhost1,me@bhost2 -o KexAlgorithms=diffie-hellman-group14-sha1 -o HostKeyAlgorithms=ssh-rsa -o MACs=hmac-sha1 oracle@target
  Enter passphrase for key 'C:\Users\me/.ssh/id_ed25519':
  me@host1's password:
  Enter passphrase for key 'C:\Users\me/.ssh/id_ed25519':
  me@host2's password:
  oracle@target's password:
  Last login: Wed Jun 24 13:29:55 2026 from bhost2
That client is Microsoft's port of OpenSSH.
saltcured 29 minutes ago|||
I always use keys in my SSH agent.

Because the jump mechanism works via use of TCP forwarding, each host authn step is talking "directly" to your client. Importantly, this means it still works without requiring "agent forwarding" for the connection you are making.

phbeks 32 minutes ago||
Thanks! I will keep this for reference. I use ssh alot but thie reminds me that I can learn new ways of tunneling :-)
hylaride 5 hours ago||
Learning how SSH port forwarding is great as a pseudo-vpn for everything from GUI-client database access to (in physical infra) access to web-admin tools for appliances.

The socks proxy support can also deal with bad web filtering and privacy issues on public wifi networks (though nowadays if you're ssh'ing to a cloud IP, you'll get lots of "bot" restrictions).

saltcured 20 minutes ago|
Yeah, I get use out of the SOCKS proxy mode in combination with a "split VPN" at work.

I need VPN to get into some internal resources via SSH, but there are lots of external/public/AWS resources I also need to access, and the full VPN adds too much overhead and fragility for those.

Using the available split VPN, I can point a browser instance at a localhost SOCKS proxy port to relay over SSH + VPN for other web resources I need to access internally.

Unfortunately, Firefox proxy config rules are sort of backwards for my needs. I want to say "only use proxy for these 3 domains" whereas it wants to use the proxy by default and only allow me to bypass specific domains.

bheadmaster 3 hours ago||
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.

saltcured 26 minutes ago||
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.

ranger_danger 2 hours ago||
Do you have more info on this method? How is the remote forwarding actually done?
mldbk 1 hour ago||
[dead]
segphault 5 hours ago|
Or you could just install something like Tailscale and never have to think about it again.
More comments...