LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Ubuntu (https://www.linuxquestions.org/questions/ubuntu-63/)
-   -   Ubuntu 9.04, chpasswd & /usr/sbin/nologin (https://www.linuxquestions.org/questions/ubuntu-63/ubuntu-9-04-chpasswd-and-usr-sbin-nologin-819646/)

Feetloaf 07-13-2010 01:51 PM

Ubuntu 9.04, chpasswd & /usr/sbin/nologin
 
Hi, all,

Built a new system, imported my list of users and updated their passwords with chpasswd easily enough, but the email-only users are getting their passwords rejected. If I use passwd on the console to set the same password, the account starts working. What do you think would cause this, and is there a way to fix it without re-writing that script I keep losing that uses passwd?

Thx,
Feetloaf

rdgreenlaw 07-15-2010 07:30 AM

Can you post the script that sets the passwords? Replace the user names and passwords with dummy values to protect your system integrity.

Feetloaf 07-15-2010 10:42 AM

Thank you for replying.

I first used a simple command (while sudo -i):

Code:

chpasswd < userlist.txt
Where the userlist.txt contents are like:

Code:

user1:password1
user2:password2

which returned no errors, and I could see that the password field of /etc/shadow was changed.

I also believe chpasswd is defaulting to the right enc. type (SHA512), because I can use passwd on a user, and then subsequently change that users' password with chpasswd and the user can check email using the newest password.

rdgreenlaw 07-15-2010 11:45 AM

You should see error messages if chpasswd is not able to assign the chosen password (assuming you are executing this command from root.) Assuming that you are not receiving any error messages then the problem must be located within your email program.

Since passwd seems to fix the problem you can try the following. It should work to resolve your issues.

Create a script that has one line for each user
Code:

passwd user1 < pwfix
passwd user2 < pwfix
...
passwd usern < pwfix

create a file named pwfix that contains the following 2 lines
Code:

thisisanewpassword
thisisanewpassword

execute the script created to set every users password to thisisanewpassword

then run the chpasswd command to change every user to their real password.


To create the passwd script file file you could use

Code:

awk -F ":" '{print "passwd " $1 " < pwfix"}' < userlist.txt > runthisfirst.sh
chmod 766 runthisfirst.sh
sh runthisfirst.sh
chpasswd < userlist.txt

You will still need the second file mentioned above that has the temporary password defined in it.

Note: Check the contents of runthisfirst.sh to check it's contents. Any typo on the awk line will prevent it from having the correct output.

Feetloaf 07-15-2010 07:20 PM

Thanks for the passwd tips; that's pretty similar to what I'd been doing in the past. But I was after chpasswd because it seemed more elegant, and would let me export a file directly from a spreadsheet or db and let me pump it into /etc/passwd & /etc/shadow with a one-liner command.

The solution turned out to be the "newusers" command. It wants the input file to be in the format of /etc/passwd, which isn't quite as simple as I'd like, but using, say Ooo Base, it would be easy enough to generate a large list of users with randomly generated passwords and output a file that lets me use a one-liner.


All times are GMT -5. The time now is 09:59 PM.