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.
[[email protected] ~]# 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-184.108.40.206-4.el6.x86_64 : A program-script interaction and testing utility Repo : base Matched from: Filename : /usr/bin/mkpasswd [[email protected] ~]#
The output shows us that the expect package contains the mkpasswd utility.
[[email protected] ~]# 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.
[[email protected] ~]# mkpasswd N5cZ8v*dq
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 (‘*‘).