配置samba使用用户名和密码登录
1、当samba配置文件中的secure设置为user的时候,需要正确的用户名和密码才能登录。
root@localhost /]#gedit /etc/samba/smb.conf
# ----------------------- Standalone Server Options ------------------------
# Scurity can be set to user, share(deprecated) or server(deprecated)
# Backend to store user information in. New installations should
# use either tdbsam or ldapsam. smbpasswd is available for backwards
# compatibility. tdbsam requires no further configuration
security = user //这是默认值,需要用户名密码
passdb backend = tdbsam
2、管理账户和密码
samba默认使用tdbsam数据库管理机制来统一管理用户名和密码,使用的命令是pdbedit,命令如下
命令
说明
pdbedit -L
列出samba用户列表
pdbedit -Lv
列出samba用户详细信息
pdbedit -Lw
列出smbpasswd格式的用户
pdbedit –a wj
增加用户wj
pdbedit –x wj
删除用户wj
pdbedit –c “[D]” –u wj
暂停用户wj
pdbedit –c “[]” –u wj
回复用户wj
3、添加用户,必须确保这个用户存在于你的Linux系统中
[root@localhost wj]# pdbedit -a david //添加用户david
new password:
retype new password:
Unix username: david
NT username:
Account Flags: [U ]
User SID: S-1-5-21-1098217942-694112815-2930643030-1000
Primary Group SID: S-1-5-21-1098217942-694112815-2930643030-513
Full Name: david
Home Directory: \\localhost\david
HomeDir Drive:
Logon Script:
Profile Path: \\localhost\david\profile
Domain: LOCALHOST
Account desc:
Workstations:
Munged dial:
Logon time: 0
Logoff time: never
Kickoff time: never
Password last set: 三, 15 8月 2018 10:15:21 CST
Password can change: 三, 15 8月 2018 10:15:21 CST
Password must change: never
Last bad password : 0
Bad password count : 0
Logon hours : FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
[root@localhost wj]# pdbedit -L //查看是否添加成功
david:500:david
4、重启smb服务
[root@localhost wj]# gedit /etc/sysconfig/iptables
-A INPUT -m state --state NEW -m tcp -p tcp --dport 137 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 138 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 139 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 445 -j ACCEPT
[root@localhost wj]# service iptables restart
iptables:将链设置为政策 ACCEPT:filter nat [确定]
iptables:清除防火墙规则: [确定]