samba如何批量添加用户
2019-04-29 来源:爱站科技
? ? ? ?我们可以利用samba服务器共享服务器上面的文件,因此作为系统管理员我们需要经常为机器添加用户,但是一个个添加太麻烦了,那么你知道samba如何批量添加用户吗?
这2天接了个linux下文件服务器的单,所以研究samba,目前能做到的是批量导入用户,有些方面的处理还不是很周到,以后有时间再改,先发上几个相关文件.
安装执行办法:
./update.sh remove
./update.sh install
设置smb
./update.sh set
user.txt为用户密码文件,user:password
update.sh
#!/bin/bash
if [ "$1" = "remove" ]; then
aptitude purge samba -y > /dev/null
apt-get remove samba* -y > /dev/null
rm -rf /etc/samba > /dev/null
elif
[ "$1" = "install" ]; then
echo "Waiting..................."
aptitude install samba -f -y
aptitude install winbind -f -y
aptitude install expect -y
addgroup kx
elif
[ "$1" = "set" ]; then
/etc/init.d/samba stop
cp ./smb.conf /etc/samba/smb.conf -f
SAVEDIFS=$IFS
IFS=:
while read xname other
do
smbpasswd -x $xname
done & /dev/null
chown $name.kx /home/$name
./expect_smb.sh $name $passwd > /dev/null
echo "Add user ##$name## with password ##$passwd## over!"
done < ./user.txt
/etc/init.d/samba restart
fi
./expect_smb.sh
#!/usr/bin/expect -f
#FileName:expect_smb.sh
#Add user to the samba server
# 1---The name of user
# 2---The passwd of user
set username [lindex $argv 0]
set password [lindex $argv 1]
spawn smbpasswd -a $username
expect "*password:"
send "$password\n"
expect "*password:"
send "$password\n"
expect eof
smb.conf
[global]
workgroup = mygroup
server string = %h server
; wins support = no
; wins server = w.x.y.z
dns proxy = no
; name resolve order = lmhosts host wins bcast
; interfaces = 127.0.0.0/8 eth0
; bind interfaces only = true
log file = /var/log/samba/log.%m
max log size = 1000
; syslog only = no
syslog = 0
panic action = /usr/share/samba/panic-action %d
security = user
encrypt passwords = true
passdb backend = tdbsam
obey pam restrictions = yes
invalid users = root
; unix password sync = no
passwd program = /usr/bin/passwd %u
passwd chat = *Enter\snew\sUNIX\spassword:* %n\n *Retype\snew\sUNIX\spassword:* %n\n *password\supdated\ssuccessfully* .
; pam password change = no
domain logons = no
; logon path = \\%N\profiles\%U
; logon path = \\%N\%U\profile
; logon drive = H:
; logon home = \\%N\%U
; logon script = logon.cmd
; add user script = /usr/sbin/adduser --quiet --disabled-password --gecos "" %u
load printers = no
; printing = bsd
; printcap name = /etc/printcap
; printing = cups
; printcap name = cups
; printer admin = @ntadmin
; include = /home/samba/etc/smb.conf.%m
# You may want to add the following on a Linux system:
socket options = TCP_NODELAY SO_RCVBUF=8192 SO_SNDBUF=8192
; domain master = auto
; idmap uid = 10000-20000
; idmap gid = 10000-20000
; template shell = /bin/bash
winbind enum groups = yes
; winbind enum users = yes
#======================= Share Definitions =======================
[homes]
comment = Home Directories
browseable = no
writable = yes
create mask = 0700
directory mask = 0700
valid users = %S
[wind]
comment = wind
path = /home/wind
writable = yes
create mask = 0770
directory mask = 0770
[tools]
comment = tools
path = /home/tools
writeable = yes
create mask = 0700
directory mask = 0700
; write list = root, @ntadmin
; postexec = /bin/umount /cdrom
user.txt
kx1:0
kx2:0
kx3:0
kx4:0
? ? ? ?以上就是爱站技术频道小编为大家准备samba如何批量添加用户的内容,希望你正好需要,更多精彩内容,请继续关注爱站技术频道。
标签: [db:TAGG]
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点!
本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。
下一篇:增强Linux服务器安全的配置