client side windows
user
: tecmint
passwd:
123456
clint side linux
connect to server
server ip:XXX
share: tecmintusers
username: tecmint
Setup
Samba Server Using tdbsam Backend on RHEL/CentOS 6.3/5.8 and Fedora 17-12
Samba is an open source and most popular widely used program that
enables end users to access Linux shared directory from any windows
machine on the same network. Samba is also named as a network file system and
can be installed on Linux/Unix operating systems. Samba itself is a
client/server protocol of SMB ( Server Message Block) and CIFS (Common
Internet File System). Using windows smbclient (GUI) or file
explorer, end users can connect to Samba server from any windows workstations
to access shared files and printers.
Samba Server Setup
This tutorial explains how to setup Samba
Server (fileserver) Using tdbsam Backend on RHEL 6.3/6.2/6.1/6/5.8, CentOS 6.3/6.2/6.1/6/5.8 and Fedora 17,16,15,14,13,12 systems and also we
will learn how to configure it to share files over the network using SMB
protocol, as well as we will see how to create and add system users on samba
user’s database.
1.
Preliminary Note
We are using RHEL 6.3 system
with hostname tecmint with IP address 172.16.25.126.
2.
Disable SELinux
First, check whether SELinux
is currently enabled or disabled with following command.
#
selinuxenabled && echo enabled || echo disabled
enabled
In our case, SELinux is
currently enabled, so we need to disabled it under RHEL/CentOS/Fedora
systems, open file called /etc/selinux/config with your choice of
editor. ( Ignore this step, if SELinux is already disabled ).
#
vi /etc/selinux/config
And change the line that says SELINUX=enabled
to SELINUX=disabled and reboot the system.
#
This file controls the state of SELinux on the system.
#
SELINUX= can take one of these three values:
# enforcing - SELinux security policy is
enforced.
# permissive - SELinux prints warnings
instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled
#
SELINUXTYPE= can take one of these two values:
# targeted - Targeted processes are
protected,
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
3.
Rebooting System
Here, we will need to reboot the
system to re-lable entire file system in the boot process. This reboot process
can take some time, depends on the volume of files.
#
init 6
Once the system comes to login
prompt, login with root user and start installing Samba package.
3.
Installing Samba
We use YUM package manager tool to install Samba packages.
#
yum install samba samba-common cups-libs samba-client
4.
Configure Samba with tdbsam Backend
Once samba installed successfully,
now time to configure it using tdbsam password backend. Open file /etc/samba/smb.conf.
#
vi /etc/samba/smb.conf
And check for the following lines in
the Standalone Server Options section. This line enables users to login
into Samba server.
#
----------------------- Standalone Server Options ------------------------
#
#
Scurity can be set to user, share(deprecated) or server(deprecated)
#
#
Backend to store user information in. New installations should
#
use either tdbsam or ldapsam. smbpasswd is available for backwards
#
compatibility. tdbsam requires no further configuration.
security =
user
passdb
backend = tdbsam
5.
Creating Samba Share Directory
Now, we will create Samba
share directory for sharing files for all users. Run the following commands.
#
mkdir -p /home/sambashares/tecmintusers
#
chown -R root:users /home/sambashares/tecmintusers
#
chmod -R 775 /home/sambashares/tecmintusers
6.
Configuring Samba Share Directory
Add following lines at the bottom of
the file /etc/samba/smb.conf.
[tecmintusers]
comment = All Users
path = /home/sambashares/tecmintusers
valid users = @users
force group = users
create mask = 0660
directory mask = 0771
writable = yes
7.
Creating Samba Start-up Links
Create system start-up links for
Samaba.
#
chkconfig --levels 235 smb on
8.
Restarting Samba Server
Now restart Samba server.
#
/etc/init.d/smb restart
9.
Creating Samba Users
We will create a user called tecmint
and set password to it.
#
useradd tecmint -m -G users
#
passwd tecmint
Now add newly created user tecmint
to Samba user database and set password for him.
#
smbpasswd -a tecmint
This way you can create as many as
users you want, just replace the username tecmint with the desired
username.
10.
Verify Samba Server Share
Verify Samba share directory within
Linux system using smbclient package with -L option. It will
display list of available samba share directories on the host tecmint.
#
smbclient -L tecmint
Domain=[MYGROUP]
OS=[Unix] Server=[Samba 3.5.10-125.el6]
Sharename Type
Comment
--------- ----
-------
tecmintusers Disk
All Users
IPC$ IPC IPC Service (Samba Server Version
3.5.10-125.el6)
Anonymous
login successful
Domain=[MYGROUP]
OS=[Unix] Server=[Samba 3.5.10-125.el6]
Server Comment
--------- -------
Workgroup Master
--------- -------
Try to login into Samba share
directory under Linux system using username as tecmint with password.
#
smbclient -L //tecmint/tecmintusers -U tecmint
Enter
tecmint's password:
Domain=[MYGROUP]
OS=[Unix] Server=[Samba 3.5.10-125.el6]
Sharename Type
Comment
--------- ----
-------
tecmintusers Disk
All Users
IPC$ IPC IPC Service (Samba Server Version
3.5.10-125.el6)
tecmint Disk Home Directories
Domain=[MYGROUP]
OS=[Unix] Server=[Samba 3.5.10-125.el6]
Server Comment
--------- -------
Workgroup Master
--------- -------
11.
Login to Samba Server from Windows
Now try to login from your Windows
system, open Windows Explorer and type the address \\172.16.25.126\tecmint
and enter username as tecmint and password, you will see tecmint’s
home directory. Refer screenshot below.
Now to share Samba shared directory
type address as \\172.16.25.126\tecmintusers. You will see similar to
below.