2

https://zaiste.net/ssh_port_forwarding/#remote-port-forwarding

Remote port forwarding is created with -R parameter.

ssh -R source_port:forward_to_host:destination_port via_host 

This command connects to via_host. via_host runs a SSH server. It then forwards all connection attempts to source_port on the remote via_host machine to destination_port port on the local machine (a machine that initiated the ssh command) . forward_to_host machine must be reachable from the the local machine machine. Forwarding can be also done through Unix sockets.

What does "Forwarding can be also done through Unix sockets" mean? How is that done?

Is ssh remote port forwarding done not through Unix sockets, but Internet sockets?

Thanks.

4

Let's look at the real ssh(1) man page instead of that webpage:

 -R [bind_address:]port:host:hostport
 -R [bind_address:]port:local_socket
 -R remote_socket:host:hostport
 -R remote_socket:local_socket

There are four forms of the -R option, and the one you quoted is the first one. It forwards a TCP port on the system that has the remote end of the SSH connection to the specified host and TCP port number on the local side of the connection.

The second form describes how to forward a remote TCP port to a local Unix socket:

ssh -R 1234:/tmp/local_socket user@remote_host

In other words, when something connects to TCP port 1234 on the remote_host, the connection will be forwarded to Unix socket /tmp/local_socket on the local host.

The third form describes how to do it the opposite way, remote socket to a TCP port on the local side:

ssh -R /tmp/remote_socket:1234:somehost user@remote_host

Here, a process on remote_host can use Unix socket /tmp/remote_socket and the connection will be passed through the SSH connection to the local side, and then over a regular TCP connection to TCP port 1234 of somehost.

The fourth form describes forwarding from a remote Unix socket to a local one:

ssh -R /tmp/remote_socket:/tmp/local_socket user@remote_host

Here, a process on remote_host could open the Unix socket at /tmp/remote_socket to connect to /tmp/local_socket on local host.

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.