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

How to build a Samba service in Centos 7

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

Share

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

This article shows you how to build a Samba service in Centos 7, which is concise and easy to understand. It will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.

First, anonymous access to Samba sharing services

1. The 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/ # # 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 # # re-create a configuration file (except 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 # # 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 permission create mask=0644 # # set permission directory mask=0755

2. Create a site and start the service

[root@localhost samba] # mkdir / opt/test # # create directory [root@localhost samba] # chmod 777 / opt/test # # 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

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 authentication of 111.txt II and 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 = SAMBA security = user passdb backend = tdbsam printing = cups printcap name = cups load printers = yes Cups options = raw # map to guest = Bad User # # an anonymously accessed comment or delete # # locate the last line by G Add [test] path=/opt/test # # shared file directory path browseable=yes # # accessible, remove create mask=0644 directory mask=0755 valid users=zhangsan from public entries, lisi # # users allowed to access write list=zhangsan # # users allowed to write

2. Create smb users

[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 the maximum permission [root@localhost opt] # systemctl restart smb # # restart the 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:

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

1. Establish 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 smb

3. 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 access to paragraph 192.168.13 [root@localhost samba] # systemctl restart smb the above is how to build a Samba service in Centos 7. Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.

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