3

I have two processes (Client and server) that communicate with each other using a Unix socket /tmp/tm.ipc. Both processes (Client and Server) don't support TCP.

Client -> /tmp/tm.ipc -> Server

Now, I want to separate both processes to run on two different machines that run in the same subnet. Therefore, I want to build sort of a TCP bridge in between.

Client -> /tmp/tm-machine1.ipc -> TCP port 15432 -> /tmp/tm-tm-machine2.ipc -> Server

I was thinking to use Socat, but this looks like that it only covers the server listening part.

socat -d -d TCP4-LISTEN:15432,fork UNIX-CONNECT:/tmp/tm.ipc

Now I want to connect the client's Unix socket to that port. How can I do that?

5

OpenSSH of a sufficient version (OpenSSH 6.7/6.7p1 (2014-10-06) or higher) can do this, if the SSH is initiated from the client to the server system one could write something like

ssh -L /path/to/client.sock:/path/to/server.sock serverhost

and then the client would connect to /path/to/client.sock and the server would listen at /path/to/server.sock. You probably will also need to set -o StreamLocalBindUnlink=yes, see ssh_config(5).

(And please don't use /tmp; improper use of /tmp can lead to local security exploits or denials of service or…)

  • that is 100% fascinating. makes you wonder how these features come about, eh? :) – Tim Kennedy Feb 6 '18 at 16:33

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.