I have a VPS with 2 public IPs (assume 192.168.0.1 and 192.168.0.2)
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 192.168.0.2:22:remote_machine:22 remote_machine
Then, I am trying to access 192.168.0.2 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 192.168.0.1. When I do a
netstat - plant |grep LISTENI see
tcp 0 0 192.168.0.1:22 0.0.0.0:* LISTEN 603/sshdcorrectly, and 603 is indeed the process ID of SSHD.
When I execute the above port forward, when I do
netstat -plant | grep LISTENI see
tcp 0 0 192.168.0.2:22 0.0.0.0:* LISTEN 1416/ssh tcp 0 0 192.168.0.1:22 0.0.0.0:* LISTEN 603/sshd
And 1416 is indeed the process ID of my
selinux is disabled
iptables -Llists nothing. No firewall of any sort whatsoever.
I am able to do
ssh 192.168.0.2on 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)
$HOME/.ssh/configeverything contains the line
GatewayPorts yes, and I also use the
-goption. In fact, I have tried all combinations and still unable to access the local forward port from a remote machine.
When I run
-vvvI do see ->
debug1: Local connections to 192.168.0.2:22 forwarded to remote address remote_machine:22 debug3: channel_setup_fwd_listener: type 2 wildcard 0 addr 192.168.0.2 debug1: Local forwarding listening on 192.168.0.2 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 192.168.0.2 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 192.168.0.2 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?