Remote Dynamic forwarding with unix socket
Макс
m88202016 at gmail.com
Tue Nov 17 16:43:25 AEDT 2026
Hi Charles,
Thanks for the patch — I hit the same issue independently and your analysis
matches mine: channel_connect_by_listen_path is missing the port_to_connect
== 0 check that channel_connect_by_listen_address has, so the reverse
dynamic forward to a unix socket never gets hooked up locally.
I haven't been able to build or test the patch yet (no build environment
handy at the moment), so I can't confirm the man page rendering or runtime
behavior. But the diff looks correct to me.
I think filing it at bugzilla.mindrot.org is the right next step — have you
filed it already, or would you like me to?
Best,
Maxim
пн, 16 нояб. 2026 г., 12:40 Charles Mirabile via openssh-unix-dev <
openssh-unix-dev at mindrot.org>:
> Hi all—
>
> I recently tried to do reverse dynamic forwarding where the remote
> listener was a unix socket instead of a tcp host/port (i.e. `-R
> /tmp/proxy.sock`) on Linux. It wasn't documented in the man page, but
> seemed like a natural extension of the existing syntax and it was
> accepted by my client and the server (i.e. no error message locally
> and the socket does get created on the remote machine).
>
> However trying to actually use the remote socket as a proxy didn't
> work (e.g. `curl --proxy=socks5h://localhost/tmp/proxy.sock
> https://example.com` on the remote machine causes ssh to print
> "connect_to socks: unknown host (Name or service not known)").
>
> After rooting around in the code for a while but not really getting
> anywhere, I asked gemini (forgive me) and it confirmed my suspicions,
> suggesting that this behavior was a limitation of the client: while it
> could parse the option and was sending the right thing to the server
> something wasn't hooked up internally locally and it was treating it
> like a remote unix to local tcp forward and trying to connect locally
> to a fake hostname "socks". It suggested various workarounds (i.e.
> running a dedicated proxy on a specific local port and forwarding that
> port to the remote machine).
>
> I asked it whether I could patch my client, and while it hallucinated
> the actual code substantially, I guess enough of the openssh code was
> in its pre-training that it was able to point me to the functions
> `channel_connect_by_listen_address` and
> `channel_connect_by_listen_path` in channels.c where I saw the former
> has a check for `port_to_connect` being zero in which case it calls
> `rdynamic_connect_prepare` while the latter has no such check.
>
> I copied the if statement from one function into the other and
> recompiled and the resulting client was able to perform this kind of
> forwarding. I have attached a patch with that modification to
> `channel_connect_by_listen_path`, and also a small edit to the man
> page to document this usage (though I do not know troff and again
> merely copied another block and edited it lightly so do please check
> it over).
>
> Perhaps this patch is worth including? I'd also be happy to file a
> formal bug. I am not very familiar with the OpenBSD development
> process, but I do think that this would be applicable to the upstream
> and not merely to the portable version. I also only subscribed to the
> list to send this and will probably unsubscribe so please make sure to
> reply to me directly. Thanks in advance for your attention (and for
> creating this great program in the first place)!
>
> Best—Charlie
>
> Charles Mirabile
> Senior Software Engineer
> ARM & RISC-V Kernel Hardware Team
> Red Hat
> _______________________________________________
> openssh-unix-dev mailing list
> openssh-unix-dev at mindrot.org
> https://lists.mindrot.org/mailman/listinfo/openssh-unix-dev
>
More information about the openssh-unix-dev
mailing list