Tuesday, February 22, 2011

How to install and configure samba

Enterprise Linux: Samba HowTo [ID 416921.1]
Modified 31-AUG-2007 Type HOWTO Status PUBLISHED
In this Document
Goal
Solution

Applies to:

Linux Kernel - Version: 2.6.9
Linux x86
Goal

How to install and configure samba
Solution

Enterprise Linux: Samba HowTo

Contents:
1. Brief
2. Step by step installation and configuration
3. Service/Server management
4. Problem diagnosis: logs, diagnostic tools,etc
5. Reference also to
6. Samba Client Configuration and Use
7. Reference

1. Brief

To provide printer and file sharing, Microsoft Windows uses a facility known as SMB (Server Message Block). This same facility is sometimes known as NetBIOS or LanManager. Thanks to Andrew Tridgell and others, Linux systems provide support for SMB via a package known as Samba. Like SMB, Samba lets you:
* Share printers and files among Microsoft Windows, OS/2, Netware, and Unix systems
* Establish a simple nameserver for identifying systems on your local area network
* Backup PC files to a Linux system and restore them
* Administer users and passwords

Samba has proven its reliability and high performance in many organizations. According to the online survey at http://www.samba.org/pub/samba/survey/ssstats.html, Bank of America is using Samba in a configuration that includes about 15,000 clients, and Hewlett-Packard is using Samba in a configuration that includes about 7,000 clients.


Samba is an Open Source/Free Software suite that has, since 1992, provided file and print services to all manner of SMB/CIFS clients, including the numerous versions of Microsoft Windows operating systems. Samba is freely available under the GNU General Public License.

Samba software suite on Enterprise Linux is a collection of programs that implements the Server Message Block (commonly abbreviated as SMB) protocol for UNIX systems.


2. Step by step installation and configuration
2.1 Download Samba and installation:
1. Download the binary samba rpm package from ftp://ftp.sernet.de/pub/samba

Select the platform of your box. I select rhel4-i386 as my platform and show installation and configuration steps below:
ftp://ftp.sernet.de/pub/samba/rhel4-i386/libsmbclient-3.0.24-30.i386.rpm
ftp://ftp.sernet.de/pub/samba/rhel4-i386/samba3-client-3.0.24-30.i386.rpm
ftp://ftp.sernet.de/pub/samba/rhel4-i386/samba3-3.0.24-30.i386.rpm

2. mkdir /tmp/samba
3. download the rpm file to /tmp/samba
4. rpm -Uvh /tmp/samba/*.rpm

2.2 Installation from ULN

In Enterprise Linux system,SAMBA include as followed rpm packages:
samba-*
samba-common-*
system-config-samba-*
samba-client-*
You can install above packages from the Enterprise Linux CD/DVD media or via up2date get those from Oracle Unbreakable Linux Network(ULN) repository.

2.3 Configuration for file sharing

Samba's configuration is stored in the smb.conf file, which usually resides in /etc/samba/smb.conf .

2.3.1 smb.conf example

[global]
workgroup = mygroup
log file = /var/log/samba/%m.log
max log size = 500
encrypt passwords = yes

[homes]
comment = Home Directories
browseable = no
read only = no


[Music]
path = /data/mp3
public = yes
read only = yes
write list = @kate

2.3.2 smb.conf parameters
2.3.2.1 Configuring global variables

[Global Parameters]
workgroup = mygroup : 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.

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


2.3.2.2 Configuring Share variables

[Share Parameters]

[homes]
comment = Home Directories
browseable = no
read only = no

[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\kate (this is my username on Linux and Samba) This share /home/kate is browseable only by you. Remember this is much the same as the "My Documents" folder in Windows


[Music]
path = /data/mp3
public = yes
browseable = yes
read only = yes
write list = @kate

[Music] This will create a share for mp3 storage. Again lets go over the share parameters for this.

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 in Network Neighborhood as "Music"

public = yes: Specifies anyone can access and view the contents of /data/mp3

write list = kate:

Although anyone can view and excute (meaning see and play any mp3 in this directory). For security and practical reasons I have set this share so that only kate (thats me) can delete or add files. You can add as many names as you wish to this line ie:, john 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.

In order for Samba to accomplish all this we need to set certain Linux file permissions such as these. This can be done by opening your file manager (in this case Konqueror) and right clicking on the /data/mp3 share and choosing properties

3. Service/Server management

3.1 Adding Users and Restarting Samba

example:
1. adduser kate
useradd -d /home/kate kate
2. init kate's password
passwd kate
3. init kate's smbpasswd
smbpasswd -a kate
4. /etc/init.d/smb restart


4. Problem diagnosis: logs, diagnostic tools,etc

4.1 diagnostic tools

To verify that the parameters are correct in the smb.conf file or to debug configuration problems, use the testparm command.

4.2 logs

For debugging problems with Samba in general, the log files log.smbd and log.nmbd under the /var/log/samba directory are invaluable.
The parameter log level in the global section of the smb.conf file determines the amount of detailed information Samba writes to the log files, with level 0 being the most general and 10 being the most detailed. Each logging level contains the messages from that level, in addition to the logging messages below it. For example, a logging level of 5 contains messages from level 5, plus those from levels 0 through 4.

# this tells Samba to use a separate log file for each machine
# that connects
log file = /var/log/samba/%m.log
debuglevel = 4


5.Reference also to:

man samba
man 8 smbd
man 5 smb.conf

6. Samba Client Configuration and Use

example :Microsoft Windows Client
Microsoft Windows 3.11, 9x, and NT have built-in support for the SMB protocol, so systems running these operating systems can easily access your Samba server's resources. Under Microsoft Windows 9x and NT, you can access Samba resources by using the Windows Explorer. Log on using a userid that's authorized to access Samba resources. Then click on Network Neighborhood and you should see a subtree that corresponds to your Samba server. By expanding the subtree, you can see the browseable file and printer shares that are available. You can easily drag and drop files to and from a shared directory, assuming your userid is permitted the necessary access.

7. Reference
http://us4.samba.org/samba/
http://en.wikipedia.org/wiki/Samba_software

No comments:

Post a Comment

Post a Comment