[samba]
服务端:
#yum install -y samba samba-client samba-common
#mkdir /westos
#touch /westos/sambafile
#vim /etc/samba/smb.conf
#useradd -s /sbin/nologin chengcheng
#smbpasswd -a chengcheng
#chown -R chengcheng /westos
#vim /etc/samba/smb.conf
[hello]
comment = local
path = /westos
guest ok = yes //允许匿名用户登录
writeable = yes //任何用户可写即上传文件
#systemctl restart smb.sevice
#客户端: yum install -y samba-client
#smbclient //ip/hello -U chengcheng
smb: \> put file
smb: \> get file1
smb: \> rm file10 //注意这里删除不能用rm -rf 的
这样就可以实现实名用户上传下载了
下来进行匿名用户访问
[hello]
comment = local
path = /westos
guest ok = yes //允许匿名用户登录
writeable = yes //任何用户可写即上传文件
在security = user passdb backend = tdbsam
中增加:map to guest = bad user
重启smb服务
#systemctl restart smb.sevice
#smbclient //ip/hello
smb: \> put file
smb: \> get file1
smb: \> rm file10
valid users = test //表示有效用户,@groupname或者+groupname不在组组的中的用户不能登录。
admin users = test //这个表示普通用户将以root的身份对上传下载,删除
write list = test //用户列表中的可写
samba多用户挂载
#mount -t cifs -o username=test,password=123456 //172.25.254.164/hello /mnt
#df -h
自动挂在的设置
#vim /etc/fstab
//172.25.254.164/hello /mnt cifs defaults,username=test,password=123456 0 0
#注意这样不***全
//172.25.254.164/hello /mnt cifs credentials=/root/userpasswd 0 0
#vim /root/userpasswd
user=test
pass=123456
[SMB多用户挂载]
安装cifs-utils软件包,它包含了cifscreds命令
# yum install -y cifs-utils
创建smb多用户挂载目录:
# mkdir /mnt/multiuser
建立smb认证文件:
# echo ‘username=test‘ > /root/smb-multiuser.txt
# echo ‘password=123456‘ > /root/smb-multiuser.txt
编辑/etc/fstab,永久挂载smb共享:
//server0/smbshare /mnt/multiuser cifs credentials=/root/smb-multiuser.txt,multiuser,
sec=ntlmssp 0 0
# mount -a
# su - test
$ touch /mnt/multiuser/test.txt
touch: cannot touch ‘/mnt/multiuser/test.txt’: Permission denied
$ cifscreds add server0
Password: redhat
$ echo "multiuser" > /mnt/multiuser/test.txt
$ cat /mnt/multiuser/test.txt
multiuser
$ exit
# su - cheng
$ cifscreds add server0
Password: redhat
$ echo "multiuser" > /mnt/multiuser/cheng.txt
-bash: /mnt/multiuser/cheng.txt: Permission denied
$ cat /mnt/multiuser/brian.txt
multiuser
//