Add users in samba in batches-Linux Enterprise Application-Linux server application information. The following is a detailed description. I received a ticket from the file server in linux over the past two days. So what we can do with samba is to import users in batches. Some operations are not very thoughtful and I will try again later, start with several related files.
Installation Method:
./Update. sh remove
./Update. sh install
Set smb
./Update. sh set
User.txt is the user password file, 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 verify CT-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 </etc/passwd
While read name passwd
Do
Deluser $ name
Useradd-g kx-k/dev/null-p $ passwd-m-s/bin/false-d/home/$ name> &/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/CT-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]
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service