I am trying to have a local Unix domain socket, say, ~/docker.sock. I want it to proxy everything to a remote Unix domain socket running elsewhere over SSH. (You can find a diagram of what I’m trying to do below).

OpenSSH supports this (an example here). For instance, this command will proxy MySQL client connections on a remote server to my local instance:

ssh -R/var/run/mysql.sock:/var/run/mysql.sock -R127.0.0.1:3306:/var/run/mysql.sock somehost

But this is not how I want it to be like. It forwards the traffic that comes to the remote socket to my local socket (I want it the other way).

enter image description here


The man page for ssh offers two complementary options: -R for remote forwarding to local, and -L for local forwarding to remote.

In your case just use -L instead of -R.

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.