Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Build samba server by Centos7x

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

1. Brief introduction

Samba is a free software that implements SMB protocol on Linux and UNIX systems, which is composed of server and client programs. SMB (Server Messages Block, Information Service Block) is a communication protocol for sharing files and printers on the LAN. It provides sharing services for files, printers and other resources between different computers in the LAN. SMB protocol is a client / server protocol, through which clients can access shared file systems, printers, and other resources on the server. By setting "NetBIOS over TCP/IP", Samba can share resources not only with LAN hosts, but also with computers around the world.

two。 Environment

Operating system: Red Hat Enterprise Linux Server release 7.2 (Maipo)

IP:10.0.1.16

Installation package: samba-4.6.4

3. Deployment

3.1 download the samba-latest.tar.zip file

Go to the official website http://www.samba.org to download the latest version of the samba source package (the latest version is samba-4.6.4)

3.2 installation

a. Install dependency packages and compilation environment

Yum install gnutls-devel python python-devel python-lib* libacl-devel openldap-devel-y

Yum install gcc icc ICL cc-y

b. Use filezilla or winscp to upload samba-latest.tar.zip to the / usr/local directory, and then extract it

Tar-zvxf samba-latest.tar.zip

After decompressing, there will be an extra samba-4.6.4 directory, and then enter the samba-4.6.4 directory.

Cd samba-4.6.4

b. Run the. / configure script to detect the job environment

c. Compilation and installation

Make & & make install

3.3 configure samba

There is no smb.conf configuration file by default. You need to copy smb.conf from the installation package samba-4.6.4/packaging/LSB/ to / usr/local/samba/etc, using the following command

Cp packaging/LSB/smb.conf / usr/local/samba/etc/

3.3.1 configure a shared directory

Vim / usr/local/samba/etc/smb.conf

The default shared home directory, or you can customize the shared directory according to the corresponding format, but the shared directory exists, such as

[pub] path to share

Comment = share to public description

Path = / share/time share path

Valid users = test the user who accesses the shared folder write list = the user group that test accesses the shared folder

Printable = no does not allow printing

Create mask = 0755 permissions to create a file

Directory mask = 0755 permissions to create a directory

3.3.2 create samba user

The user used by samba must be a system user and need to join the samba user. For example:

# create a local user of the system

Useradd test

Passwd test

The password is set to test

# create a samba user

Pdbedit-a-u test # add a samba user

Pdbedit-x-u test # Delete a samba user

Pdbedit-L # View samba users

3.3.3 start samba

/ usr/local/samba/sbin/smbd

Netstat-anutp | grep smbd # to see if it starts

3.3.4 create a custom service boot

Vim / lib/systemd/system/smb.service

Add

[Unit]

Description=samba

After=syslog.target network.target nmb.service winbind.service

[Service]

Type=forking

ExecStart=/usr/local/samba/sbin/smbd start

ExecReload=/usr/local/samba/sbin/smb_restart.sh

ExecStop=/usr/local/samba/sbin/smb_stop.sh

PrivateTmp=true

[Install]

WantedBy=multi-user.target

Note: to avoid formatting problems, please enter it manually

3.3.5 create a smb_restart.sh,smb_stop.sh script

Cd / usr/local/samba/sbin/

Vim smb_restart.sh

Add

Pid= `cat / usr/local/samba/var/run/ smbd.pid`

Kill $pid

/ usr/local/samba/sbin/smbd

Vim smb_stop.sh

Add

Pid= `cat / usr/local/samba/var/run/ smbd.pid`

Kill $pid

Note: to avoid formatting problems, please enter it manually

4. test

Start the smb service

# systemctl start smb

# systemctl restart smb

A. Linux client test

Create a mount point

Mkdir / mnt/samba

Give the user write permission

# setfacl-m u:test:rwx / share/time/

Mount the shared directory first

Mount-t cifs / / 10.0.1.16/pub / mnt/samba-o username=test

If an error occurs as follows:

Please execute the command: yum install cifs*-y

Check whether the mount is successful

Df-h

Power on and mount automatically

Vim / etc/fstab

Add

/ / 10.0.1.16/pub / mnt/ mnt/samba cifs credentials=/etc/samba/test.passwd 0 0

Vi / etc/samba/zhi.passwd # # prevent password disclosure, so create another file

Username=zhipassword=abcdef

# chmod 600 / etc/samba/test.passwd # # set the password file permissions

# umount / mnt/samba # # Uninstall

B. Windows client test

Start-> run-- > enter / / 10.0.1.16/pub

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report