For those who worked with ssh port forwarding or for those who have an idea, I managed to create a remote tunnel from my PC to a remote machine(a camera that does not have a public address) through a ssh server ( has a public address ).

The goal is to forward the access of the camera to the public with ssh remote port forwarding,

The format of the command that I launched on my PC is:

  ssh -R sshServer_port:destination_address:destination_port sshServer_address


  ssh -R 3000: [email protected]

In the sshServer, I can access the remote machine through localhost:3000

and then, I set up a tcpproxy to make the access public with this command:

tcpproxy -lhost -rhost localhost:3000

With this,anyone from any network can access to the camera interface by typing

What I want to do is create a tunnel that listens on two remote machine ports (80 for http and 8000 for the live streaming) with the format of the command:

ssh -R sshServer_port:destination_address:destination_port1 -R sshServer_port:destination_address:destination_port2 sshServer_address


ssh -R 3000: -R 3000: [email protected]

I tried to run the command but I got this error: Warning: remote port forwarding failed for listen port 3000

Do you have an idea how to fix this.

2 Answers 2


What you want is not to create a tunnel that listens on two remote machine ports, you want two tunnels that listen on the same remote port.

That is not possible. How is ssh supposed to know to which port an incoming connection should be forwarded?

There are solutions that can distinguish between protocols, but none of them are generic. It the port 80 you use is an indication of http traffic, you can set up a reverse proxy, but it would be much easier to just use two different ports for the two destinations.


From your comments, it seems you are just missing the -g option to SSH to allow other hosts to connect to the tunnel.

  • Thanks for the answer, I already set up a reverse proxy (tcpproxy) that forward any request of the port 8080 to the localhost:80 of the ssh server. If I use two different remote ports for the two destinations, I cannot set up the reverse proxy. Do you know any other solution for that ? Could dynamic port forwarding solve the porblem ?
    – Wrath13
    Oct 11, 2018 at 14:32
  • You would have to provide more details.
    – RalfFriedl
    Oct 11, 2018 at 14:33
  • okay, So the destination machine ( is a camera that I can access to its interface by writing its address in the browser, the camera needs the port 80(http) and the port 8000(streaming). The camera doesn't have a public address, so what I did is creating tunnel(ssh -R 3000: [email protected]) to the public through a ssh server that has a public address. when I set up a tcpproxy (tcpproxy -lhost -rhost localhost:3000), anyone could access to the camera through the address of the public server but it needs the port 8000 to the live streaming works.
    – Wrath13
    Oct 11, 2018 at 14:46
  • Add that to the question, it allows proper formatting and for others to see at once.
    – RalfFriedl
    Oct 11, 2018 at 14:47
  • Why don't you just forward port 80 to 80 and 8000 to 8000? Why port 3000 for both?
    – RalfFriedl
    Oct 11, 2018 at 14:49

I fixed the issue, thanks to ralffriedl for the hints.

First step: I created the first remote port forwarding tunnel between the camera address on port 80 and the ssh server on port 2233, then I set up a tcpproxy between the localhost:2233 of the ssh server and the public ip address of the server( on port 4455

Second step: I created the second remote port forwarding tunnel between the camera address on port 8000 and the ssh server on port 2255, then I set up a tcpproxy between the localhost:2255 of the ssh server and the public ip address of the server( on port 8000

With this, when someone from an external network, put the server ip address on his browser with the port forwarded from the port 80 of the camera ip address, i.e:(, he is able to access to the camera and when a live streaming request is done on port 8000, ie:(, it's forwarded to the localhost:2255 of the server and then to the port 8000 of the camera.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .