SSH Port Forwarding Example use OpenSSH client

To use the feature SSH Port Forwarding you must enable AllowTcpForwarding on your sshd_config

AllowTcpForwarding yes

Remote Forwarding

To enable Remote Forwarding outside the server machine, you must enable GatewayPorts on your sshd_config

GatewayPorts yes

or strict all except an IP address

GatewayPorts clientspecified

Example 1:

ssh -R 12345:localhost:80

Example 2:

ssh -R

only connections from the IP address to port 12345 are allowed.

Local Forwarding

Example 3:
ssh -L

This example opens a connection to the jump server, and forwards any connection to port 80 on the local machine to port 80 on

You can specify a bind address:
ssh -L

Dynamic Port Forwarding allows a communication not on a single port, but across a range of ports. This port forwarding is created using -D parameter. This option will make SSH acts as a SOCKS proxy server. SOCKS5 is an internet protocol which routes packets between a server and a client using a proxy server.

Example 4:
ssh -v -D 12345

Now you have a Socks5:

Recent search terms:

  • ssh client port

Leave a Reply