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-18 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 service 1, install Samba service [root@localhost ~] # yum install samba-y # # install Samba service 2 Configure Samba configuration file 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 (excluding annotated) [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 # # access to writable=yes # # write permission create mask=0644 # # set permission directory mask=07553 Create a myshare path directory and give permissions [root@localhost samba] # mkdir / opt/abc # # create directories [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 enhancements [root@localhost samba] # systemctl start smb.service # # enable Samba service 4, use test machine access to access shares

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 view the created text [root@localhost abc] # ls111.txt [root@localhost abc] # ls-l # # Linux. The anonymous access user is the total amount of nobody used by Murray. 1 nobody nobody 0 November 5 15:51 111.txt II, authentication 1 for Samba shared service 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 = tdbsam printing = cups printcap name = cups Load printers = yes cups options = raw # # delete an entry for anonymous access # # add the following configuration information from big G to the last line [test] path=/opt/test # # shared file directory path browseable=yes # # can access 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 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 smb users zhangsan:1001:lisi:1002: [root@localhost samba] # cd / opt/ [root@localhost opt] # mkdir test # # create a shared directory [root@localhost opt] # lsabc rh test [root@localhost opt] # chmod 777 test/ # give maximum permissions [root@localhost opt] # systemctl restart smb.service # # restart Samba service 3 Use the test machine to access the share in order to avoid errors, you can first clear the cache on the test

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 [root@localhost opt] # cd / opt/test/ [root@localhost test] # ls # # in Linux. The 222.txt4 has been created successfully, because only zhangsan write permission is allowed in the configuration file to test whether lisi can write to access the share with lisi.

Test creation file

3. 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 alias profile path [root@localhost samba] # systemctl restart smb.service # # restart Samba service 2 Use the test machine to test alias access use alias login

Fourth, Samba shared service access control list 1, configuration 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 [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 and use a test machine to access the test shared folder

Fifth, mount the shared files in Linux directly through the Windows shared folder. Use 1 to access the files shared by Windows [root@localhost] # smbclient-L / / 192.168.100.99/share # # access the shared Enter SAMBA\ root's password: # # password 2, and mount the shared files to Linux Directly access the file [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 view previous blogs Thank you! (thank you for reading!

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