linux--How to build a shared directory of Samba, user authentication sharing and anonymous user sharing? (No system)

Source: Internet
Author: User

1. Application scenario, build Sam shared directory
Available for Linux and between Windows

2. Server ip:192.168.56.11 (A)
Client ip:192.168.56.133 (B)

View firewall status and close

[[email protected] ~]#systemctl status firewalld[[email protected] ~]#systemctl disable firewalld[[email protected] ~]#systemctl stop firewalld[[email protected] ~]#setenforce 0

Install Sam First and set up the SAM user

[[email protected] ~]# yum-y install samba-* [[email protected] ~]# useradd-m DDD//create user ddd,-m, do not create user home directory [ [email protected] ~]# smbpasswd-a DDD//Add system user for Samba user and set password 123New SMB password:retype new SMB password:added US ER ddd.testparm[[email protected] samba]# touch smbusers//Create/smbusers[[email protected under/etc/samba] Samba ]# echo ' DDD = Share ' >/etc/samba/smbusers//here to map DDD to share users, you need to add DDD =/etc/samba/smbusers in the Share[[email&nb file        Sp;protected] samba]# vim/etc/samba/smb.conf//Add the following in the global configuration [global] workgroup = Samba Security = user Username map =/etc/samba/smbusers//Add user Name Mapping file/etc/samba/smbusers[[email protected] ~]# mkdir/op T/guohui[[email protected] ~]# chown-r DDD. Ddd/opt/guohui[[email protected] ~]# testparm//test configuration file for syntax errors, view the final active configuration Load SMB config files fro M/etc/samba/smb.conf[[email protected] ~]# ll/opt/total dosage 0drwxr-xr-x. 2 DDD DDD 6 August 6 17:07 Guohui 

Configure sharing
[email protected] ~]# cat >>/etc/samba/smb.conf <<eof

> [guohui]> comment = guohui> path = /opt/guohui> browseable = yes> guest ok = yes> writable = yes> write list = share> public = yes> EOF
[[email protected] ~]# tail -8 /etc/samba/smb.conf[guohui]comment = guohuipath = /opt/guohuibrowseable = yesguest ok = yeswritable = yeswrite list = sharepublic = yes
``
[[email protected] ~]# systemctl start smb                //启动smb服务[[email protected] ~]# systemctl restart smb             //重启smb服务[[email protected] ~]# systemctl reload smb             //重新加载smb服务[[email protected] ~]# systemctl enable smb             //设置smb服务随系统启动而启动Created symlink from /etc/systemd/system/multi-user.target.wants/smb.service to /usr/lib/systemd/system/smb.service.

View the Samba server on the client with those shared resources (B)

[[email protected] ~]# smbclient -L 192.168.56.11 -U shareEnter SAMBA\share‘s password:Anonymous login successfulOS=[Windows 6.1] Server=[Samba 4.7.1]    Sharename       Type      Comment    ---------       ----      -------    print$          Disk      Printer Drivers    guohui          Disk      guohui    IPC$            IPC       IPC Service (Samba 4.7.1)Anonymous login successfulOS=[Windows 6.1] Server=[Samba 4.7.1]    Server               Comment    ---------            -------    Workgroup            Master    ---------            -------

Mount the shared resource Guohui of the Samba server to the client local (B)
To mount the IP address as a ddd in a cifs manner

[[email protected] ~]# mkdir -p /opt/guohui[[email protected] ~]#  mount -t cifs //192.168.56.11/guohui /opt/guohui/ -o username=share,password=123[[email protected] ~]# df -h文件系统                 容量  已用  可用 已用% 挂载点tmpfs                     98M     0   98M    0% /run/user/0//192.168.56.11/guohui    17G  4.0G   14G   24% /opt/DDD
[[email protected] opt]# cd guohui           (B)在目录下创建[[email protected] guohui]# mkdir 1[[email protected] ~]# ls /opt/guohui        (A)验证1总结,请务必先关闭防火墙

2. How to configure anonymous sharing

查看防火墙状态并关闭[[email protected] ~]# systemctl status firewalld[[email protected] ~]# systemctl disable firewalld[[email protected] ~]# systemctl stop firewalld[[email protected] ~]# setenforce 0//使用yum安装samba服务器
[[email protected] ~]# yum -y install samba-*   //在全局配置中添加[[email protected] ~]# vim /etc/samba/smb.conf     [global]        workgroup = SAMBA        security = user        map to guest = Bad User        //添加本行命令,固定式

Create a shared directory

[[email protected] ~]# mkdir /opt/guohui1[[email protected] ~]# chmod 777 /opt/guohui1[[email protected] ~]# ll /opt/drwxrwxrwx. 2 root root 6 8月   6 19:45 guohui1

Configure sharing

[[email protected] ~]# vim /etc/samba/smb.conf[[email protected] ~]# tail -7 /etc/samba/smb.conf[guohui1]comment = guohui1path = /opt/guohui1browseable = yesguest ok = yeswritable = yespublic = yes
//启动smb服务[[email protected] ~]#  systemctl start smb

View shared resources of the Samba server on the client, Discover GUOHUI1//(B)

[[email protected] ~]# smbclient-l 192.168.56.11-u ' bad User '
Enter Samba\bad User ' s password:
Os=[windows 6.1] Server=[samba 4.7.1]

Sharename       Type      Comment---------       ----      -------print$          Disk      Printer Driversguohui1         Disk      guohui1IPC$            IPC       IPC Service (Samba 4.7.1)

Mount the shared resource guohui1 of the Samba server to the client local

[[email protected] ~]# mkdir -p /opt/guohui1[[email protected] ~]# mount -t cifs //192.168.56.11/guohui1 /opt/guohui1/ -o username=‘Bad User‘Password for Bad [email protected]//192.168.56.11/guohui1:              //空格[[email protected] ~]# df -h//192.168.56.11/guohui1   17G  4.0G   14G   24% /opt/guohui1

Create a new file on the client computer by entering the shared directory

[[email protected] ~]# cd /opt/guohui1          (B)在目录下创建[[email protected] guohui1]# mkdir 1//samba服务器验证[[email protected] ~]# ls /opt/guohui1        (A)验证1

Summarize:

Use Windows to log into Samba server, user (bad user), no password required

1. Place files in Windows into the Samba server//login in Windows system (\+IP)

2. Place a window file into the Samba server and use the Samba server to view

[[email protected] guohui1]# mkdir 1[[email protected] guohui1]# ls1  1.txt

linux--How to build a shared directory of Samba, user authentication sharing and anonymous user sharing? (No system)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.