The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
Google UNIX.COM


UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Looking for a script to reset password soliberus SUN Solaris 3 05-11-2008 08:15 AM
Is it possible to write a script to reset user's password? pdtak Shell Programming and Scripting 1 02-25-2008 05:55 PM
I would like to reset my password matrixmadhan Post Here to Contact Site Administrators and Moderators 5 04-30-2007 07:46 PM
Not receiving my reset password whyaskedhere Forum Support Area for Unregistered Users & Account Problems 1 10-16-2005 08:20 AM
how to reset the password in solaris mallesh SUN Solaris 1 06-20-2005 03:16 PM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-26-2006
Registered User
 

Join Date: Dec 2006
Posts: 9
automation of Password reset

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.
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 12-26-2006
Registered User
 

Join Date: Dec 2006
Posts: 9
automation script for password reset

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
Reply With Quote
  #3 (permalink)  
Old 12-26-2006
_Spare_Ribs_'s Avatar
Registered User
 

Join Date: Dec 2006
Location: /dev/null
Posts: 72
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.

Code:
#! /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:

Code:
0     0     1     *     *     /full/path/of/script/password_change.sh
Reply With Quote
  #4 (permalink)  
Old 12-26-2006
_Spare_Ribs_'s Avatar
Registered User
 

Join Date: Dec 2006
Location: /dev/null
Posts: 72
I have replied here

http://www.unix.com/showthread.php?t=34014
Reply With Quote
  #5 (permalink)  
Old 12-26-2006
Registered User
 

Join Date: Dec 2006
Location: Maryland
Posts: 144
I tried that method , It did not work on AIX
Reply With Quote
  #6 (permalink)  
Old 12-26-2006
_Spare_Ribs_'s Avatar
Registered User
 

Join Date: Dec 2006
Location: /dev/null
Posts: 72
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.
Reply With Quote
  #7 (permalink)  
Old 12-26-2006
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,454
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
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 11:33 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0