From e1023d6d3b30a460dc3c74a1d0f62e95964918c3 Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Tue, 3 Dec 2013 04:26:10 +0100 Subject: [PATCH] README: Add example about socket forwarding with socat. --- README | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/README b/README index da69397..4776f6f 100644 --- a/README +++ b/README @@ -8,7 +8,7 @@ sockets are usable by everyone on the system. It works for both servers (`listen(3)`) and clients (`connect(3)`). -These UNIX sockets can also be forwared over SSH with `socat`. +These UNIX sockets can also be forwared over SSH with `socat` (see below). DEPENDENCIES @@ -80,6 +80,38 @@ The following additional environment variables are available: functionality but only one part should be redirected. +EXAMPLES +-------- + +`socat` can be used to forward UNIX sockets over SSH. Thanks to [1] for the +necessary commands. + +[1]: http://www.debian-administration.org/users/dkg/weblog/68 + +`socat` is required on both local and remote system. + +To forward the server socket `path/to/socket/remote` from `remote-host` to +`path/to/socket/local` on the local host run this command on the local system: + + $ socat UNIX-LISTEN:path/to/socket/local,reuseaddr,fork \ + EXEC:'ssh remote-host socat STDIO UNIX-CONNECT\:path/to/socket/remote' + +Any program on the local host can then connect to `path/to/socket/local` and +the connection gets forwarded to `remote-host`. + +To use the forwarding with socket2unix the sockets must be named appropriately +(see above). For example to use socket2unix on the client-side: + + $ socat UNIX-LISTEN:socket-v4-4711,reuseaddr,fork ... + +Connect to the forwarded socket: + + $ LD_PRELOAD=/path/to/libsocket2unix.so \ + SOCKET2UNIX_PATH=`pwd`/socket nc -4 localhost 3000 + +The same works for the remote socket. + + BUGS ---- -- 2.43.2