How to allow remote connections from non localhost clients with ssh remote port forwarding?

7,710

You might need to change the servers config. Set GatewayPorts to 'on' or 'clientspecified'. Otherwise the remote interface is restricted to localhost

Share:
7,710

Related videos on Youtube

videoguy
Author by

videoguy

Updated on September 18, 2022

Comments

  • videoguy
    videoguy over 1 year

    I have a system say "privatesys". I am trying to give access to its web server through a remote proxy using ssh remote port forwarding like below.

    Private sys name: privatesys
    Port exposed: 80

    The remote system name: remotesys
    The remote port: 9090

    On privatesys, I ran the following command.

    ssh -N -R remotesys:9090:localhost:80 -l username remotesys
    

    It set up a tunnel between privatesys and remotesys and the port forwarding worked fine as long as I connect to port 9090 from remotesys.

    What I like to do is access http://remotesys:9090/ from systems that are on the same sub net as remotesys. When I do that, I am getting invalid url error from browser. Looks like the sshd on remotesys is bound to localhost instead of all the interfaces on the system.

    What is the trick to get sshd on remotesys accept connections from any system on its sub net?

  • Admin
    Admin almost 13 years
    Can it be done on a server I don't have root access?
  • John Smith
    John Smith almost 13 years
    No, you need to edit the sshd_config. But you could try to login at the server and use a local forwarding. Like: ssh -R *:9090:localhost:80 -l username privatesys
  • Admin
    Admin almost 13 years
    I can't use local forwarding as privatesys is behind a firewall.