Search Suggest

Samba Server Installation and configuraiton in CentOS – 6

What is Samba Server ?

"Samba is an Open Source/Free Software suite that provides file and print services to SMB/CIFS clients."
It provides an easy way to share  directory over Linux And Windows environment.

Benefites of using Samba Server
·        
  •     File and printer sharing with MS Clients
  •         Provides user Authentication and access
  •          Name resolution
  •          Browsing
  •          Support on various platform
  •          Can act as a Domain  controller


Samba Server Package use

Package Name
Package Description
Samba
Use for samba server
samba-client
Use for samba client
samba-common
Commands which use in samba server and client 


Component of samba server

testparm : This command is use to test the samba configuration file.
smbstatus: This comand is use to check the current connection of samba client.
smbpasswd:  This command is use to set the password of samba user.

Samba Server details:

Operating system: CentOS – 6.5
Server IP Address:  192.168.0.62
Hostname : server.openpath.in
Config file : /etc/samba/smb.cnf
Service : smb
Port no : 137,138,139,445
Selinux : Disabled

Samba client details:

Operating system: Windows 7
Hostname: client01
IP Address : 192.168.0.95 

Install package on samba server

[root@server ~]# yum install samba samba-client samba-common

Check Installed package

[root@server ~]# rpm -qa | grep samba
samba-winbind-3.6.23-14.el6_6.x86_64
samba4-libs-4.0.0-58.el6.rc4.x86_64
samba-winbind-clients-3.6.23-14.el6_6.x86_64
samba-3.6.23-14.el6_6.x86_64
samba-common-3.6.23-14.el6_6.x86_64
samba-client-3.6.23-14.el6_6.x86_64

Create Share directory and give permission


[root@server ~]# mkdir /data && chmod 777  /data


Add user for authentication


[root@server ~]# useradd test1
[root@server ~]# useradd test2

Set password

[root@server ~]# smbpasswd -a test1
[root@server ~]# smbpasswd -a test2

Take backup of samba configuration file


[root@server ~]# cp /etc/samba/smb.conf /etc/samba/smb.conf.bak


Configure Samba server configuraiton file


[root@server ~]# vim /etc/samba/smb.cnf

## IPRange allowed in network##
hosts allow = 127. 192.168.0.
##Add following lins at bottom##
[data]
comment = "Data shared Folder"
path = /data
browsable =yes
writable = yes
read only = no
valid users = test1,test
Veto files = /*.exe/*.com/*.dll/*.sh/*.py/*.inf/*.reg/*.mp3/*.rm/*.flv/*.mp4/*.avi/*.pdf/


Restart samba service

[root@server ~]# /etc/init.d/smb restart
Shutting down SMB services:                                [FAILED]
Starting SMB services:                                           [  OK  ]


On Samba service permanently

[root@server ~]# chkconfig smb on

Test the configuration file

[root@server ~]# testparm
Load smb config files from /etc/samba/smb.conf
rlimit_max: increasing rlimit_max (1024) to minimum Windows limit (16384)
Processing section "[homes]"
Processing section "[printers]"
Processing section "[data]"
Loaded services file OK.
Server role: ROLE_STANDALONE
Press enter to see a dump of your service definitions

[global]
        workgroup = MYGROUP
        server string = Samba Server Version %v
        log file = /var/log/samba/log.%m
        max log size = 50
        idmap config * : backend = tdb
        hosts allow = 127., 192.168.0.
        cups options = raw

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

[printers]
        comment = All Printers
        path = /var/spool/samba
        printable = Yes
        print ok = Yes
        browseable = No

[data]
        path = /data
        comment = "Data shared Folder"
        valid users = test1, test2
        read only = No


Acces Share directory from client machine
Go to Start -> Run -> \\serverip_address


Type user name and password
Uername : test or test2
Password: ******



You can share more directory in samba server and can give access to defferent user.

Create directory name as common-data

[root@server ~]# mkdir /common-data

Create user for authentication

[root@server ~]# useradd user1
[root@server ~]# useradd user2

Set password for authentication

[root@server ~]# smbpasswd -a user1
[root@server ~]# smbpasswd -a user1

Set permission in share directory using ACL

[root@server ~]# setfacl -m user:user1:rwx /common-data/
[root@server ~]# setfacl -m user:user2:rwx /common-data/

[root@server ~]# vim /etc/samba/smb.conf


Add below line in config file

[common-data]
comment = "common-data shared Folder"
path = /common-data
writable = yes
browseable = yes
read only = no
valid users = user1,user1


Restart service after updating samba config file

[root@server ~]# /etc/init.d/smb restart

Acces Share directory from client machine
Go to Start -> Run -> \\192.168.0.62

Disable Home Directory of user in Samba

#vim /etc/samba/smb.conf

[homes]
        comment = Home Directories
        browseable = no
        writable = yes

#service smb restart

Login Samba user Cli

# smbclient //localhost/userrname  -U username

Show Active User

# smbstatus

List Samba User

# pdbedit -w –L

Delete Samba User

# smbpasswd -x username

Disable Samba User

# smbpasswd -d username

How to import and export samba user and password

Export Samba User and Password

# pdbedit -e smbpasswd:/tmp/sambabak

Import Samba user backup and password


# pdbedit -i smbpasswd:/tmp/sambabak

Note: UID of user should be according to new server.


Đăng nhận xét