Short question:

How do I connect to a local unix socket (~/test.sock) via ssh? This sockets forwards to an actual ssh server. The obvious does not work and I can't find any documentation:

public> ssh /home/username/test.sock
"ssh: Could not resolve hostname: /home/username/test.sock: Name of service not known"

Long Question:

The Problem I try to solve, is to connect from my (public) university server to my (local) PC, which is behind NAT and not visible to public.

The canonical solution is to create a ssh proxy/tunnel to local on public:

local> ssh -NR 2222:localhost:22 public

But this is not possible, as the administration prohibits creating ports. So I have thought about using UNIX socket instead, which works:

local> ssh -NR /home/username/test.sock:localhost:22 public

But now, how can I connect to it with ssh?


You should be able to do utilizing socat and ProxyCommand option for ssh. ProxyCommand configures ssh client to use proxy process for communicating with your server. socat establishes two-way communication between STDIN/STDOUT (socat and ssh client) and your UNIX socket.

ssh -o "ProxyCommand socat - UNIX-CLIENT:/home/username/test.sock" foo

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.