RE: automatically generating an encrypted passwd for useradd -p

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 2003-12-02 at 08:35, Rigler, Steve wrote:

> Are you looking for a way to force the user to enter a password at
> next login or to automatically set the password to something?
> 
> If you're just looking for a way to create the hash, you can use
> a perl script like below.  Call it "gen_crypt.pl" and use it with
> usermod like "usermod -p $( gen_crypt.pl somepass ) username":
> 
> #!/usr/bin/perl
> 
> my $pass  = shift;
> my @salts = ( 'a' .. 'z', 'A' .. 'Z', 0 .. 9, '.', '/' );
> 
> print
>   crypt( $pass, join( "", map { $salts[ rand( scalar(@salts) ) ] } ( 1, 2 ) ) );


OpenSSL's passwd feature also works well as a one-liner.  :)

usermod -p `openssl passwd -1 <password>` <username>


-- 
Jason Dixon, RHCE
DixonGroup Consulting
http://www.dixongroup.net


-- 
redhat-list mailing list
unsubscribe mailto:redhat-list-request@xxxxxxxxxx?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list

[Index of Archives]     [CentOS]     [Kernel Development]     [PAM]     [Fedora Users]     [Red Hat Development]     [Big List of Linux Books]     [Linux Admin]     [Gimp]     [Asterisk PBX]     [Yosemite News]     [Red Hat Crash Utility]


  Powered by Linux