\r\n

\r\n

\r\n

\r\n

\r\n

\r\n

\r\n

\r\n

<< Previous: Operating System << Contents >> Next: Software>>

\r\n

Set up your NAS Server

\r\n

Setup your network configuration

\r\nSince you are running a server I guess you don’t want to run it in dhcp mode.\r\n

$ sudo vi /etc/network/interfaces

\r\nsudo will run your command with root (administrator) privileges – you have to enter your password to do this. Further informations for the sudo command.\r\n\r\nYour output should look like this\r\n

# This file describes the network interfaces available on your system # and how to activate them. For more information, see interfaces(5). # The loopback network interface auto lo iface lo inet loopback # The primary network interface auto eth0 iface eth0 inet dhcp

\r\nIt is possible that your network card is not called eth0. In this case do not change the name of the network card in the following update of your config. Just replace eth0 with the actual naming of our ethernet card.\r\n\r\nTo get an static ip you need to edit it to the following but consider to change the settings to your current network configuration. Move your cursur to the lines you want to remove and press dd (two times d) to remove a line. Press d3d to remove the next 3 lines. To insert text hit i.\r\n

# This file describes the network interfaces available on your system # and how to activate them. For more information, see interfaces(5). # The loopback network interface auto lo iface lo inet loopback # The primary network interface auto eth0 iface eth0 inet static address 192.168.178.10 netmask 255.255.255.0 network 192.168.178.0 broadcast 192.168.178.255 gateway 192.168.178.20

\r\nWhen you inserted your new network config hit Escape and type :wq to save (w) and leave(q) VIM. You can find more information for VIM here.\r\n\r\nNow we have to remove all lines from /etc/resolv.conf\r\n

$ sudo vi /etc/resolv.conf

\r\nMove your cursor to the top and press d9d to remove the next 9 lines (that should cover all lines) or hit i and comment all lines with an #.\r\n\r\nWhen you saved the file we just need to restart the network service, to do that type the following in your terminal:\r\n

$ sudo service networking restart

\r\n(Tip: type sudo service net and press tab – it should automatically complete the word networking. You can almost tab anything in ubuntu)\r\n\r\nTo check if you get your desired static IP we will use ifconfig\r\n

$ ifconfig

\r\nThe second line of your output should similar to this\r\n

inet Adresse:192.168.178.10 Bcast:192.168.178.255 Mask:255.255.255.0

\r\nIf your IP adress is displayed correctly then it works.\r\n\r\nIn the next part we will install SSH to configure and administrate our server from a remote computer.\r\n

Install SSH to administrate your server from a remote desktop

\r\nSecure Shell is a secure network protocol for a remote command-line login – you will need it to administrate your server from a remote computer. To enable SSH on our server we have to install the openssh-server package with apt-get. It is a part of the advanced packaging tool that allows you to install deb packages. You will often find apt-get or a similiar packaging tool like Aptitude in your daily Linux administration.\r\n

$ sudo apt-get install openssh-server

\r\nThe installation of openssh-server will probably ask you to install some depencies – just answer the question with y or yes.\r\n

How to connect to your SSH Server

\r\nLinux and Windows users can use PuTTY – a classic leightweight tool to use the SSH protocol. Download PuTTY and run it. If you are running Linux I recommend to connect to SSH directly from the terminal what is pretty simple as you can see\r\n

$ ssh [email protected]

\r\nYou will be asked for your credentials and well basically that’s it.\r\n\r\nTo set PuTTY up you just have to enter the IP of your server into the host name field. If you want to save your connection give a name in the field under “Saved Sessions” and hit save on the right.\r\n

win1

\r\n

\r\nWhen you want to connect to your server click open and accept the following popup. This message will only appear once when you accept it.\r\n

win2

\r\n

\r\nNow you are connected to your Server – as would you sit in front of it.\r\n\r\nwin3\r\n

Get a Key-Pair for ‘secure’ non pw connecting

\r\nTo make the connection to the server more comfortable you could use public key authentication. For our porpuses it would allow you (only you) to connect to the server without a password. The server and you basically will own a file that tells the server “okay let that guy in”. You own the private key and the server owns the public key. Someone without the private key can’t connect to the Server without password.\r\n\r\nWe will also take a look how to denied any connections without a private key – so you can’t log into your sever wihtout a private key anymore.\r\n\r\nTo generate your key pair you have to SSH into your server.  Type into the terminal:\r\n

$ ssh-keygen Enter file in which to save the key: Keep blank to use the default Enter passphrase: Keep blank [Enter] Enter same passphrase again: Keep blank again of course [Enter]

\r\nNow you have generated your key pair, move to the path where they are stored. Unless you did not changed default path type the following into the terminal to get in the default folder. The cd command will help you to move around your filesystem and set your current working directory. (Tip: cd .. will move to the parent directory) To make sure the keys are generated we will take a look at the files that are currently deployed in  your output directory. To get all visible files of a directory just type in ls. To see hidden and visible files you can use the -a parameter. When you want to list the output instead of having it side by side you can use the -l parameter. (Tip: you can combine parameters, so you could use ls -al)\r\n

$ cd ~/.ssh/ $ ls -l

\r\nYour output should look similiar to this\r\n

-rw——- 1 lsc lsc 1675 Jan 15 00:40 id_rsa\r\n-rw-r–r– 1 lsc lsc 392 Jan 15 00:40 id_rsa.pub

\r\nThe last step is let SSH know that we want to let connections in with our new key. When the file authorized_keys do not already exist you can just rename id_rsa.pub to allow this key. The command mv makes you able the move files around the systems, actually renaming a file is moving it. So move it from id_rsa.pub to authorized_keys\r\n

$ mv id_rsa.pub authorized_keys

\r\nWhen the file authorized_keys alread exists you have to append the content of id_rsa.pub to your authorized keys with catcat is a command that send the content of a file to the standard output in Linux. You can redirect the output with >  or >>. First will overwrite the content of an existing file while >> will append to an existing file.\r\n

$ cat id_rsa.pub >> authorized_keys

\r\nIn the last step we set the user permissions of our authorized keys to rw – read and writeable for the current userYou can find a brief explanation about the linux user permissions system here. When you are not familiar with the permission system I highly recommend to give it a read. The chmod command will set the user permissions to files and folders.\r\n

$ chmod 600 authorized_keys

\r\nWhen you have your key pair we need to get the private key id_rsa on our local machine. There are many ways to accomplish that – when you use Linux as your desktop computer you easily can use rsync. Replace user in the following statement with you username on the server  and replce localuser with the username on youre desktop computer. Now run it from your desktop computer. Also consider that you change the IP to you servers one.\r\n

$ rsync [email protected]:/home/user/.ssh/id_rsa /home/localuser/.ssh/ida_rsa_nas

\r\nWhen the directory .ssh was not found on your local system, create it and try to rsync our private key again.\r\n

$ mkdir ~/.ssh

\r\nNow you have to add the private key to your ssh setup on your local machine\r\n

$ ssh-add ~/.ssh/id_rsa

\r\nWhen you are running windows you can use WinSCP to connect SFTP and download the desired file from your server. It is the same process as downloading a file over the FTP procol. First you need to download WinSCP – you can use the portable version to avoid installing it.\r\n\r\nWhen you stared WinSCP select SFTP as protocol, fill in your credentials and click Login. Since we are connecting to a local server you can accept the following warning without any worries – basically this will tell us just that you never connected to this server.\r\n\r\n1\r\n\r\n2\r\n\r\nFine now you should be connected to your server. You start in the home directory of your user, so you just have to move into the .ssh folder. Now select the file id_rsa and click Download or press F5 this will prompt you the select a folder where you want to store the selected file. Save it anywhere you want but consider you will need this file to connect to your server. So keep it in a space where you won’t delete it accidentally.\r\n\r\n5\r\n\r\nThe next step is to produce a key in putty format from the openssh key. We need to download PuTTYgen from putty.org. Start PuTTYgen and click conversions -> Import Key. Select your downloaded private key and click on save private key. In the next step we need the newly created file, so remember where you saved it.\r\n\r\n1\r\n\r\nNow start PuTTY, we have installed it earlier. Select the connection we created and click on Load. On the left site navigate to connection -> SSH -> auth and browser for your private key.\r\n\r\n5 Now go back to session and press save. Now you should be able to connect to your server again.\r\n

Set up an shortcut to connect easily to your server

\r\nUnder Linux you can easily create a so called alias that just replaces a command with your alias. So you can set an alias like nas to connect to your nas server via SSH, just replace user and ip. Type the following into your remote computers terminal (Tip: usally you can open a terminal with CTRL + ALT + T)\r\n

alias nas=”ssh [email protected]

\r\nWhen you now type nas into your terminal the actual command ssh [email protected] will be executed. When you close the terminal this alias will be gone – to have it in every terminal session just edit the file ~/.bashrc and set the command from above at the end of the file.\r\n\r\nIn windows you can create a shortcut to your putty.exe. Right click the shortcut and press options. Add the following to the target but consider to replace Nas Server with the PuTTY profile you want to load.\r\n

 -load “Nas Server”

\r\nSo it should look similiar to this\r\n

C:\Users\LSC\Documents\ssh\putty.exe -load “Nas Server”

\r\nNow you are able to connect diretly to your server with your shortcut. When you want to enable auto-login load your profile in PuTTY and set your IP adress to [email protected] Don’t forget to save your profile otherwise it’s gone the next time you start PuTTY\r\n\r\nwin4\r\n

Make your Server ssh’able from the internet

\r\nWhen you want to connect to your server other the internet when you are not at home the first step is to forward your port for SSH in your router to your server. Here is a pretty detailed guide that explains how to accomplish that.\r\n\r\nThe default port for SSH is 22 on the TCP protocol –  but I recommend you to change it to some uncommon port since everyone would be able to connect to your server.\r\n\r\nTo change the port of your SSH server on Ubuntu you have the edit the file /etc/ssh/sshd_config\r\n

$ sudo vi /etc/ssh/sshd_config

\r\nIn line 5 change the port to your desired one. Check the list of common TCP ports before you choose a port.\r\n\r\nWhen you changed the port and saved the file restart your SSH server\r\n

$ sudo service ssh restart

\r\nTo connect to the server use the -p parameter in Linux\r\n

$ ssh -p 2224 [email protected]

\r\nIn PuTTY just edit the port field for you profile\r\n

\r\n

Get a static address to connect to your server

\r\nNow you should be able to connect to your server over the internet – but when you don’t have a static IP address (you would know if you would have one) it could be some effort to always have your current external IP of your network with you. Here comes NoIP that gives you a free domain that will always forward to your current IP. So you can easily connect to your server with always the same address.\r\n\r\nFirst go to noip.com and sign up. When you activated your account go to manage hosts in your administrator interface.\r\n\r\n1\r\n\r\nNow you should already see your adress from the registration process.\r\n\r\n2\r\n\r\nWhen you did not register an adress while you signed up add a host. Just leave the default settings, choose a domain name and add the host. That’s it now you could connect to your server with your new created domain.\r\n\r\nBut the tell NoIP that our IP have changed we need to set it up either in our router nor on our NAS server. When you want to use your rotuer to update NoIP please consider not every router will provide this feature – check the manual.\r\n\r\nWhen you need to set up the NoIP client on your server you need to compile it on your own. To compile software under Linux install the build-essentials\r\n

$  sudo apt-get install build-essential checkinstall

\r\nNow we have our compiler yet we need the actual NoIP package. Move to /usr/local/src/ and download the package. You can use wget – a simple but powerful command-line downloader – to download it.\r\n

$ cd /usr/local/src/ $ sudo wget http://www.no-ip.com/client/linux/noip-duc-linux.tar.gz

\r\nThe next step is to extract the downloaded package to your hard drive with tar. The xf parameters tells tar to read from an archive (f) and extract it to the hard drive (x)\r\n

$ sudo tar xf noip-duc-linux.tar.gz $ cd noip-2.1.9-1/

\r\nFinally we will build and install the packe with make\r\n

$ sudo make install

\r\nFirst you need to enter your credentials from noip.com\r\n

Please enter the login/email string for no-ip.com [email protected] Please enter the password for user ‘[email protected]’ **********

\r\nIn the last step of the installation you will be aksed for an update interval and if you wish to start a process after a sucessful installation. You could run for example a script Pushover notification that will inform you when you have a new IP address. The values between the square brackets are default values – that means when you dont enter anything and press enter theses values will be taken\r\n

Please enter an update interval:[30] 15 Do you wish to run something at successful update?[N] (y/N)

\r\n \r\n\r\nNow you are able to connect to your server. The next steps will be setting up your data drives, SMB, NFS network shares, a MySQL database, an FTP Server and much more.  When you have anything that you want to read about feel free to request it in the comments. Check back for new posts coming soon.\r\n
\r\n

\r\n

\r\n

\r\n

\r\n

\r\n

\r\n

\r\n

\r\n

<< Previous: Operating System << Contents >> Next: Software>>