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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is there any way to reset user's password via ksh? 2

Status
Not open for further replies.

pdtak

Technical User
Feb 25, 2008
63
US
Is there anyway that I can reset user's password using ksh command?
ie. emulate passwd command with a default password of abc123 or even null value?

> ssh server1 pwdadm user1 < /dev/null
or
> ssh server1 passwd user1 < /dev/null

neither worked for me.. but you know what I mean... I couldn't emulate enter keys.

I know this method is not recommended, but I've got more than 40 servers, and I don't want to login to every server to reset passwords.

Thanks.
 
What operating system?

You could script it using expect; search this forum and you'll find many examples. autoexpect is especially useful for generating an expect script.

Alternatively you could use perl or sed to update the encrypted password field in /etc/shadow to a known good value.

Annihilannic.
 
AIX 5.2
I don't know how to script in expect. korn or bourne shell is all I know.
 
With autoexpect you don't really need to know. It just records a sample session and writes the script for you. Then you can edit the resulting script to make it more general if required (i.e. to cater for different output from different servers, etc).

Annihilannic.
 
Annihilannic, thanks, sounds like I need to get this. How do you get this and have it for use. Sorry, I'm not familiar with expect at all.
 
password reads from /dev/tty not stdio. That is why expect or equivalent needs to be used. Personally, I would do it the first way annihilannic said, create the crypt text and install a small installer on each system that takes that as an argument.

The problem with expect is sometimes the error cases can be problematic if the system isn't totally homogeneous, like login prompts, shell prompts, aliases, etc.

That being said, I haven't used it but "screen" (which is a useful program by itself, had a way of multitscreening on several hosts so input could be typed in once and sent to the screen hosts. I am sure someone else has used this feature.

eugene
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top