Ssh – Not able to access the local machine from remote server; what’s the local IP address

ipmobilessh

This is where I spent much time to know why I'm unable to connect to my local box from my own remote server (VPS); seems to be my local box's IP address issue.

To begin with, let me 1st tell how I operate in Internet.
I connect my laptop with my cellphone Nokia N73 having Vodafone SIM card. This way (dial-up) my laptop is connected to Internet.
Regarding the remote server (VPS), I purchased it from http://lvpshosting.com/.
They provide 100 Mb/s net speed.

I have remote's IP address. I ssh it and connect. Now, to connect from there to my local, I need my local IP add. So, checked my IP executing ifconfig on my local box. Please see the output below:

ravbholua@ravbholua-Aspire-5315:~$ ifconfig
eth0      Link encap:Ethernet  HWaddr 00:1b:38:d0:45:ea  
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
          Interrupt:18 

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:493 errors:0 dropped:0 overruns:0 frame:0
          TX packets:493 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:85372 (85.3 KB)  TX bytes:85372 (85.3 KB)

ppp0      Link encap:Point-to-Point Protocol  
          inet addr:10.224.108.37  P-t-P:10.6.6.6  Mask:255.255.255.255
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1
          RX packets:4848 errors:0 dropped:0 overruns:0 frame:0
          TX packets:5375 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:3 
          RX bytes:2352345 (2.3 MB)  TX bytes:698847 (698.8 KB)

From here, I suppose it to be 10.224.108.37. But when using this from remote, it doesn't work to connect to my local box.

I have tried using the following for my local IP address.

http://www.ipchicken.com/

http://whatismyip.org/

These 2 links gave IP address but none worked. As someone told that the address given by these 2 links are of my cell phone and not of my laptop.
Also when I connect to my remote from local via ssh, then when I log in to my remote, the remote server messages as seen below:

ravbholua@ravbholua-Aspire-5315:~$ ssh  rs
ravbholua@rs's password: 
Welcome to Ubuntu 13.04 (GNU/Linux 2.6.32-042stab076.5 i686)

 * Documentation:  https://help.ubuntu.com/

No mail.
Last login: Tue Sep 10 08:04:49 2013 from 123.63.112.140

This IP address as mentioned above is similar to what I get from the 2 links above. (And is not the one given by command ifconfig.)

So, one told me that the remote server displays the IP of the cell phone which is acting as a router and your local machine is not reachable. But I couldn't get any further solution on how my local box would be reached.

Please have a note here that I had posted this query on a different site (mentioned below), but couldn't get solution. It would be very useful if one please have a look at that thread of mine in that forum:

http://www.linuxquestions.org/questions/linux-networking-3/not-able-to-do-password-free-access-to-remote-machine-4175475825/

Much of my other related tasks are pending due to this issue. I am too hopeful from this site as a few other earlier unsolved queries of mine got solved in this site.

Best Answer

First of all, you don't need to connect to your machine in order to display remote programs locally. In fact, it's harder to do it that way. In order to log into a remote server and run a graphical program and see its GUI on your local machine, you will need to activate ssh X forwarding which is done by either the -X or -Y options of ssh:

 -X      Enables X11 forwarding.  This can also be spec‐
         ified on a per-host basis in a configuration
         file.

         X11 forwarding should be enabled with caution.
         Users with the ability to bypass file permis‐
         sions on the remote host (for the user's X
         authorization database) can access the local
         X11 display through the forwarded connection.
         An attacker may then be able to perform activi‐
         ties such as keystroke monitoring.

         For this reason, X11 forwarding is subjected to
         X11 SECURITY extension restrictions by default.
         Please refer to the ssh -Y option and the
         ForwardX11Trusted directive in ssh_config(5)
         for more information.

 -Y      Enables trusted X11 forwarding.  Trusted X11
         forwardings are not subjected to the X11 SECU‐
         RITY extension controls.

So, simply connect to the remote server and rn your application (using xclock as an example`):

user@local$ ssh -Y user@remote
user@remote$ xclock

That should cause a clock to appear on your local computer screen.


Now, the rest of your problems are probably due to your using your phone as a modem. The IP you get from whatismyip.com is the IP of your telephone, not of your computer. Your telephone is not configured to allow ssh access so you can't connect to it.

Now, I've never connected through a phone but if I understand your ifconfig output correctly, your phone's IP is 10.224.108.37 and your computer's local IP is 10.6.6.6. This means that in order to connect to your computer you would have to somehow configure your phone to forward incoming connections on the ssh port (usually 22) to your IP. I have no idea if this is possible, have a look at your phone's manual.

An alternative would be to set up an ssh tunnel that goes through your phone. This will only be possible if you have ssh access to the phone though and that does not seem to be the case.

Anyway, the basic message here is that you almost certainly don't need to connect back to your computer, this looks like a classic XY problem. So, put down the chocolate covered banana... :)

Related Question