Tuesday, February 26, 2013

Setting up a Linux server at home

A little project that I took on today is to establish my newly built Linux box into a network server, which I can remotely login via SSH Secure Shell.

Here are the steps that I took to set the home VAIO machine as a Linux server for SSH access:

1. First I installed OpenSSH server on the home Linux box:
    "sudo apt-get install openssh-server"

2. After successful installation, the server should starts automatically. Then I tested the SSH on the server end:
    "ssh localhost"
    It should prompt me to enter a password for authentication.

3. Now the server is up and running. But in order to access this server from a remote computer (outside your home LAN), we need a static domain name for it. Usually under DHCP, the ip address of the home Linux box is changed from time to time. We can use dynamic DNS service to link the actual ip address to a given domain name. To do that, I logged on to www.no-ip.org, signed up for an account, and added xpennyhuang.no-ip.org as the domain name for the home Linux box. Then I downloaded and installed a client onto the Linux box, to update the dynamic ip address to the domain name (the name of the client package is called no-ip2, which requires a build from source).

4. One last step we needed to do to enable the SSH access is to correctly set the "Port Forwarding" for the SSH service. The idea is, my Linux box is connected to the internet with via a router. From the point of view of external hosts on the internet, my Linux box ip address is invisible to them. Therefore, in order to allow external hosts (a remote computer) to access my Linux box for certain services(eg. SSH here), we need to set up "Port Forwarding". This is done on the Verizon router page/Firewall Setting/Port Forwarding.

5. Finally, with everything setup as mentioned above, we can test the access from a remote PC. I tested with a Windows PC running SSH Secure Shell.

6. To start, stop or restart the SSH server, the following commands can be used.

-To start the server: $sudo service ssh start
-To stop the server: $ sudo service ssh stop
-To restart the server: $sudo service ssh restart

No comments: