Random Strong Password Generator

From SME Server
Jump to: navigation, search



This contrib provides a new shell command/tool called randpw, which is a Random Strong Password Generator. randpw can generate strong passwords of any given length based on a randomized set of ASCII characters and symbols.


Contrib 9:
The latest version of randpw is available in the SME repository, click on the version number(s) for more information.


Important.png Note:
Please be aware that the current available version in the smecontribs repo is broken. Please see here for how the code should look like. Install the contrib and change it to match the code

The installation procedure for both SME 8 and SME 9 are the same. To install randpw enter the following command as root:

yum install randpw --enablerepo=smecontribs

After installation the randpw tool is immediately available to be used.


The randpw command requires a positive number as an argument. This number stands for the length of the to be generated password. Although any positive number can be given, a sensible length for a password should be considered. e.g. SME user passwords have a minimum length of 7 and the MySQL root password has a length of 70. Obviously a user password length is limited to what is humanly reasonable to remember, where as automated mechanisms that require a password, such as site to site VPN connections or the above MySQL example, can have longer, and thus stronger, passwords.


randpw [n]


randpw 75

will result in a randomly generated password which is displayed on the console e.g.:



Generate a SME user password:

randpw 7

Generate a password and store it to an SME Server db key (or db key property):

config set MyStrongPassword `randpw 70`

please note the usage of the ` character (ASCII 96) and not the ' character.

Generate a password and write it to a file:

randpw 70 > mystrongpassword.txt

Generate a password and store it to a shell variable:

MYPASS=`randpw 70`

Failures to generate a password are being logged in /var/log/messages. This may be helpful if a certain routine passes a non valid argument to randpw.

Password strength check

You can check the strength of generated passwords here.

And if you would like to learn more in 2 minutes about predictability go here.

Optimization with haveged

The password is being generated based on a random selection of characters and numbers. The randomness in it's turn is based on several factors and a strong randomness is important to limit the predictability of a password, and thus strongness of a password. Simply put, the strongness of randomness can be compared to a sheet of white paper with dots. The more dots, the more lines and combination of dots one can create.

"Dots" (entropy) are being collected by user activity like keyboard, mouse and other interaction and constantly updated in a /dev/ device. Since SME Server has little of such interaction (especially Virtial Machines), the "DOT level" may become low, and we don't want that for it will limit the number of combinations the randomizer can make between dots. As a reference, a normal level of dots averages between 2500 and 3500.

The Haveged deamon will help to increase/maintain the level of dots, especially on a headless server where there is little user interaction with physical keyboards, mice etc. Please read here for more information about the Haveged daemon and technical inner working.

It is recommended to install the Haveged next to randpw to ensure there are enough dots available for randpw to generate a strong password.

Haveged is available from the epel repository. To install it you have to enable the epel repository as described here.


Then you can install Haveged:

yum install haveged --enablerepo=epel

Start at boot

To make have haveged start at boot, enter the following commands:

ln -s /etc/rc.d/init.d/e-smith-service /etc/rc7.d/S99haveged
config set haveged service
config setprop haveged status enabled

Then start to the haveged service without rebooting

service haveged start


This contrib can be discussed on the forums here


Please raise bugs under the SME-Contribs section in bugzilla and select the randpw component or use this link .

9868SME Contribs9.1CONFIRMEDrandpw multiple issues


Only released version in smecontrib are listed here.

randpw Changelog: SME 9 (smecontribs)

2015/07/25 stephane de Labrusse 0.0.4-1
- openssl is now used to generate the password

- You must give an argument greater or equal than 8

2014/10/08 stephane de Labrusse 0.0.3-1
- new options added to prevent No argument, a negative number,
- zero and non integer argument or a no integer argument part

- -1 0 123abc and abc by Hsing-Foo Wang hsingfoo@gmail.com
2014/10/07 stephane de Labrusse 0.0.1-1
- Initial relase, idea from Hsing-Foo Wang hsingfoo@gmail.com