linux-logo.jpgSometimes it’s necessary to create Linux user accounts in batch mode (fully automatic) but often newbies ask how to set password for a new user without entering it manually. Thanks to heaven command useradd can get password as an input parameter, but it should be encrypted.

In other words, to create Linux user account with password the following command will be useful:

useradd -m -p encryptedPass username

I know at least two ways to get password encrypted. The first one is to use perl crypt(); function:

perl -e 'print crypt("password_to_be_encrypted", "salt"),"\n"'

which will give you an output sa3tHJ3/KuYvI.

The second way (more simple) is to use command:

openssl passwd password_to_be_encrypted

 

5 Comments

 

  1. Pingback : fluffigt.com » Blog Archive » Create .deb or .rpm from .tar.gz with checkinstall

  2. October 22, 2009  11:37 pm by Mark31 Reply

    Pressed on that omission,?Millstein scratched his head. ,

  3. July 12, 2010  11:13 am by Prajish S Reply

    Thanks.

    The second one worked fine.
    I did it this way
    useradd -m -p `openssl passwd $PASSWD` $USER

    $PASSWD - is password
    $USER - is user name.

    I read the values from a text file.

    Prajish S

  4. December 31, 2010  10:22 pm by blue handbags Reply

    I just discovered your blog today and I have to say that I am not disappointed. Keep up the good writing.

  5. January 25, 2011  10:51 pm by wallets for men Reply

    Only want to say your article is impressive. The clearness in your post is simply impressive and i can take for granted you are an expert on this subject. Well with your permission allow me to grab your rss feed to keep up to date with forthcoming post. Thanks a million and please keep up the admirable work.

Leave a reply

 

Your email address will not be published.