In the previous post, we saw how to setup secure access to linux box using SSH server. In this post, we are going to setup the linux box as a NAS (Network Attached Storage) server and make it accessible to other clients on the network. For setting up the NAS server, we need to install SAMBA server which will magically make the linux server available to other computers on the network.
Fire up PuTTY to log into linux server via SSH, and run the following command to install SAMBA server
sudo apt-get install samba smbfs
Once SAMBA is installed, we need to start the service (if not started automatically) and configure share and access to the linux box.
Before we start running the service, we need to configure what directories we want to share and who would have access to it.
The smb.conf file is the main configuration file present in /etc/samba.
Edit the file using the your favourite editor:
sudo gedit /etc/samba/smb.conf
Look for the following section in the file:
; security = user
Change it to look like this
security = user username map = /etc/samba/smbusers
Next, we need to create SAMBA users and link them to actual linux user logins. Run the following command and enter the desired username:
sudo smbpasswd -a <username>
Next, add the selected username to the smbusers file in the format <ubuntu_username> = “<samba username>”
sudo gedit /etc/samba/smbusers
Once this is done, now let us configure which directories to share. Basically, SAMBA allows us to share user’s home directory with minor configure. We can share more directories as required. We can also share a printer attached to the linux box.
In order to share user’s home directory, open /etc/samba/smb.conf and uncomment the following line:
comment = Home Directories
browseable = yes
By default, anyone having access to SAMBA can connect to any home directory. If we want to restrict access to their own home directory, uncomment the following line:
valid users = %S
By default, the home directories are read-only. You can make them writable using :
writable = yes
Now, start the SAMBA service by running the following command:
sudo /etc/init.d/samba start
Now, try to access the SAMBA share as \\linuxservername\username
There are more options in the smb.conf which can be modified to tweak access to directories, share more directories, printers etc.
In the next post, I’ll show you how to setup remote desktop access to the headless linux box.