[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
//
vim