Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[TIP] Random passwords generation
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
anigel
Bodhisattva
Bodhisattva


Joined: 14 Apr 2003
Posts: 1889
Location: Un petit bled pas loin de Limoges ;-)

PostPosted: Tue Oct 04, 2005 5:25 pm    Post subject: [TIP] Random passwords generation Reply with quote

Hi,

Those of you that use Linux servers with lot of users have probably already had to deal with the random password generation problem. There are a few utilities available over the net, but they all lack at least one of the following requirements :


  • generated passwords must have a reasonable length.
  • generated passwords must be formed with really random characters, not only randomized letters.
  • it must be fast enough to generate nearly 1000 password in less than 30 minutes (this is why I couldn't continue with apg).
  • and, most important, it must be able to generate both the "clear text" and th encrypted version of the password.


I found the solution in the openssl software suite. It's standard enough to be found on most linux systems, in a word : it was what I was looking for ;-). These are the 2 magical command lines you can use in your scripts.

Code:
MY_PASSWORD=`openssl rand -base64 6`
MY_CRYPTED_PASSWORD=`echo $MY_PASSWORD | openssl passwd -stdin`


These commands will create, at a decent rate, some passwords, and their encrypted version, to be re-injected in the system, as follows :

Code:
usermod -p $MY_CRYPTED_PASSWORD $USER


You just have to inform $USER of his password, and that's it !

Just a little tip, but very practical for me ;-)
_________________
Il y a 10 sortes d'individus en ce bas-monde : ceux qui causent binaire, et les autres.
Back to top
View user's profile Send private message
robbyjo
Guru
Guru


Joined: 06 Apr 2003
Posts: 462

PostPosted: Tue Oct 04, 2005 6:46 pm    Post subject: Reply with quote

Great tip! Thanks a lot! :D I'll definitely use it...
Back to top
View user's profile Send private message
DNAspark99
Guru
Guru


Joined: 03 Sep 2004
Posts: 321

PostPosted: Tue Oct 04, 2005 8:03 pm    Post subject: Reply with quote

always found this script pretty useful for this purpose, not too sure where i got it but i've been using it for years.... run it, get a randpass...but you have to set the passwd for the user by hand :\

randpass.sh:
Code:

#!/bin/bash

LENGTH="8"
MATRIX="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"

while [ "${n:=1}" -le "$LENGTH" ]
do
     PASS="$PASS${MATRIX:$(($RANDOM%${#MATRIX})):1}"
     let n+=1
done

echo "$PASS"
exit 0

Back to top
View user's profile Send private message
destr0yr
Tux's lil' helper
Tux's lil' helper


Joined: 29 Nov 2003
Posts: 80
Location: Kelowna, BC.

PostPosted: Wed Oct 05, 2005 12:41 am    Post subject: Reply with quote

emerge pwgen

works for me.
Back to top
View user's profile Send private message
j-m
Retired Dev
Retired Dev


Joined: 31 Oct 2004
Posts: 975

PostPosted: Wed Oct 05, 2005 9:03 pm    Post subject: Reply with quote

Code:
emerge app-admin/makepasswd


Works for me... :lol:
Back to top
View user's profile Send private message
anigel
Bodhisattva
Bodhisattva


Joined: 14 Apr 2003
Posts: 1889
Location: Un petit bled pas loin de Limoges ;-)

PostPosted: Fri Oct 07, 2005 4:34 pm    Post subject: Reply with quote

j-m wrote:
Code:
emerge app-admin/makepasswd


Works for me... :lol:


I used this software a few months ago, but I had problems to convert the passwords into MD5 hash (had to use openssl to do that), for use in a mysql backend. That's why using only openssl is very convenient : it can be used to cryt in a lot of ways (sorry if my english isn't perfect :lol:).
_________________
Il y a 10 sortes d'individus en ce bas-monde : ceux qui causent binaire, et les autres.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum