Hi,
Is there any way to automate the reset of passwords.I mean can we write some scripts and do it. Would be great if anybody can help in this regards.
Hi,
Is there any way to automate the reset of passwords.I mean can we write some scripts and do it. Would be great if anybody can help in this regards.
Hi,
I would like to write a script to automate the reset of password.Dont know whether it is possible ? if it is possible can anyone help me how to start.
Thanks In Advance
Hi,
Something like this should work. This probably isn't the best written shell script you're ever gonna see but I just knocked it out and it works for me
Read the comments in the code to see what each part is doing.
#! /bin/bash
#
# script to automate password reset
#
# declare variables
declare USERNAME="TEST" # This allows the username to be changed or multiple usernames specified by creating a new variable
declare TMP_VAR="" # Temporary variable we will use to store value of user check
#
echo "Start password reset script"
# first check to make sure user exists
TMP_VAR=`grep ^$USERNAME: /etc/passwd` > /dev/null > 2>&1
if [ "$TMP_VAR" = "" ];
then {
echo "User $USERNAME does not exist"
# exit cleanly with result code 1 (not successful)
exit 1;
}
else {
# if username exists proceed to reset password
passwd --stdin $USERNAME < pass_file # pass_file is the file where the password is stored you want to use
}
fi
# exit cleanly and return 0 result code
exit 0;
Since you say you want to "automate" this change I'm thinking it's going to be done on a regular basis so my opinion is to add it to the crontab for root, or someone who has privileges to change user passwords. I don't know how much you know about crontabs and their purpose and so on but you can just search the forum/google and you should see plenty of examples. If you wanted to schedule the job to run at midnight on the first of every month your entry into the crontab might look like this:
0 0 1 * * /full/path/of/script/password_change.sh
I have replied here
I tried that method , It did not work on AIX
Well, to be fair this wasn't posted under the AIX section of the forum and the O/S wasn't specified so I took the nearest one I had to hand which was FC5
Can you please post the output when you try and run the program?
Thanks.
yakyaj, our rules state:
(4) Do not 'bump up' questions if they are not answered promptly. No duplicate or cross-posting and do not report a post where your goal is to get an answer more quickly.
So please do not open two or more threads for one question. I have merged the threads.
Also here is a script that I posted a while back...
changepass automate password changes on multiple systems
Hi Ribs/Kapil/Perderabo,
Thanks for the heads up. Will try and let you know.
I need to do it in HP.
Thanks again
Perderabo,
Do you have this script using SSH and SCP by any chance? If so, can I have a copy of it?
Thank You!!!
Does anyone have a script to do this using SSH and SCP?