4.1. 2018-02-03-练习网络文件共享2

4.1.1. 练习1-建立samba服务器


建立samba服务器,共享目录为/data,要求如下: 1 共享名字为shared,工作组为linuxpanda。 2 添加组develop,添加用户panda1,panda2,panda3,其中panda1,panda以develop为附加组,

panda3不属于develop组,密码 同用户名

3 添加samba用户,panda1,panda2,panda3密码都是panda 4 此samba共享shared仅允许develop组具有写权限,其他用户只能只读访问 5 此samba共享服务仅仅运行来自192.168.46.0、24的网络主机访问。

# 添加组和用户
[root@centos-155 home]# groupadd develop
[root@centos-155 home]# useradd -G develop panda1
[root@centos-155 home]# useradd -G develop panda2
[root@centos-155 home]# useradd panda3
# 配置系统密码和samba密码
[root@centos-155 home]# echo panda1  |passwd --stdin panda1
[root@centos-155 home]# echo panda2  |passwd --stdin panda2
[root@centos-155 home]# echo panda3  |passwd --stdin panda3
[root@centos-155 home]# smbpasswd  -a panda1
[root@centos-155 home]# smbpasswd  -a panda2
[root@centos-155 home]# smbpasswd  -a panda3
# 创建目录设置权限
[root@centos-155 home]# mkdir /data
[root@centos-155 home]# setfacl -R -m "g:develop:rwx" /data
# 编辑配置文件
[root@centos-155 home]# systemctl restart smb nmb
[root@centos-155 home]# netstat -tunlp |grep mb
# 另一个机器查看
[root@centos-152 yum.repos.d]# smbclient -L  192.168.46.155 -U panda1
Enter SAMBA\panda1's password:
Domain=[CENTOS-155] OS=[Windows 6.1] Server=[Samba 4.6.2]

    Sharename       Type      Comment
    ---------       ----      -------
    print$          Disk      Printer Drivers
    pub             Disk      this is samba pub for windows
    shared          Disk      this this test
    IPC$            IPC       IPC Service (Samba 4.6.2)
    panda1          Disk      Home Directories
Domain=[CENTOS-155] OS=[Windows 6.1] Server=[Samba 4.6.2]

    Server               Comment
    ---------            -------

    Workgroup            Master
    ---------            -------
    SAMBA                CENTOS-155
    WORKGROUP            DESKTOP-31DI5AI

# 挂载
[root@centos-152 yum.repos.d]# mkdir /mnt/panda1
[root@centos-152 yum.repos.d]# mount -o username=panda1,password=oracle //192.168.46.155/shared /mnt/panda1/
# 尝试创建一个文件
[root@centos-152 panda1]# mkdir a
[root@centos-152 panda1]# ls
a  新建文本文档.txt

# 挂载2
[root@centos-152 yum.repos.d]# mkdir /mnt/panda3
[root@centos-152 panda1]# mount -o username=panda3,password=oracle //192.168.46.155/shared /mnt/panda3/
[root@centos-152 panda1]# cd /mnt/panda3
[root@centos-152 panda3]# touch a.txt
touch: cannot touch ‘a.txt’: Permission denied