I'd like to be able to remotely listen to UNIX sockets in order to make programs such as dtach, which only support listening to UNIX sockets, work remotely. I've read about socat and how it's able to forward UNIX sockets to TCP sockets and vice-versa, but in practice I haven't been able to make this work. So, through socat or any other means, how can one remotely listen to UNIX sockets?

(If you happen to know how to make dtach work remotely, then that's fine too. This question is simply an abstract question to the actual problem.)


I just found that this works:

remotehost$ socat TCP-LISTEN:6066 UNIX-CONNECT:/tmp/a.socket
localhost$ socat UNIX-LISTEN:/tmp/a.socket TCP:remotehost:6066

SSH can forward Unix domain sockets with -L and -R the same way that it forwards TCP ports. Example: ssh -L ./mydocker.sock:/var/run/docker.sock example.com

  • How? Can you expand on this with an example? – bertieb Apr 27 '18 at 19:17
  • Added an example. – Joseph Sible Apr 27 '18 at 19:37

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.