Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Automatic password changing help

Status
Not open for further replies.
Dec 10, 2003
121
US
Is there a way to change the root password on a SunOS 5.8 or 5.9 server? I was looking to change the root password automatically without any prompts and then email it to myself. I looked through a lot of posts but didn't see this question specifically asked. I just want to put a script in cron to run every 90 days to reset the root password and then email it to me so I know what it is (and possibly encrypt the email). I've programmed in ksh but not with "Expect". I've read some forums where Expect might be what I need... I haven't programmed in Perl in 6 years or more but the server has Perl on it...

Thank in advance! [3eyes]
 
Hi. Isn't this a bit of a risk? What if something happens to prevent you receiving the email notifying you of the change?
 
We have another root account we use (root2). So we could always reset it. There are two other accounts that are required to be reset every 90 days too, so even if I could script to change at least those two it would save a lot of time. Any ideas?
 
I use expect to change root passwords on a bunch of servers by simulating an interactive session, but I don't think that's what you want?

How will it know what to change the root password to? Are you planning to generate a random string or something? There's no reason why you can't use perl or ed or something to perform an automated edit of the /etc/shadow file with the new encrypted password. Just make sure it does it right! :)

To generate the key you can echo "newpasswAB" | /usr/lib/makekey where "AB" are any two randomly generated characters. They will appear as the first two characters of the encrypted password.

Annihilannic.
 
Yes that is exactly what I want to do is use Expect to change a bunch of root passwords. Yes I planned on incrementing a new password (maybe not random but something to change the number in the password). I'd like to use Expect but I have no idea how to use it. Do I need to load something?
 
Err, yes, probably expect? :) I do it from a Linux box where it is preinstalled, but you can get it from SunFreeware.com if you need to install it on Solaris It only needs to be installed on the client system.

Also, look into the autoexpect utility. It's a handy tool to record a sample session and create an expect script which you can then hack to make it more generic to work on all your servers.

Annihilannic.
 
Annihilannic, how do you use expect to change your root passwords? Is it a script?
 
Yes. As I said, try using autoexpect to create a sample script... then modify it to your needs.

Annihilannic.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top