Sunday, May 5, 2024
 Popular · Latest · Hot · Upcoming
46
rated 0 times [  46] [ 0]  / answers: 1 / hits: 77013  / 3 Years ago, fri, november 12, 2021, 10:53:16

I am writing a script to add a large amount of users to a system. Part of this involves setting default passwords for each user. How can I set users' passwords without it prompting me for the password up front?



Unfortunately passwd doesn't seem to take an argument stating the new password to set. I'm using Ubuntu 11.10.


More From » password

 Answers
4

Try usermod:


usermod --password PASSWORD USERNAME

The only thing is this needs a pre-encrypted password string which you'd have to generate first.


In order to generate the encrypted password you can use openssl. For example:


usermod --password $(echo MY_NEW_PASSWORD | openssl passwd -1 -stdin) USERNAME

[#41976] Saturday, November 13, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
rieency

Total Points: 299
Total Questions: 116
Total Answers: 111

Location: Wales
Member since Tue, Dec 14, 2021
2 Years ago
rieency questions
Wed, Aug 25, 21, 15:17, 3 Years ago
Wed, Jun 23, 21, 04:37, 3 Years ago
Fri, Sep 30, 22, 12:07, 2 Years ago
Thu, Feb 24, 22, 00:50, 2 Years ago
Mon, Mar 28, 22, 13:28, 2 Years ago
;