07-12-2005 06:32 AM
I do not wish to install "expect" to do this. I am looking for perl code to set a user's password to some pre-determined inital value, wehreby the user will have to change their password the first time they login after that.
Solved! Go to Solution.
07-12-2005 06:37 AM
07-12-2005 07:15 AM
/usr/sam/lbin/usermod.sam -p "Dx3zsaXO3q22." username
I don't think any portion needs any explanation on this command.
UNIX because I majored in cryptology...
07-12-2005 08:37 AM
I tried several different iterations of piping, reading from stdin, and other hacks to see if I could pump data into the passwd command itself. But I firmly believe that the passwd command attempts to open the tty directly somehow using the tty driver (doesn't use stdin when reading a password from the user). I even tried to fake it out by putting it in a tty-less environment while using stdin to feed data to passwd. The passwd command still refused to read from a pipe or from any specific file descriptor. Therefore, it appears that the best solution would be to generate a predefined hash (and possibly use the usermod.sam utility to plug it in to the password file). I tested the usermod.sam command on both a trusted and a non-trusted system and it seems to work in both cases. Note that the hash format (including the strings which control aging and expiration in the hash) are pretty well documented in the passwd(4) man page.
07-14-2005 12:57 PM
You can use crypt to generate the password
or you can clip a default one thats incrypted out of the password or trusted /tcb/ directory files.
If you use a default one though make sure you run an extra command to force the users to change it.
07-14-2005 01:11 PM
echo "password1b" |/usr/lib/makekey
supbstitute the output into the usermodsam command and you can automate the whole thing :).
Note to use 8 char password 2 char salt when doing this.
Points are welcome