三、将共享文件加载到客户端本地进行操作
客户端使用smbclient远程访问共享目录时,操作指令是有限的(能过help命令可以查看),touch命令就不可用。为做进一步验证,要将共享目录加载到本地,再进行相关操作。
通过mount cifs方式进行加载。
1.先使用user1挂载、操作:
[root@zoro ~]# mount -t cifs 192.168.56.53:/share /mnt/ -o username=user1
Password:
[root@zoro ~]# cd /mnt
[root@zoro mnt]# ls
b
[root@zoro mnt]# mkdir user1
[root@zoro mnt]# vim user1/1
user111 (注,这个是输入的内容)
[root@zoro mnt]# ll
total 4
-rw-r--r-- 1 root root 4 May 24 06:41 b
drwxr-xr-x 2 502 502 0 May 24 07:02 user1
[root@zoro mnt]# ll user1/
total 4
-rw-r--r-- 1 502 502 8 May 24 07:02 1
[root@zoro mnt]# cd
[root@zoro ~]# umount -t cifs 192.168.56.53:/share /mnt/
umount: /mnt: not mounted
2.再用user2挂载、操作:
[root@zoro ~]# mount -t cifs 192.168.56.53:/share /mnt/ -o username=user2%RedHat
(注,这行命令,直接把user2的samba密码redhat也写出来了)
[root@zoro ~]# cd /mnt
[root@zoro mnt]# ls
b user1
[root@zoro mnt]# ls user1/
1
[root@zoro mnt]# cat user1/1
user111
[root@zoro mnt]# rm -rf user1/
rm: cannot remove `user1/1': Permission denied
[root@zoro mnt]# rm -rf b
rm: cannot remove `b': Permission denied
[root@zoro mnt]#
[root@zoro mnt]# touch 2
[root@zoro mnt]# cd
[root@zoro ~]# umount -t cifs 192.168.56.53:/share /mnt/
umount: /mnt: not mounted
可以看到,user2是没有权限删除或更改其他用户的文件的,但可以创建属于自己的文件。
