Samba service configuration tutorial and samba configuration tutorial
I. Install samba
Disconnect the shared connection in the window: net use */d/y. Do not use win8 as the client.
[Root @ localhost ~] # Service iptables stop
[Root @ localhost ~] # Vi/etc/sysconfig/selinux
SELINUX = disabled \ restart the system
Or
[Root @ localhost ~] # Setenforce 0 \ restart not required
[Root @ localhost ~] # Rpm-qa | grep "^ samba"
Samba-common-3.6.9-164.el6.x86_64
Samba-client-3.6.9-164.el6.x86_64
Samba4-libs-4.0.0-58.el6.rc4.x86_64
Samba-winbind-3.6.9-164.el6.x86_64
Samba-winbind-clients-3.6.9-164.el6.x86_64
[Root @ localhost ~] # Mount/dev/cdrom/media/cdrom
[Root @ localhost Packages] # rpm-ivhsamba-3.6.9-164.el6.x86_64.rpm
[Root @ localhost Packages] # cd
[Root @ localhost ~] # Service smb start
Start the SMB service: [OK]
[Root @ localhost ~] # Service nmb start
Start NMB service: [OK]
[Root @ localhost ~] # Netstat-anptu | grep "mbd"
Ii. Build a shared service
1: Shares that can be accessed anonymously
[Root @ localhost ~] # Grep-v "#"/etc/samba/smb. conf | grep-v "^;" | grep-v "^ $"
[Global]
Workgroup = MYGROUP
Serverstring = Samba Server Version % v
Logfile =/var/log/samba/log. % m
Maxlog size = 50
Security = user
Passdbbackend = tdbsam
Loadprinters = yes
Cupsoptions = raw
[Homes]
Comment = Home Directories
Browseable = no
Writable = yes
[Printers]
Comment = All Printers
Path =/var/spool/samba
Browseable = no
Guestok = no
Writable = no
Printable = yes
[Root @ localhost ~] # Testparm
[Root @ localhost ~] # Vi/etc/samba/smb. conf
74 workgroup = WORKGROUP
101 security = share
Compared with SAMBA 3, samba4 has a major change: security does not support share and the parameters need to be adjusted.
Originally:
Security = share
Now:
Security = user
Map to guest = Bad User
289 [rhel6]
290 comment = REHL6.5 DVD
291 path =/media/cdrom
292 public = yes
293 read only = yes
[Root @ localhost ~] # Service smb restart
2: Verify with a windows Host
3: User-verified sharing
[Root @ localhost ~] # Useradd vina \ Add a system user
[Root @ localhost ~] # Pdbedit-a-u vina \ Add a shared user; pdbedit-x-uvina Delete
[Root @ localhost ~] # Pdbedit-L \ list samba users
[Root @ localhost ~] # Pdbedit-vL vina \ View Details
[Root @ localhost ~] # Useradd zhangsan
[Root @ localhost ~] # Useradd lisi
[Root @ localhost ~] # Pdbedit-a-u zhangsan
[Root @ localhost ~] # Pdbedit-a-u lisi
[Root @ localhost ~] # Mkdir/opt/mytools \ create a shared directory
[Root @ localhost ~] # Touch/opt/mytools/gongxiang
[Root @ localhost ~] # Vi/etc/samba/smb. conf
Modify
57 [global]
101 security = user
Add
294 [tools]
295 comment = my share
296 path =/opt/mytools
297 public = no
298 read only = yes
299 valid users = zhangsan, lisi
300 write list = zhangsan
[Root @ localhost ~] # Service smb reload
Log in with zhangsan and lisi respectively, and you will see your own folder of the same name. Both accounts can write data in their own folders. To enable zhangsan to write data in tools, perform the following operations:
[Root @ localhost ~] # Chmod 777/opt/mytools/\ give the directory write permission
[Root @ localhost ~] # Vi/etc/samba/smb. conf
Make the user's uploaded Directory have 755 permissions, and the uploaded file has 644 permissions,
Add in [tools]
Directory mask = 0755
Create mask = 0644
NOTE: If no permission mask is set, the permission for the file created by the user is 744, And the directory is 755.
Use Michael Jacob to create a file and verify the Directory
4. User ing and access address restrictions
1): Shared account ing
[Root @ localhost ~] # Cat/etc/samba/smbusers
Add
Zhangsan = aaa bbb ccc
[Root @ localhost ~] # Vi/etc/samba/smb. conf
Add
[Global]
Username map =/etc/samba/smbusers
[Root @ localhost ~] # Service smb restart
2): Access address Restriction
[Root @ localhost ~] # Vi/etc/samba/smb. conf
Add
Hosts allow = 192.168.10.6
[Root @ localhost ~] # Service smb restart
Modify the ip address of the client and then access
3. Client Access (using another linux or centos)
[Root @ localhost ~] # Vi/etc/samba/smb. conf
Modify
# Hosts allow = 192.168.10.6 \ comment out
[Root @ localhost ~] # Smbclient-L192.168.10.10-U zhangsan \ Use zhangsan to view shares
[Root @ localhost ~] # Smbclient // 192.168.10.10/tools \ anonymous User Logon: anonymous
[Root @ localhost ~] # Smbclient-U aaa // 192.168.10.10/tools \ log in with zhangsan
Mount sharing
[Root @ localhost ~] # Mkdir/aaa
[Root @ localhost ~] # Mount-ousername = zhangsan // 192.168.10.10/tools/aaa
[Root @ localhost ~] # Cd/aaa
[Root @ localhost aaa] # ls
[Root @ localhost aaa] # touch bbb