Configure samba in centos 6.5

Source: Internet
Author: User

Configure samba in centos 6.5

1
Samba Introduction

Samba is a software that allows Linux systems to Apply Microsoft network communication protocols. SMB is short for Server Message Block, that is, Server Message Block. SMB is mainly used as Microsoft network communication protocol, later, Samba applied the SMB communication protocol to the Linux system, forming the current Samba software. Later, Microsoft renamed smb cifs (Common Internet File System), a public Internet File System, and added many new features, this makes Samba more powerful.

Samba can be used for file sharing and print sharing between Linux and windows systems. Samba can be used for file sharing between windows and Linux, it can also be used for resource sharing between Linux and Linux. Because NFS (Network File System) can well achieve data sharing between Linux and Linux, therefore, Samba is mostly used for data sharing between Linux and windows.

SMB is a client/server-based protocol. Therefore, a Samba server can act as both a file sharing server and a Samba client. For example, A Samba server has been set up in Linux, and the windows client can share the resource files on the Samba server through the SMB protocol. At the same time, the Samba server can also access files shared by other windows or Linux systems on the network.
Samba uses the NetBIOS protocol in windows. If you want to use files shared in Linux, check whether the NetBIOS protocol is installed in your windows system.

One of the two services that make up Samba to run is SMB and the other is NMB. SMB is the core startup service of Samba and is mainly responsible for establishing conversations between the Linux Samba server and the Samba client, verify the identity of the user and provide access to the file and print system. Only when the SMB service is started can file sharing be realized, listening to port 139 TCP, And the NMB Service is responsible for parsing, similar to the functions implemented by DNS, NMB can correspond the name of the Working Group shared by the Linux system to its IP address. If the NMB service is not started, it can only access the shared file through the IP address, listen to UDP ports 137 and 138.

The Samba server provides the following functions: WINS and DNS services, network browsing services, authentication and authorization between Linux and Windows domains, UNICODE Character Set and domain name ing, and UNIX sharing of CIFS protocols.

2
Implement
Share/share directory through SMB
Your SMB server must be a member of the WORKGROUP Working Group and the sharing name must be public.
Zxw can read shared content.

The first step is to install and configure the Samba shared directory; the second is to use zxw users to access the shared disk; the third is to configure the firewall and se to be able to access Samba shared.

3
I didn't see samba installed.
[Root @ beiigang ~] # Rpm-qa | grep-I samba
Samba-winbind-clients-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-common-3.6.9-164.el6.x86_64

Configuration Files
[Root @ beiigang ~] # Find/-name samba
/Etc/samba
/Etc/sysconfig/samba
/Usr/lib64/samba
/Var/log/samba
/Var/lib/samba
[Root @ beiigang ~] #
Not Installed

The installation is as follows. It seems that it was not installed previously.
[Root @ beiigang ~] # Rpm-qa | grep-I samba
Samba-common-3.6.23-12.el6.x86_64
Samba-3.6.23-12.el6.x86_64
Samba4-libs-4.0.0-58.el6.rc4.x86_64
Samba-winbind-3.6.23-12.el6.x86_64
Samba-winbind-clients-3.6.23-12.el6.x86_64
Samba-client-3.6.23-12.el6.x86_64

4
No matter whether it is installed or not, delete it first.
[Root @ beiigang ~] # Yum remove samba
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Remove Process
No Match for argument: samba
Loading mirror speeds from cached hostfile
* Base: centos.ustc.edu.cn
* Extras: centos.ustc.edu.cn
* Updates: centos.ustc.edu.cn
Package (s) samba available, but not installed.
No Packages marked for removal

5
Install

[Root @ beiigang ~] # Yum search samba
Check related packages

[Root @ beiigang ~] # Yum-y install samba
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
* Base: pai.bit.edu.cn
* Extras: pai.bit.edu.cn
* Updates: 2.16.bit.edu.cn
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package samba. x86_64. 6.23-12. el6 will be installed
...
Installed:
Samba. x86_64. 6.23-12. el6

Dependency Updated:
Libsmbclient. x86_64 0: 3. 6.23-12. el6 samba-client.x86_64 0: 3. 6.23-12. el6 samba-common.x86_64 0: 3. 6.23-12. el6
Samba-winbind.x86_64 0: 3. 6.23-12. el6 samba-winbind-clients.x86_64 0: 3. 6.23-12. el6

Complete!

6
After the installation is as follows, an additional samba-3.6.23-12.el6.x86_64
[Root @ beiigang ~] # Rpm-qa | grep-I samba
Samba-common-3.6.23-12.el6.x86_64
Samba-3.6.23-12.el6.x86_64
Samba4-libs-4.0.0-58.el6.rc4.x86_64
Samba-winbind-3.6.23-12.el6.x86_64
Samba-winbind-clients-3.6.23-12.el6.x86_64
Samba-client-3.6.23-12.el6.x86_64

7
Query startup Methods
[Root @ beiigang ~] # Rpm-ql samba | grep '/etc'
/Etc/logrotate. d/samba
/Etc/openldap/schema
/Etc/openldap/schema/samba. schema
/Etc/pam. d/samba
/Etc/rc. d/init. d/nmb
/Etc/rc. d/init. d/smb
/Etc/samba/smbusers

[Root @ beiigang ~] #/Etc/init. d/smb start
Starting SMB services: [OK]
[Root @ beiigang ~] # Service nmb start
Starting NMB services: [OK]

Set auto-start
Chkconfig -- level | grep smb
Chkconfig -- level 35 smb on
Chkconfig -- level 35 nmb on
Chkconfig -- level | grep smb

View port
[Root @ beiigang ~] # Netstat-tunpl | grep '[sn] mb'
Tcp 0 0 0.0.0.0: 139 0.0.0.0: * LISTEN 2071/smbd
Tcp 0 0 0.0.0.0: 445 0.0.0.0: * LISTEN 2071/smbd
Tcp 0 0: 139: * LISTEN 2071/smbd
Tcp 0 0: 445: * LISTEN 2071/smbd
Udp 0 0 192.168.18.255: 137 0.0.0.0: * 21924/nmbd
Udp 0 0 192.168.18.99: 137 0.0.0.0: * 21924/nmbd
Udp 0 0 0.0.0.0: 137 0.0.0.0: * 21924/nmbd
Udp 0 0 192.168.18.255: 138 0.0.0.0: * 21924/nmbd
Udp 0 0 192.168.18.99: 138 0.0.0.0: * 21924/nmbd
Udp 0 0 0.0.0.0: 138 0.0.0.0: * 21924/nmbd

8
View samba configuration files
[Root @ beiigang ~] # Rpm-qc samba-common
/Etc/logrotate. d/samba
/Etc/pam. d/samba
/Etc/samba/smbusers
/Etc/samba/lmhosts
/Etc/samba/smb. conf
/Etc/sysconfig/samba
[Root @ beiigang ~] #

9
Configuration
[Root @ beiigang ~] # Vi/etc/samba/smb. conf
[Global]
Workgroup = WORKGROUP
Server string = Samba Server Version % v
Public = yes

Netbios name = ZXWSamba
Lanman auth = yes
Client lanman auth = yes


Security = share


[Public]
Comment = Public Stuff
Path =/share
Public = yes
Writable = yes

10
[Root @ beiigang ~] #/Etc/init. d/smb restart
Shutting down SMB services: [OK]
Starting SMB services: [OK]

[Root @ beiigang ~] # Service nmb status
Nmbd is stopped
[Root @ beiigang ~] # Service nmb stop
Shutting down NMB services: [FAILED]
[Root @ beiigang ~] # Service nmb start
Starting NMB services: [OK]
[Root @ beiigang ~] # Service nmb stop
Shutting down NMB services: [OK]

11
Test
[Root @ beiigang ~] # 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 "[public]"
Loaded services file OK.
Server role: ROLE_STANDALONE
Press enter to see a dump of your service definitions

[Global]
Netbios name = ZXWSAMBA
Server string = Samba Server Version % v
Lanman auth = Yes
Log file =/var/log/samba/log. % m
Max log size = 50
Idmap config *: backend = tdb
Guest OK = Yes
Cups options = raw

[Homes]
Comment = Home Directories
Read only = No

[Printers]
Comment = All Printers
Path =/var/spool/samba
Guest OK = No
Printable = Yes
Print OK = Yes
Browseable = No

[Public]
Comment = Public Stuff
Path =/share
Read only = No

12
[Root @ beiigang ~] # Mkdir/share
[Root @ beiigang ~] # Cd/share/
[Root @ beiigang share] # touch sambatest.txt
[Root @ beiigang share] # chown-R nobody: nobody/share/
[Root @ beiigang share] # chmod-R 777/share/
[Root @ beiigang share] # ll
Total 0
-Rwxrwxrwx. 1 nobody 0 Dec 2 17:34 sambatest.txt


13
[Root @ beiigang share] # smbclient // 192.168.18.99/public
WARNING: The security = share option is deprecated
Enter root's password:
Domain = [WORKGROUP] OS = [Unix] Server = [Samba 3.6.23-12. el6]
Server not using user level security and no password supplied.
Server requested LANMAN password (share-level security) but 'client lanman auth = no' or 'client ntlmv2 auth = yes'
Tree connect failed: NT_STATUS_ACCESS_DENIED
[Root @ beiigang share] #

14
View status
[Root @ beiigang share] # smbstatus

Samba version 3.6.23-12. el6
PID Username Group Machine
-------------------------------------------------------------------
<Processes do not show up in anonymous mode>

Service pid machine Connected
-------------------------------------------------------
Public 2399 test-pc Tue Dec 2 17:05:09 2014
IPC $2399 test-pc Tue Dec 2 17:00:56 2014

Locked files:
Pid Uid DenyMode Access R/W Oplock SharePath Name Time
Bytes --------------------------------------------------------------------------------------------------
2399 99 DENY_NONE 0x100081 rdonly none/home/share. Tue Dec 2 17:10:20 2014

15
[Root @ beiigang ~] # Vi/etc/samba/smb. conf
Security = user


[Root @ beiigang share] # service smb restart
Shutting down SMB services: [OK]
Starting SMB services: [OK]
[Root @ beiigang share] # service nmb restart
Shutting down NMB services: [OK]
Starting NMB services: [OK]

16
[Root @ beiigang share] # smbstatus

Samba version 3.6.23-12. el6
PID Username Group Machine
-------------------------------------------------------------------
2142 zxw test-pc (192.168.18.101)

Service pid machine Connected
-------------------------------------------------------
Zxw 2142 test-pc Wed Dec 3 10:20:52 2014
Zxw 2142 test-pc Wed Dec 3 10:20:52 2014
Public 2142 test-pc Wed Dec 3 10:20:52 2014
IPC $2142 test-pc Wed Dec 3 10:20:52 2014

No locked files
It seems yes.

17
List shared directories of smb services
[Root @ beiigang share] # smbclient-L 192.168.18.99
Enter root's password:
Session setup failed: NT_STATUS_LOGON_FAILURE
This is because the login user is not a samba service user

[Root @ beiigang share] # smbpasswd-a zxw
New SMB password:
Retype new SMB password:
Added user zxw.

18
[Root @ beiigang share] # smbclient-L 192.168.18.99-U zxw
Enter zxw's password:
Domain = [WORKGROUP] OS = [Unix] Server = [Samba 3.6.23-12. el6]

Sharename Type Comment
--------------------
Homes Disk Home Directories
Public Disk Public Stuff
IPC $ IPC Service (Samba Server Version 3.6.23-12. el6)
Zxw Disk Home Directories
Domain = [WORKGROUP] OS = [Unix] Server = [Samba 3.6.23-12. el6]

Server Comment
----------------
ZXWSAMBA Server Version 3.6.23-12. el6

Workgroup Master
----------------
WORKGROUP

19
Connection test. The connection is successful, but it cannot be seen.
[Root @ beiigang share] # smbclient // 192.168.18.99/public-U zxw
Enter zxw's password:
Domain = [WORKGROUP] OS = [Unix] Server = [Samba 3.6.23-12. el6]
Smb: \> dir
NT_STATUS_ACCESS_DENIED listing \*
Smb: \> ls
NT_STATUS_ACCESS_DENIED listing \*
Smb: \>

20
Se problem, turn off OK
[Root @ beiigang share] # setenforce 0
[Root @ beiigang share] # getenforce
Permissive
[Root @ beiigang share] # smbclient // 192.168.18.99/public-U zxw
Enter zxw's password:
Domain = [WORKGROUP] OS = [Unix] Server = [Samba 3.6.23-12. el6]
Smb: \> ls
. D 0 Tue Dec 2 17:34:59 2014
.. DR 0 Wed Dec 3 09:20:49 2014
Sambatest.txt A 0 Tue Dec 2 17:34:59 2014

55119 blocks of size 131072. 25361 blocks available
Smb: \>

21
View on windows

22
View and modify se settings
[Root @ beiigang share] # getenforce
Enforcing
[Root @ beiigang share] # getsebool-a | grep samba
Samba_create_home_dirs --> off
Samba_domain_controller --> off
Samba_enable_home_dirs --> off
Samba_export_all_ro --> off
Samba_export_all_rw --> off
Samba_portmapper --> off
Samba_run_unconfined --> off
Samba_share_fusefs --> off
Samba_cmd_nfs --> off
Sanlock_use_samba --> off
Use_samba_home_dirs --> off
Export _use_samba --> off

[Root @ beiigang share] # setenforce 1
[Root @ beiigang share] # getenforce
Enforcing
[Root @ beiigang share] #
[Root @ beiigang share] # setsebool samba_export_all_ro 1
[Root @ beiigang share] # setsebool samba_export_all_rw 1

23
Test OK
[Root @ beiigang share] # smbclient // 192.168.18.99/public-U zxw
Enter zxw's password:
Domain = [WORKGROUP] OS = [Unix] Server = [Samba 3.6.23-12. el6]
Smb: \> ls
. D 0 Tue Dec 2 17:34:59 2014
.. DR 0 Wed Dec 3 09:20:49 2014
Sambatest.txt A 0 Tue Dec 2 17:34:59 2014

55119 blocks of size 131072. 25361 blocks available
Smb: \> dir
. D 0 Tue Dec 2 17:34:59 2014
.. DR 0 Wed Dec 3 09:20:49 2014
Sambatest.txt A 0 Tue Dec 2 17:34:59 2014

55119 blocks of size 131072. 25361 blocks available
Smb: \>

24
View on windows

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.