Scripting HP-UX User Account Creation

By | August 17, 2013

This is going to be a short one but it took me a while to find the information here so I figured it would be nice to put it all in one place. When creating accounts in HP-UX it's nice to be able to script them, especially the passwords. But HP-UX doesn't seem to have a handy way to script this like "passwd --stdin" on RHEL.

Luckily HP-UX has a tool called makekey which can make a password has. It does have some unfortunate limitations. It's passwords need to be exactly 8 characters and your choice of salts is limited from 00-99 (and must be two digits). But utilizing this command can allow you to optimize HP-UX to speed up user account creation.

So the basic form is like this:

useradd ... -p `echo 8digitpw## | /usr/lbin/makekey` <username>
passwd -f <username>

Let's explain this. "8digitpw" is your 8 digit initial password. "##" is your two digit numeric salt. Everything in between the `...` will create a has to be placed for a password on the system. And "passwd -f <username>" will set a flag in HP-UX forcing the user to change their password upon next log in (where they'll be able to set a longer password).

Bonus use "usermod ... -p `echo 8digitpw## | /usr/lbin/makekey` <username>" to reset passwords (do "passwd -f <username>" again to make them change it upon next login).


One thought on “Scripting HP-UX User Account Creation

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.