Hello Gurus
I have little challenge which I do not know how to address it. I have unix account on many servers (let's say over 25). These accounts expire every 60 days. Is there scripts that I can run from my "local computer" and pass a new password to it where it would change it for me on all servers?
Or maybe an application that I can use on my local machine to do that?!
actually expect is not written in Perl. It is Tcl based.
---------- Post updated at 17:55 ---------- Previous update was at 17:52 ----------
I would suggest you migrate to LDAP if possible. This will make your life so much easier and give you more options for managing accounts. If you don't centralize your accounts your going to have to customize a solution to update the passwords on each server. This can be done many ways but I would avoid using an expect script if possible. Most Unix variants these days have command line ways to update passwords with either clear text or encrypted passwords.
Here is one I wrote that allows you to enter the user to run as, username and password, then run the command on any files within the "host" files.
If you dont' have a linux box, I would suggest using one of the servers to run the script from. Unless you shared keys, you would have to type the root password for each.
#!/bin/bash
read -p "Username to run command as: " user
read -p "Username to change: " resetuser
read -s -p "Enter Password : " password
pass=$(perl -e 'print crypt($ARGV[0], "salt")' $password)
# connect each host and run command
for host in $(cat hosts.txt)
do
ssh -t $user@$host sudo /usr/sbin/usermod -p $pass $resetuser
done
You can remove the sudo portion if you are going to run it as root.