[samba]samba设置指定用户权限
步骤:
- 1.在系统中添加用户
批量添加用户和密码的方法(因为samba用户要求必须在系统中存在):
for name in a b c d;do useradd $name ; echo “$user:passwd” |chpasswd;done
即添加了a,b,c,d四位用户,使用echo “user:passwd” |chpasswd 可以非交互修改密码
或者echo “passwd” |passwd –stdin user,也是非交互修改密码
- 2.在samba中添加用户
使用pdbedit命令
pdbedit –L
pdbedit –Lv
nix username: nobody
NT username:
Account Flags: [U ]
User SID: S-1-5-21-2107421968-467478545-4137003959-501
Primary Group SID: S-1-5-21-2107421968-467478545-4137003959-513
Full Name: nobody
Home Directory:
HomeDir Drive: (null)
Logon Script:
Profile Path:
Domain: INNERSERVER1
Account desc:
Workstations:
Munged dial:
Logon time: 0
Logoff time: never
Kickoff time: never
Password last set: 0
Password can change: 0
Password must change: 0
Last bad password : 0
Bad password count : 0
Logon hours : FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
pdbedit –Lw
nobody:65534:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:[U ]:LCT-00000000:
pdbedit –a –u userA 【添加】
pdbedit –r –u userC 【修改】
pdbedit –x –u userB 【删除】
批量添加用户:
for name in a b c d ; do pdbedit –a –u $name; done
- 3.修改samba用户密码
使用smbpasswd批量修改密码的方法
for name in a b c d ; do ( echo passwd; echo confirmpasswd) | smbpasswd –s –U $name; done
-s 是使用silent模式,-U 指定用户名
- 4.权限设定
关于writelist,需要在read only权限设置使用的情况才有效,否则如果设定read only = no
或者writable = yes则不生效。
例如:
[DA-Share]
comment = DA-Share
path = /home/dashare/DA-Share
browseable = yes
read only = yes
write list = root jinuo zuowei
guest ok = no