Topics: AIX, Security, System Admin
mkpasswd
An interesting open source project is Expect. It's a tool that can be used to automate interactive applications.
You can download the RPM for Expect can be downloaded from
http://www.perzl.org/aix/index.php?n=Main.Expect, and the home page for Expect is http://www.nist.gov/el/msid/expect.cfm.
A very interesting tool that is part of the Expect RPM is "mkpasswd". It is a little Tcl script that uses Expect to work with the passwd program to generate a random password and set it immediately. A somewhat adjusted version of "mkpasswd" can be downloaded here. The adjusted version of mkpasswd will generate a random password for a user, with a length of 8 characters (the maximum password length by default for AIX), if you run for example:
To see the interactive work performed by Expect for mkpasswd, use the -v option:# /usr/local/bin/mkpasswd username sXRk1wd3
By using mkpasswd, you'll never have to come up with a random password yourself again, and it will prevent Unix system admins from assigning new passwords to accounts that are easily guessible, such as "changeme", or "abc1234".# /usr/local/bin/mkpasswd -v username spawn /bin/passwd username Changing password for "username" username's New password: Enter the new password again: password for username is s8qh1qWZ
Now, what if you would want to let "other" users (non-root users) to run this utility, and at the same time prevent them from resetting the password of user root?
Let's say you want user pete to be able to reset other user's passwords. Add the following entries to the /etc/sudoers file by running visudo:
# visudo
Cmnd_Alias MKPASSWD = /usr/local/bin/mkpasswd, \
! /usr/local/bin/mkpasswd root
pete ALL=(ALL) NOPASSWD:MKPASSWD
This will allow pete to run the /usr/local/bin/mkpasswd utility, which he can use to reset passwords.
First, to check what he can run, use the "sudo -l" command:
Then, an attempt, using pete's account, to reset another user's password (which is successful):# su - pete $ sudo -l User pete may run the following commands on this host: (ALL) NOPASSWD: /usr/local/bin/mkpasswd, !/usr/local/bin/mkpasswd root
Then another attempt, to reset the root password (which fails):$ sudo /usr/local/bin/mkpasswd mark oe09'ySMj
$ sudo /usr/local/bin/mkpasswd root Sorry, user pete is not allowed to execute '/usr/local/bin/mkpasswd root' as root.
If you found this useful, here's more on the same topic(s) in our blog:
- Changing maxuproc requires a reboot?
- How to unconfigure items after mksysb recovery using NIM
- Double X11 forwarding
- DSH fails with host key verification failed
- SCP Stalls
Interested in learning more?




