Under Linux this job is very simple (use the '-p' option to useradd) but for Solaris I found ridiculous posts about admins using multi-line PERL scripts or even expect scripts to change a password. Expect?! EXPECT? I didn't even realise people still used such things ?!
Any how... here is a simple PERL one liner for updating the shadow file:
perl -pe 's/^USERNAME:.*?\:/USERNAME:NEWPASS\:/' /etc/shadow > /tmp/shadow.tmp && mv /tmp/shadow.tmp /etc/shadow
Note: This oneliner requires the password to be crypt()'d first. This can be done easily as a one liner in PERL:
[bisscuitt@asimov ~]$ perl -e "print crypt($ARGV[0], substr(rand(date),2));" PLAINTEXTPASSWORD
50kq0KhJnHwU2
Hope this helps someone.
Have Fun,
BiSScuiTT

0 comments:
Post a Comment