Recently I have changed over my main server to Debian 6.0 running the LXDE desktop. I have a requirement to share my main files across the network to both Windows and Linux machines and because of this I will be using Samba.
The steps outlined in this tutorial should work if you have a desktop environment installed (in my case LXDE) or not.
First thing we need to do is set a static ip address for our server. Once we have that setup it is time to download and install the packages we need – smbfs, samba and smbclient.
Open up a terminal and type:
sudo apt-get install samba
Type your root password when prompted. You will be asked to provide a Workgroup name during installation.
Now install smbfs by typing:
sudo apt-get install smbfs
and then type your root password again.
Finally install smbclient by typing:
sudo apt-get install smbclient
We now have to configure the smb.conf file which contains all the samba settings. In a terminal type:
sudo nano /etc/samba/smb.conf
Locate the line WORKROUP = ********* and check that it is set to the name you entered when installing samba (Mine was set to HomeServer_01).
Now at the end of the file add the following text:
[Shared_Files] (This is the name of your share – change as appropriate)
path = /home/chris (This is the network path to your share – change as appropriate)
available = yes
browsable = yes
public = yes
writable = yes
comment = shared files
Save the file and exit.
Now we have to add users to the smbpasswd file which is located at /etc/samba/smbpasswd. Only users specified in the smbpasswd file will be able to access your samba shares. Open a terminal and type:
sudo smbpasswd -a user (where user is the name of the person allowed to access the shares)
When prompted enter their new password twice.
We now need to restart the samba service so in a terminal type:
sudo service samba restart
Now we have to check the configuration so far. In a terminal type:
Testparm will tell you if there are any errors in your configuration. If everything is Ok then type:
smbclient -L 10.0.0.1 (where 10.0.0.1 is the ip address of your samba server).
This will show you the list of all your available samba shares. At this point if you have no errors your server is configured correctly.
Install samba and smbfs either using the package manager or the command line. You will need to set the Workgroup parameter in the smb.conf file to the same value as you entered on the server (in my case HomeServer_01).
Then we have to mount the available shares. First decide where you are going to mount them. I will mount them in /media/dev/share but first I will have to make the directory dev so:
sudo mkdir dev
and then ls which should show us the new dev directory in media. Now time to mount the shares.
sudo mount -t smbfs //10.0.0.1/(share name) /media/dev/share where 10.0.0.1 is the ip address of your samba server. This will mount the share but only as long as you are logged in. To make the link persistent you need to enter the following line into /etc/fstab.
//10.0.0.1/(share) /media/dev/share cifs username=user,password=pass,user,rw,noatime 0 0
We have to change the workgroup to the same value as the Debian server (Home Server_01 in this case) and then add the ip address of the samba server to the hosts file (must open as administrator).
Once this is complete map the shares to your computer.
Word of warning here about firewalls. Either turn them off or add exception rules for traffic on ports 137-139 and 445.
About the Author
Hi I am Chris Wakefield the owner of ComTech IT Support. I provide Windows and Linux based IT Support, laptop repairs and computer repairs to both business and personal clients in and around Stirling.
For a list of what I can offer you why not visit my website www.comtech247.net where you will find a list of my services, testimonials, blog and much more.