Search This Blog

Thursday, July 29, 2010

SAMBA Configuration in linux.

This Article is based Following Redhat release.
# lsb_release -a
LSB Version: :core-3.1-ia32:core-3.1-noarch:graphics-3.1-ia32:graphics-3.1-noarch
Distributor ID: EnterpriseEnterpriseServer
Description: Enterprise Linux Enterprise Linux Server release 5.2 (Carthage)
Release: 5.2
Codename: Carthage


For a simple installation and configuration following steps are taken.

1)Install samba packages necessary for samba installation.
2)Start the samba service at runlevel(Optional).
3)Create Samba users.
4)Setting the password for samba user.
5)Edit configuration file accordingly.
6)Restart the samba service.

1)Install samba packages necessary for samba installation.
First check to see if samba server is installed or not.

# rpm -q samba
package samba is not installed

However you can find samba client installed on most of Linux Distributions.

# rpm -qa | grep samba
samba-common-3.0.28-0.el5.8
samba-client-3.0.28-0.el5.8

{
Note: If you dont get any client and common rpm you might need to explicitly install them.
You might need to install cups-libs-1.2.4-11.18.el5.i386.rpm as a dependency for above 2 packages.
}

To get the samba server package the best place to for is your Distribution disk.
I have searched my OS disk and found following package for samba.
samba-3.0.28-0.el5.8.i386.rpm

install the above package on the system using.
# rpm -ivh samba-3.0.28-0.el5.8.i386.rpm


After successful installation just run “rpm –q samba “ To check if samba is installed or not.
# rpm -q samba
samba-3.0.28-0.el5.8

Samba configuration file is stored at following location.
/etc/samba/smb.conf


2)Start the samba service at runlevel(Optional).
Samba service name.
smb

To start samba service at system starup use chkconfig command.

To check the current runlevel of smb service.
# chkconfig --list | grep smb
smb 0:off 1:off 2:off 3:off 4:off 5:on 6:off

To start the service at system startup use.
#chkconfig --level 345 smb on

reconfirm with below command.

# chkconfig --list | grep smb
smb 0:off 1:off 2:off 3:on 4:on 5:on 6:off

restart the machine and check the smb service status.
# service smb status
smbd (pid 4712 4671) is running...
nmbd (pid 4684) is running...


3)Create Samba users.

First, lets create the smbpasswd file that we defined in the smb.conf file. The best way to go about this is to create it based on your existing /etc/passwd file. In other words, samba users are created based on existing linux users:
#cat /etc/passwd | mksmbpasswd.sh > /etc/samba/smbpasswd

after execution a new file will be created under /etc/samba directory.

lmhosts passdb.tdb secrets.tdb smb.conf smb_orig.conf smbpasswd smbusers

4)Setting the password for samba user.

the password for samba user is not similar to existing system users.
We need to manually set the samba user.
# smbpasswd root
New SMB password:
Retype new SMB password:

5)Edit configuration file accordingly.
Now its time to edit samba configuration file .
Take a backup of original file using.
# cp /etc/samba/smb.conf /etc/samba/smb_orig.conf

For the very simple configuration file i will recommend to backup the configuration file and create a new one.
#mv /etc/samba/smb.conf /etc/samba/smb.conf.old
following values to newly created configuration file .

*************************************************************

[global]
workgroup = PUTIEVILLE
server string = My Lil Linux Box
hosts allow = 192.168. 127.
log file = /var/log/samba/%m.log
security = user
encrypt passwords = yes
smb passwd file = /etc/samba/smbpasswd
socket options = TCP_NODELAY SO_RCVBUF=8192 SO_SNDBUF=8192

[Downloads]
comment = Downloads
path = /
browseable = yes
writable = yes
public = yes
read only = no

[homes]
comment = My Home Directory
browseable = yes
writable = yes
public = yes
read only = no

[printers]
path = /var/spool/samba
public = yes
guest ok = yes
printable = yes
browseable = yes
writable = yes
read only = no
******************************************************
Description of Samba Configuration file:
[global]
hosts allow = 192.168. 127.
This line will allow samba server accessible from 10.180.18 series and localhost .

smb passwd file = /etc/samba/smbpasswd
This will tell samba to use smbpasswd file from mentioned location

[Downloads]
comment = Downloads
Name of the share
path = /
Path that should be made available for all.

make read only = yes if you dont want others to write anything .

Make sure the samba user you create has a read access on the shared files(If this fails you assign ownership to samba user this is not recommended )

6)Restart the samba service.
#service smb restart
and access the files through windows login.







++++++++++++++++Additional Information+++++++++++++++++++++
You may get such error if /etc/samba/smb.conf file doesn't exists .(I renamed it /etc/samba/smb.conf.bkp ) i have created a dummy file using touch /etc/samba/smb.conf and the command run successfully.
# smbpasswd root
Can't load /etc/samba/smb.conf - run testparm to debug it

You may get below errors if you try to set a weak samba password for root account.
(This may be distribution specific and the chances of you not getting this error is more.Mine is harden for security reason ). you will not get the error if you set a strong password.
# smbpasswd root
New SMB password:
Retype new SMB password:
account_policy_get: tdb_fetch_uint32 failed for field 1 (min password length), returning 0
account_policy_get: tdb_fetch_uint32 failed for field 2 (password history), returning 0
account_policy_get: tdb_fetch_uint32 failed for field 3 (user must logon to change password), returning 0
account_policy_get: tdb_fetch_uint32 failed for field 4 (maximum password age), returning 0
account_policy_get: tdb_fetch_uint32 failed for field 5 (minimum password age), returning 0
account_policy_get: tdb_fetch_uint32 failed for field 6 (lockout duration), returning 0
account_policy_get: tdb_fetch_uint32 failed for field 7 (reset count minutes), returning 0
account_policy_get: tdb_fetch_uint32 failed for field 8 (bad lockout attempt), returning 0
account_policy_get: tdb_fetch_uint32 failed for field 9 (disconnect time), returning 0
account_policy_get: tdb_fetch_uint32 failed for field 10 (refuse machine password change), returning 0

No comments:

Post a Comment