Friday, February 24, 2012

SAMBA Server

SAMBA Server Configuration

Descriptions:

The presence of linux workstation in a network will invariable demand the need for allowing remote file access in between systems. Samba is a solution that is used to enable UNIX-Windows file sharing. Readers implements a samba server in the network so that other users of the LAN can leverage the functionalities of network file sharing.

Introduction:

  • Samba is a suite of programs running under UNIX-like operating systems that provide integration between unix and windows machines. Samba uses server Server Message Block ( SMB ) protocol which is the underlying protocol used in Microsoft Windows Networking.

  • For many networks samba can provide a complete replacement for windows NT servers, although it does not provide the full range of functionality provided by Active Directory under Windows Server 2000 and Windows server 2003.

  • Samba can also register itself with the master browser on the network so that it would appear in the listing of hosts in windows 95/NT "neighborhood network". In fact, samba itself can act as the master browser ( domain controller ) on the network.

  • Samba can also use LDAP ( Lightweight Directory Access Protocol ) as backend database for storing machine and user account details.

  • Another standard feature of Samba is an ftp like SMB client which allows you to access shared PC resources such as disk or folders and printers.

Packages that are required to have Samba system in the system are shown below.


Package
Description
Samba-*
Basic Samba Server Package
Samba-client-*
This package allows you to setup your linux computer to read shared Microsoft Printers
Samba-common-*
This package includes files required to support Linux as a Samba client and as a samba server.
Samba-swat-*
This GUI tool lets you modify the main samba configuration files.


Configuring a share :

To analyze the way directory are share from the packaged 'smb.cong' configuration. There are 8 examples of shared directories in the standard 'smb.conf' file.

SAMBA Linux to Windows Sharing 

Setup the shares in /etc/samba/smb.conf by editing it as follows
[share1]  -----------------------------------------------------> This is the share name
          comment = share from linux box  ----> A description of the share
          path = /path/to/shared/directory -----> Path to the shared directory
          read only - yes/no ----------------------------> Permissions to the directory
          vaild users = user --------------------------->  User name
          browse able = yes/no ----------------------> Permission to list contents of the  
                                                                       directory
 If you want to share CD/DVD drive
[DVD]
         comment = dvd drive on linux box
         writable = no
         locking =  no
         path = /mount/point/of/dvd
         valid users = user1 ( user name )

Checking the configuration file for errors:
  • After editing the 'smb.conf' file to add the shares that you need, we check it for consistency and syntactic errors.
  • At the shell type:
#testparm
  • this command reads through the configuration file and display errors if any.

Adding Users:
At this stage, we are almost done. To access Samba shares, evey user needs to have a userID and password. Bear in the mind that this userID and passwd is different from the log-in ID that the users uses to log in to the system.
Open your terminal windows and type in the following:
#useradd user1
#passwd user1
changing password for user user1
NEW UNIX password:
Retype new UNIX password:
passwd: all authentication tokens updated successfully

#smbpasswd -a user1
NEW SMB password:
Retype new SMB password:
Added user user1

The same username and password that you log onto to the windows PC with. 
When you create a new linux user, it will automatically create a home share for this person. In this case it will be /home/user1.
Now Samba has to be restarted so that all of the changes that we have made will take effect. For starting that samba services use the following command in the command prompt.

#/etc/init.d/smb restart OR
#/etc/init.d/smb start

Accessing the shares via GUI:
                     Accessing shares from a windows machine.
  • Click Start|Run.
  • In the prompt type \\192.168.0.1\share1. 192.168.0.1 is the IP address of the linux machine.
Accessing shares from a linux machine.
  • Open a file browser like nautilus or knoqueror.
  • Type 'smb://192.168.0.1/share1' and press enter to access the share.

Accessing the shares via command line in Linux:
you can access share available from linux machine by mounting the share as your local directory. For mounting use  the following command on the client linux machine.
#smbmount //linuxserver/share name /home/user1 -o username= test password:


                                                     OR
$smbclient  //linuxserver/sharename -u username 
password:
smb:/>

Note:
To access the smb share via a remote machine, we need  to know the username and password on the remote samba server machine.

Global Parameters
[global]
Anything in here applies to samba as a global setting. There is some configuration info here that is important so that samba and your windows pc's will function properly. However some global settings can be overridden by share settings ( more on this later). I will now go through each line and give a brife description of what role it plays in Samba.

workgroup = home
This is the name of your network group. It is important that both samba and windows are in the same workgroup. Please read your windows documentation on how to change your windows pc's workgroup name.

netbios = Samba
Netbios name is what you will see in your windows pc "Network Neighborhood"
for your Samba server. You can name this anything you wish. If you leave it blank, it will default to your host name.

encrypt passwords = yes
Samba can work with encrypted or unencrypted passwords. However windows 98, Windows NT,2000 utilize encrypted passwords. The only time this should be set to no is when you have any older windows systems running on your network ie: Windows 95,3.x if this is the case you will have to do some registry modifications to your windows 98, NT , 2000 to allow them to send unencrypted passwords across the network. Not the most secure situation though.

Share Parameters
[homes]
 When you create a user on your linux pc ( more on this later ) it will automatically create a home folder for you in /home/yourusername. Think of this as your "My Documents" for linux.
read only = no
By default samba will always make any directory read only for security reasons, so we need to let samba know that we want to be able to write to this directory.
browseable = no: defines when you map a network drive to samba, it will map directly to your user directory ie: \\home\mw ( this is my username on linux and samba ) This share /home/mw is browseable only by you. Remember this is much the same as the " My Documents" folder in windows.
path = /data/mp3
This tells us the directory is found on the samba server as /data/mp3, later when we map the network drive on the windows pc, it will be seen as "music" in Network Neighborhood.
browseable = yes
This share will show in network neighborhood as " Music "
Public = yes
Specifies anyone can access and view the contents of /data/mp3
write list = user1
Although anyone can view and excute ( meaning see and play any mp3 in this directory ). For security and practical reason i have set this share so only mw     ( thats me )  and jackie can delete or add files. You can add as many names as you wish to this line ie: , mw, john, tiffany etc. To exclude any person from being  able to access this share altogether, add the line: invalid users = vicky, steve. These names are the logon names from windows and are not case sensitive. They also must have a logon name and samba password on the linux pc.


No comments: