I have a VPS with 2 public IPs (assume and

I am trying to do a local tunnel to my router on my VPS bound to the second IP, and then access it via another machine. I do the following -

# ssh -g -L remote_machine

Then, I am trying to access from my laptop in a coffee shop, but it times out. What could be happening? here's what I have troubleshooted -->

  • My SSH server on my VPS is only listening on When I do a netstat - plant |grep LISTEN I see tcp 0 0* LISTEN 603/sshd correctly, and 603 is indeed the process ID of SSHD.

  • When I execute the above port forward, when I do netstat -plant | grep LISTEN I see

    tcp 0 0* LISTEN 1416/ssh 
    tcp 0 0* LISTEN 603/sshd

And 1416 is indeed the process ID of my ssh call.

  • selinux is disabled

  • iptables -L lists nothing. No firewall of any sort whatsoever.

  • I am able to do ssh on the VPS, and it successfully takes me to remote_machine. However, I am not able to get the same behavior from outside the VPS (from my coffee shop)

  • The /etc/ssh/ssh_config , /etc/ssh/sshd_config, $HOME/.ssh/config everything contains the line GatewayPorts yes , and I also use the -g option. In fact, I have tried all combinations and still unable to access the local forward port from a remote machine.

  • When I run ssh with -vvv I do see ->

    debug1: Local connections to forwarded to remote address remote_machine:22
    debug3: channel_setup_fwd_listener: type 2 wildcard 0 addr
    debug1: Local forwarding listening on port 22.

However, there's no notification of any action when I try to connect to that port.

  • I have tried this as a root user with privileged ports and non root user with high numbered ports. Same behavior. Access is only possible from the VPS itself, but not outside the VPS.

  • If I set the VPS SSH server to listen on as well, I am able to access the VPS from that address. However, when I create a tunnel with one of the end points on and another on remote machine, access to the tunnel is only possible from within the VPS, not anywhere outside.

Any idea what I am missing?

  • Maybe the coffee shop blocks port 22? You could try connecting to a well-known site like github.com.
    – Kenster
    Nov 22, 2015 at 0:02
  • Nope, that is definitely not the case, since I can access the VPS itself via SSH. Also, this behavior is not just for SSH. Even if I forward a port that is running some other service (http based for instance) I see the same behavior, I can access it from within the VPS, but not from a remote machine. Nov 22, 2015 at 0:54
  • Who is the VPS provider?
    – cutrightjm
    Nov 22, 2015 at 7:36
  • Please don't use public IP addresses (especially those belonging to others). May 14, 2019 at 6:23


You must log in to answer this question.

Browse other questions tagged .