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

Samba server configuration under Centos7 (actual combat)

2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

Overview of Samba

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.

First, anonymous access to Samba sharing services

1. Install the Samba service

[root@localhost ~] # yum install samba-y # # install the Samba service

2. Configure Samba profile information

[root@localhost ~] # cd / etc/samba/ # # switch to the Samba configuration file directory [root@localhost samba] # mv smb.conf smb.conf.bak # # backup [root@localhost samba] # grep-v "#" smb.conf.bak > smb.conf # # recreate a configuration file (uncommented) [root@localhost samba] # vim smb.conf # # modify the configuration file [global] # # Global workgroup = SAMBA security = user passdb backend = tdbsam printing = cups printcap name = cups load printers = yes cups options = raw map to guest = Bad User # # add this item Enable anonymous user access # # add the following configuration information from Big G to the last line [myshare] # # added share file path=/opt/abc # # path public=yes # # Public access browseable=yes # # can access writable=yes # # write permission create mask=0644 # # setting permission directory mask=0755

3. Create the myshare path directory and give permissions

[root@localhost samba] # mkdir / opt/abc # # create directory [root@localhost samba] # chmod 777 / opt/abc # # give full permissions [root@localhost samba] # systemctl stop firewalld.service # # turn off firewall [root@localhost samba] # setenforce 0 # # turn off enhanced function [root@localhost samba] # systemctl start smb.service # # enable Samba service

4. Use the test machine to access

Using the test machine to access sharing

View shared folder

Create a file to a shared folder

View the created file in Linux

[root@localhost samba] # cd / opt/abc/ # # View the shared file directory and see the created text [root@localhost abc] # ls111.txt [root@localhost abc] # ls-l # # Linux. The anonymous user is the total amount of nobody: 0 Murray, Murray, Murray. 1 nobody nobody 0 November 5 15:51 111.txt

Second, authentication of Samba shared services

1. Configure Samba profile information

[root@localhost ~] # cd / etc/samba/ # # switch to the Samba configuration file directory [root@localhost samba] # vim smb.conf # # modify the configuration file [global] workgroup = SAMBA security = user passdb backend = cups printcap name = cups load printers = yes cups options = raw # # delete an entry for anonymous access # # add big G to the last line below Configuration information of [test] path=/opt/test # # shared file directory path browseable=yes # # can be accessed Remove create mask=0644 directory mask=0755 valid users=zhangsan from public entry, lisi # # users allowed to access write list=zhangsan # # users allowed to write

2, create a smb user

[root@localhost samba] # useradd zhangsan # # create two users [root@localhost samba] # useradd lisi [root@localhost samba] # smbpasswd-a zhangsan # # create smb user and set password New SMB password: # # set password Retype new SMB password: # # confirm password Added user zhangsan. [root@localhost samba] # smbpasswd-a lisiNew SMB password:Retype new SMB password:Added user lisi. [root@localhost samba] # pdbedit-L # # list the use of smb

3, use the test machine to access the sharing

To avoid errors, clear the cache on the test first.

Using the test machine to access sharing

Authentication is required. Enter user name and password

Create a file to the test shared folder

View the created file in Linux

[root@localhost opt] # cd / opt/test/ [root@localhost test] # ls # # successfully created 222.txt

4, because only zhangsan write permissions are allowed in the configuration file, test whether lisi can write

Access sharing with lisi

Test creation file

Third, the account name mapping of Samba shared service (account alias login)

1, configuration mapping file and Samba configuration file

[root@localhost ~] # cd / etc/samba/ [root@localhost samba] # vim smbusers # # create account mapping profile zhangsan = T01 T02 # # alias T01 T02 password or zhangsan user password [root@localhost samba] # vim smb.conf # # configuration Samba configuration file [global] workgroup = SAMBA security = user passdb backend = tdbsam printing = cups printcap name = cups load printers = yes Cups options = raw username map = / etc/samba/smbusers # # add the alias profile path [root@localhost samba] # systemctl restart smb.service # # restart the Samba service

2. Use the test machine to test alias access and log in with aliases

Fourth, the access control list of Samba shared services

1. Configure Samba profile information

[root@localhost ~] # cd / etc/samba/ # # change to the Samba profile directory [root@localhost samba] # vim smb.conf # # modify the configuration file [test] path=/opt/test browseable=yes create mask=0644 directory mask=0755 valid users=zhangsan, lisi write list=zhangsan hosts deny=192.168.13. # # add deny 192.168.13 segment access to test [root@localhost samba] # systemctl restart smb.service # # restart Samba service

2. Access the test shared folder with the test machine

Fifth, mount it directly to Linux through the Windows shared folder

1. Use Linux to access files shared by Windows

[root@localhost ~] # smbclient-L / / 192.168.100.99/share # # access shared Enter SAMBA\ root's password: # # password

2. Mount the shared file to Linux and access the file directly

[root@localhost ~] # mkdir-p / opt/share01 # # create a mount point [root@localhost ~] # mount.cifs / / 192.168.100.99/share / opt/share01 # # mount a shared folder to the mount point Password for root@//192.168.100.99/share: [root@localhost ~] # cd / opt/share01 # # switch to the mount point [root@localhost share01] # lstest.txt [root@localhost share01] # cat test. Txt # # View the file contents of the shared folder this is a testboxes!

(Windows specific sharing settings to view the previous blog, thank you! )

The above is the whole content of this article, I hope it will be helpful to your study, and I also hope that you will support it.

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