Forward local port or socket file to remote socket file
Altough in the time, when the question was asked, it was really impossible, but it is possible nowadays.
You can to both: UNIX=>TCP and UNIX=>UNIX forwarding.
For example:
ssh \
-R/var/run/mysql.sock:/var/run/mysql.sock \
-R127.0.0.1:3306:/var/run/mysql.sock \
somehost
It is possible since OpenSSH 6.7.
Forward a local socket on demand
- Setup SSH public key authentication
- Install
socat
at both ends - create a directory locally for your sockets, inaccessible to other users.
export SOCKET_DIR=~/.remote-sockets
mkdir -p $SOCKET_DIR
socat "UNIX-LISTEN:$SOCKET_DIR/mysqld.sock,reuseaddr,fork" \
EXEC:'ssh user@server socat STDIO UNIX-CONNECT\:/var/run/mysqld/mysqld.sock'
then
mysql -S $SOCKET_DIR/mysqld.sock -u mysqluser -p
stolen from forwarding unix domain sockets with ssh and socat