I have a simple text file with one username/password combo per line:
user1 p@55w0rD1
user2 p@55w0rD2
I used this simple script to import my user list on the Linux side:
#!/bin/bash
while read u1 p1
do
echo Username: $u1 Password: $p1 created
adduser $u1
echo $p1 | passwd --stdin "$u1"
echo Username: $u1 Password: $p1 created
done < userlist.txt
Can this script be modified so that I can add this same user list to Samba? The thing I'm stumbling on is smbpasswd -a prompts for a password immediately and I'm not sure how to handle that in a script.
Give this a shot:
#!/bin/bash
case "$@" in
add ) for user in `cat user.txt`
do
smbpasswd -a $user
echo samba_password | passwd --stdin $user
done;;
* ) echo"Please enter an argument....";;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.