The other day I couldn’t remember what package provided the mkpasswd binary…..
yum whatprovides */mkpasswd
yum install expect
mkpasswd -l 12
The above creates a password of length 12 with two uppercase letters, two numbers and one special character.
I was surprised to find the mkpasswd utility missing from my new installation of CentOS 6.4.
Yum has a feature called whatprovides, which can be used to find out which installable package provides some feature, utility or file. The below demonstrates its use. You just need to prefix ‘*/’ to the utility name that your searching for.
[root@server ~]# yum whatprovides */mkpasswd
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
base/filelists_db | 5.9 MB 00:00
extras/filelists_db | 10 kB 00:00
updates/filelists_db | 2.8 MB 00:00
expect-220.127.116.11-4.el6.x86_64 : A program-script interaction and testing utility
Repo : base
Filename : /usr/bin/mkpasswd
The output shows us that the expect package contains the mkpasswd utility.
[root@server ~]# yum install expect
Now I can quickly and easily generate strong passwords from the Linux command line. For example, the following command produces a password using the default set of arguments.
[root@server ~]# mkpasswd
A default password is 9 characters long. Each password will have at least 2 digits (numbers); 2 upper and 2 lowercase alphabetic characters; plus 1 special character, which in our example is an asterisk (‘*‘).