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

Construction of Samba Service based on Centos 7 and related experiments (pure experiment)

2025-02-27 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.

-from Baidu encyclopedia

1. Anonymous access to the Samba sharing service. 1. Installation service modifies the main configuration file

Configuration file location: / etc/samba/smb.conf

[root@localhost ~] # yum install samba-y # # install the Samba service [root@localhost ~] # cd / etc/samba/ # # change 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 # # re-create a configuration file (uncommented) [root@localhost samba] # vim smb. Conf # # modify 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 # # press G to locate the last line Add [share] # # added share file path=/opt/test # # path public=yes # # Public access browseable=yes # # can be accessed Writable=yes # # write permissions create mask=0644 # # set permissions directory mask=07552, Create a site and open the service [root@localhost samba] # mkdir / opt/test # # create a directory [root@localhost samba] # chmod 777 / opt/test # # give full permissions [root@localhost samba] # systemctl stop firewalld.service # # turn off the firewall [root@localhost samba] # setenforce 0 # # turn off the enhanced function [root@localhost samba] # systemctl start smb.service # # enable Samba service 3, verify the test results

Note: the test machine needs to be interconnected with the Samba server

Using the WIN+R shortcut, enter the IP address of the samba server

Go back to Linux to check

[root@localhost samba] # cd / opt/test/ # # View the shared file directory and view the created text [root@localhost test] # ll-rw-r--r--. 1 nobody nobody 0 November 5 15:51 111.txt II, authentication of Samba shared services 1, Modify the main configuration file [root@localhost ~] # cd / etc/samba/ # # change to the Samba configuration file directory [root@localhost samba] # vim smb.conf # # modify the configuration file [global] workgroup = user passdb backend = tdbsam printing = cups printcap name = cups load printers = yes cups options = raw # map to guest = Bad User # # anonymously access a comment or delete # # press G to locate the last line Add [test] path=/opt/test # # shared file directory path browseable=yes # # can access Remove the public entry from the create mask=0644 directory mask=0755 valid users=zhangsan Lisi # # users allowed to access write list=zhangsan # # users allowed to write, 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] # lstest rh test2 [root@localhost opt] # chmod 777 test2/ # # give maximum permission [root@localhost opt] # systemctl restart smb # # restart Samba service 3, Result verification

Similarly, using the WIN+R shortcut key, enter the server IP

Note: in this experiment, zhangsan is the only user with full read and write rights, and lisi can only perform read operations. Start to verify:

three, Samba shared service account name mapping (account alias login) 1. Create a mapping file [root@localhost ~] # cd / etc/samba/ [root@localhost samba] # vim smbusers # # create an account mapping profile zhangsan = T01 T02 lisi = test1 test22, Modify the configuration file [root@localhost samba] # vim smb.conf [global] workgroup = SAMBA security = user passdb backend = tdbsam printing = cups printcap name = cups load printers = yes cups options = raw username map = / etc/samba/smbusers # # to add the alias Configuration file path [root@localhost samba] # systemctl restart smb3, Verification result

Use aliases for login operations

Also use WIN+R shortcuts to link

4. Access control list of Samba service

To establish an access control list, you only need to modify one file.

[root@localhost samba] # vim / etc/samba/smb.conf [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 [root@localhost samba] # systemctl restart smb result verification

Thank you for your 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