Remote Port Forwarding Tutorial Using SSH

Port Forwarding is often applied to many things, one of its uses is to channel ports from client to server, and vice versa. If you have previously tried the service snoringas that is called port forwarding.

SSH can also be used for this, and many people refer to it as SSH Tunneling. In fact, besides being used to forward ports, it can also be used to add network encryption like using a VPN.

You can also create your own SSH Port Forwarding service for the purpose of opening ports on a server. For example you are running a webserver Apache/Nginxbut the server doesn’t allow access to port 80 or 443, so in this way, you can open those ports using SSH.

Tutorial on Creating Private SSH Remote Forwarding

What you need to prepare first is Linux VPS to create an OpenSSH Server. No need for high specifications, even 1 CPU is enough. If you have prepared the VPS, please follow the steps for making it below.

1. Setting SSH Configuration for Tunneling

By default, OpenSSH does not allow port forwarding through computers outside the server, but with a few tweaks in the configuration, it’s certainly not impossible to do.

Please open the SSH settings using the following command:

nano /etc/ssh/sshd_config

After that add the following text to the last line:

GatewayPorts yes
AllowTcpForwarding remote

If you have added it, please save it and then restart the SSHD using the following command:

sudo systemctl restart ssh

2. Opening Port on VPS Firewall

Before using the port for tunneling or forwarding, make sure that the port is opened in the server’s firewall settings. Because if you use a VPS service, you have to set it yourself in the Firewall.

3. Running Port Forwarding Using SSH

The last step is to try to run this tunneling, for example here I want to forward port 80 from the client to port 8110 server, here is an example of the command:

ssh -R 8110:localhost:80

So the above command is run on the client computer, and you also need to authenticate the SSH login process so that later tunneling can run. Make sure you change the IP address above with the VPS IP address that you prepared earlier.

And if you are already connected to SSH, you can access port 80 via the following URL:

Once again, don’t forget to change the IP address above according to the IP address or VPS host that you have set up.

Also read: How to Change Original PORT 3389 on RDP


Port forwarding using SSH in my opinion is simpler, because there is no need to use other programs like snoring. On the internet there are also many SSH port forwarding services, it’s just that most of them limit to port 80 or 443 only.

There used to be a service called Serveo which does not limit the port, it’s just that the service has been closed due to many abuses. Therefore, if you need to do port forwarding on many things, of course making it private will be better and safer.

If you have any questions regarding the tutorial above, you are very welcome to comment for immediate assistance.

Hopefully useful and good luck