chipmunken Posted June 6, 2009 Share Posted June 6, 2009 Ok Im trying too make this shell script create users from my text file, I also want to type in a password that will be set to the users. #!/bin/sh # Sebastian schmidt clear echo "This script creates accounts for the people you have listed in the file (users) and puts them in the group it." echo "" echo "given and surname must be seperated with ( in the file (users)." echo "If you want to execute the script now type (yes) and press enter, else type exit and press enter." id | grep root 2>/dev/null >/dev/null if [ $? -eq 1 ] then echo "You need to be root before running this script." echo "Please restart this script as root and all will be fine." exit fi read svar if [ "$svar" = "yes" ] then echo "Type password for the new users." read pass echo "Type in the path for the file (users)" #echo $pass read users groupadd it 2>/dev/null >/dev/null for i in `sed 's/\(..\).*@\(..\).*/\1\2/' $users` do useradd -g it -p $pass -s /bin/bash -m -d /home/it09$i it09$i 2>/dev/null >/dev/null done echo "Done!" elif ["$svar" = "exit"] then echo "exiting script" exit fi This is how my textfile looks like sebastian@schmidt sandra@fahlen tomas@persson All works fine when it comes to createing the users and home catalogs. The problem is the password wont stick.. I dont know whats wrong. When I switch to a normal user and try to su to one of the created users it asks me for a password and then it says seb@webserver:/home$ su it09sesc Password: su: Authentication failure Help wanted Quote Link to comment Share on other sites More sharing options...
Daniel0 Posted June 7, 2009 Share Posted June 7, 2009 From the man-page of useradd -p, --password PASSWORD The encrypted password, as returned by crypt(3). The default is to disable the account. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.