5

I need to create bunch of new users with given password. What I want is a script that I would pass the user name of new user and it will create/add the user and set its password. (the password is the same for all new users - no security issues here.)

Any suggestions how to do that on SuSE from command line?

7

Does SuSE useradd have the -p option? That takes the password (albeit in encrypted form, but you should be able to generate that I think).

So useradd -p <crypt'ed password> <new username> should do it I think

| improve this answer | |
0

You can create a shell script like this:

#!/bin/bash
echo "Type the username:"
read USERNAME
echo "Type the pass:"
stty -echo
read PWD
stty echo
useradd -p ${PWD} ${USERNAME}
| improve this answer | |
0
for i in `cat userlist`
do
useradd $i
echo "$i:your_password"|chpasswd
done

userlist should contain list of users to be created.

| improve this answer | |
  • Welcome to the site, and thank you for your contribution. Please note, however, that the "backtick"-style for command substitutions is deprecated, and the $( ... ) style should be used instead. – AdminBee Aug 5 at 15:11
0

Can be done in two steps.

  1. First create users with useradd command
  2. On the second run something like this
    cat 1.txt | while read line; do echo "12345" | passwd --stdin $(echo ${line}); done
    
    where 1.txt is a file containing the list of logins.
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.