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 service configuration details (anonymity, identity, aliases, access control, mount access)

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

Share

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

Detailed explanation of Samba service configuration

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.

Anonymous access to Samba sharing service [root@localhost ~] # yum install samba-y [root@localhost ~] # cd / etc/samba/ [root@localhost samba] # lslmhosts smb.conf smb.conf.example [root@localhost samba] # mv smb.conf smb.conf.bak [root@localhost samba] # grep-v "# smb.conf.bak > smb.conf [root@localhost samba] # vim smb.conf [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 users to access [myshare] # # added share files path=/opt/chen # # path public=yes # # Public access browseable=yes # # can access writable=yes # # allow write permissions create mask=0644 # # set permissions directory mask=0755 [root@localhost Samba] # mkdir / opt/chen [root@localhost samba] # chmod 777 / opt/chen/ [root@localhost samba] # systemctl stop firewalld.service [root@localhost samba] # setenforce 0 [root@localhost samba] # systemctl start smb.service go to win10 to test anonymous access

When we go back to the Linux server, we can see that the files we shared are anonymously accessed [root@localhost samba] # cd / opt/chen/ [root@localhost chen] # lsCHEN.txt [root@localhost chen] # ls-l. 1 nobody nobody 0 November 14 09:55 authentication for CHEN.txtSamba shared services [root@localhost samba] # vim smb.conf [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 # # remove the original anonymous access [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 [root@localhost samba] # useradd zhangsan # # create user [root@localhost samba] # useradd lisi [root@localhost samba] # smbpasswd-a zhangsan # # set the password New SMB password:Retype new SMB password:Added user zhangsan. [root@localhost samba] # smbpasswd-a lisiNew SMB password:Retype new SMB password:Added user lisi to the user . [root@localhost samba] # pdbedit-L # # list smb users zhangsan:1001:lisi:1002: [root@localhost samba] # cd / opt/ [root@localhost opt] # mkdir test [root@localhost opt] # lschen rh test [root@localhost opt] # chmod 777 test/ [root@localhost opt] # systemctl restart smb.service go to win10 to test authentication access

Account name mapping for Samba shared services Account alias login [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 # # configure 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 file path [root@localhost samba] # systemctl restart smb.service # # restart to win10 to test alias access

Access control list for Samba shared service [root@localhost ~] # cd / etc/samba/ # # switch to the Samba profile directory [root@localhost samba] # vim smb.conf # # modify the profile [test] path=/opt/test browseable=yes create mask=0644 directory mask=0755 valid users=zhangsan Lisi write list=zhangsan hosts deny=192.168.13.0 # # add deny 192.168.13 segment access to test [root@localhost samba] # systemctl restart smb.service # # restart the Samba service to win10 to test the access control

Directly mount to Linux through Windows shared folder and use files accessed by Linux to access Windows share [root@localhost ~] # smbclient-L / / 192.168.100.99/share # # access shared Enter SAMBA\ root's password: # # password to mount 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! There are detailed tutorials in my previous blog. Thank you for watching.

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