[root@qhfax code]# smbpasswd -a nginx
New SMB password:
Retype new SMB password:
Added user nginx.
smbpasswd 属于samba套件,能够实现添加或删除samba用户和为用户修改密码
参数:
-a:向smbpasswd文件中添加用户;
-c:指定samba的配置文件;
-x:从smbpasswd文件中删除用户;
-d:在smbpasswd文件中禁用指定的用户;
-e:在smbpasswd文件中激活指定的用户;
-n:将指定的用户的密码置空。
问题:
smbpasswd samba
New SMB password:
Retype new SMB password:
Failed to find entry for user samba.
解决方法,加参数'-a':
# smbpasswd -a samba
New SMB password:
Retype new SMB password:
Failed to add entry for samba
解决方法:
vi /etc/samba/smb.conf 编辑smb.conf 文件
将;security = share修改为 security user
这是因为没有加相应的系统账号,所以会提示Failed to add entry for user的错误,只需增加相应的系统账号test就可以了
useradd nginx
[root@qhfax samba]# smbpasswd -a nginx
New SMB password:
Retype new SMB password:
workgroup = LinuxSir
netbios name = LinuxSir05
server string = Linux Samba Server TestServer
security = share
client code page=936
display charset = UTF-8
unix charset = UTF-8
dos charset = UTF-8
security = user
encrypt passwords = yes
smb passwd file = /etc/samba/smbpasswd
[log]
path = /log/abc
writeable = no
browseable = yes
guest ok = yes
补充:
以上设置中,smb passwd file = /etc/samba/smbpasswd文件没有生效,smbpasswd命令成功后,测试也是成功的,但是没有写入这个密码文件,最后通过查找,原来密码是存储在这里:
[root@qhfax samba]# ll /var/lib/samba/private
总用量 832
-rw------- 1 root root 421888 10月 10 10:07 passdb.tdb
-rw------- 1 root root 430080 4月 1 2015 secrets.tdb
权限细化:
net use * /del
#security = share
client code page=936
display charset = UTF-8
unix charset = UTF-8
dos charset = UTF-8
passdb backend = tdbsam
security = user
encrypt passwords = yes
username map = /etc/samba/smbusers
smb passwd file = /etc/samba/smbpasswd
[ali_log]
#admin user = dev
path = /sc_log/ali_log
writeable = no
browseable = yes
guest ok = no
valid users = dev
[ali_code]
#admin user = dev
path = /sc_log/sc_code
writeable = no
browseable = yes
guest ok = no
valid users = dev
[ali_upload]
path = /upload/code
#admin users = test
valid users = test
writeable = yes
browseable = yes
guest ok = no