Sunday, April 21, 2013

Accessing my computer from anywhere over internet using ssh and port forwarding

1. Creating a free account on noip.com
Create an account on noip.com. You'll receive a confirmation mail from noip.com. Confirm the link.

Login to your account on noip.com and goto
My Account > Hosts/Redirects > Manage Hosts > Add a host
Chose a proper host name (ex: myserver) and a free domain (ex: zapto.org) from the available list and click on "Update host" when completed.

2. Installing the noip client on device to be accessed
Now Download the noip2 tool from the site under Hosts/Redirects > Download Client

Unzip the noip-duc-linux.tar.gz and install it
$ tar -xzvf noip-duc-linux.tar.gz
$ cd noip-2.1.9-1
$ sudo make install
$ sudo noip2 -C
[sudo] password for user: 

Auto configuration for Linux client of no-ip.com.

Please enter the login/email string for no-ip.com youremail@gmail.com
Please enter the password for user 'youremail@gmail.com'  ********

2 hosts are registered to this account.
Do you wish to have them all updated?[N] (y/N)  n
Do you wish to have host [myserver.no-ip.biz] updated?[N] (y/N)  n
Do you wish to have host [myserver.zapto.org] updated?[N] (y/N)  y
Please enter an update interval:[30]  
Do you wish to run something at successful update?[N] (y/N)  n

New configuration file '/usr/local/etc/no-ip2.conf' created.

To check the status:
 $ sudo noip2 -S

No noip2 processes active.
 
Configuration data from /usr/local/etc/no-ip2.conf.
Account youremail@gmail.com
configured for:
    host  myserver.zapto.org
Updating every 30 minutes via /dev/wlan0 with NAT enabled.

3. Port Forwarding of local wifi network to be accessible from anywhere over internet
Now we need to give access to wifi router to access ssh port from anywhere in the internet. I followed the tutorial from this site and it worked well for me. For my beetel wifi router on airtel network on the browser, login to wifi http://192.168.1.1
user: admin
password: password
http://portforward.com/english/routers/port_forwarding/Beetel/450TC1/defaultguide.htm

4. Changing default ssh port
So we are almost done now. However its recommended to change the ssh port from default (default port 22) settings while forwarding it to internet for security reasons.

To change the ssh port:
sudo vi /etc/ssh/sshd_config and change the following line to custom port address

 ListenAddress 0.0.0.0:44812 

--> make sure that this port number matches the port address described in the portforward.com tutorial.

Also you can make your device ip static. For Raspberry pi, i have mentioned the modifications in the comments of previous post.

5. Accessing over internet using ssh client
Now, to access the device from anywhere from the internet. I am using the ConnectBot client in Android to access my device remotely.

 ssh username@myserver.zapto.org:44812

--> you should be connected to your device now. Cheers, now I can access my device from anywhere using my android phone :-).

No comments:

Post a Comment