SSH forwarding is valuable in transporting network data for services that rely on unencrypted protocols like VNC or FTP. It offers a secure method to transmit this data by leveraging the encryption provided by SSH. Additionally, SSH forwarding facilitates accessing geo-restricted content and bypassing intermediate firewalls that might restrict the direct access to certain services.
SSH port forwarding comprises three distinct types:
1) Local Port Forwarding is a method of SSH port forwarding that enables you to establish a connection from your client to the SSH server and then forward that connection to a specific destination host port.
2) Remote Port Forwarding is a type of SSH port forwarding that facilitates forwarding a port from the server to the client and then to a specific destination host port.
3) Dynamic Port Forwarding is a type of SSH port forwarding that establishes a SOCKS proxy server, enabling communication across a range of ports.
To set port forwarding for the remote server, you can specify remote SSH port forwardings using the -R option. This option allows you to define the forwarding rules for remote ports. Here is the basic syntax:
ssh -R [REMOTE:]REMOTE_PORT: DESTINATION

The options used are as follows:
REMOTE_PORT - the port number and IP address on the remote SSH server. If the REMOTE value is not specified, then the remote SSH server will bind to all interfaces.
DESTINATION_PORT - Specifies the IP address or hostname and the port number of the destination machine.
[USER@]SERVER_IP - Specifies the remote SSH user and the server's IP address.
Remote port forwarding is used to grant external individuals access to an internal service.
For example, ssh -R 9090:example.com:80 admin@server.com
By specifying the -R flag, we establish that requests sent to the remote server port 9090 will be redirected to example.com, which resides on the local network at port 80. If we initiate a request to the server using port 9090, we will receive a response from example.com.
Leave a comment: