Unable to ssh into my linux machine behind a router from outside the network

4

We are about to deploy some of the gateway devices (Raspberrypi) in the field. Although we are trying to make them so robust that we should not be required to remotely access them but as this is one of POC, we are taking a measure to remotely debug them.

Set-up is like this, that we have a RPI that is acting as a data aggregator for other wireless devices. We just want to access the log and run some commands remotely if required. Now i am running a ssh server on my RPI and listening on default 22 port (we can change the port). Now this RPI is connected to a Reliance JIO wifi device whose port forward section looks like this

Reliance JIO hifi page for port forward

I used local port and WAN port both as 22 and MAC address as my laptop Wifi MAC address. Now i got my public IP using below command curl ipinfo.io/ip. Now i used one of my digital ocean server and tried to ssh using ssh <username>@<IP> -p<PORT number which is 22>, but still i am not able to access my machine and i am not able to figure out the reason behind that. Can any one guide me or at least point out the mistake which i am doing.

Note:- Also at present, i am using ngrock which allow only one ngrok process and with command ./ngrok tcp 22 you are able to get a customised IP from ngrok and can use the same to access the system without doing anything on router. This is good till the time you are testing on one machine. My main aim is to write a small python script which keep on posting the current IP of RPI to a web-server and update the IP if there is a change. I can then use the same IP to ssh my machine.

Edit-1 - I used online port scanner canyouseeme.org and found that port 22 is not open in my Reliance Wifi device in spite of the fact that i forwarded port 22 (if this mean opening port 22). Also i tried the same with my Dlink Router DIR-816. Below is the attached image enter image description hereand when i used online port scanner, it say that Error: I could not see your service on XX.XX.XX.XX on port (22) Reason: No route to host. I am using ACT fibernet - a one of broadband service here in Bangalore. When i run traceroute from one of my digital ocean server, i was able to see my IP.

Edid -2 As suggested i used a different WAN port and tried the online port scanner and came up with same error connection timed out. Also the output of netstat -anutp | grep :22 is $ netstat -anutp | grep :22 (Not all processes could be identified, non-owned process info will not be shown, you would have to be root to see it all.) tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN -
tcp 0 252 192.168.0.100:37043 XX.XX.XX.XX:22 ESTABLISHED -
tcp6 0 0 :::22 :::* LISTEN -

Is there is a possibility that my ISP is blocking this port or any incoming port request. But at the same time when i used ngrok, everything works fine. Problem with ngrok is, its a paid service and in free plan allow only one instance and i don't want to end-up paying $100 for ssh only.

srj0408

Posted 2017-05-06T19:11:05.430

Reputation: 65

Why not use a Dynamic DNS service? And if your router is using port 22 itself I would suggest that you test the port forwarding with another WAN port (eg 50222 - any will do), check if you computer is listening on 0:0:0:0 port 22 and if the firewall (if any) allows the connection). You can also use an online port scanner to see if the port will be shown as open. – Zina – 2017-05-06T22:27:42.200

I saw port 22 using canyouseeme.org and found that my port is not open inspite of the fact that i opened port 22 on my Reliance Wifi device. Same happen with my Dlink router DIR 816. – srj0408 – 2017-05-07T09:55:11.013

I still would suggest that you try another WAN port and forward it to you local ip port 22. Can you post the output of ifconfig and netstat -anutp | grep :22 on your laptop and a test the open port from Internet with your firewall disabled? – Zina – 2017-05-07T10:17:44.887

I tried using a different WAN port as 2804 and local port as 22 and when i use a online port scanner, i get the same error connection time out. I am adding the output of netstat in my question in Edit-2 – srj0408 – 2017-05-07T10:40:24.470

You say you made a port forward to 192.168.0.120 and your netstat output shows local IP .100 - as you did not include your ifconfig I am not sure if you did it on the correct machine.. Could you clarify? – Zina – 2017-05-07T19:32:05.210

No answers