Operating System - HP-UX
1753903 Members
10400 Online
108810 Solutions
New Discussion юеВ

Change Password without prompting

 
SOLVED
Go to solution
J Ramesh Kumar
Advisor

Change Password without prompting

Hi,

I require to change an user user password without prompting. Because I need to trigger the command from my program. Currently the linux has the following option,

/usr/sbin/usermod -p

But the -p option is not available in hp-ux. Is there any way to change the password without prompting ?

Thanks in advance for your help.

Thanks,
Ramesh
19 REPLIES 19
OFC_EDM
Respected Contributor
Solution

Re: Change Password without prompting

Think you're out of luck.

Are you changing password for same user across systems?

If so, All I can think of is to change the password on one system.

Then from the program Copy there entry from the password file onto the other systems.

Provided they're using the same UID on the other systems.

Also there may be more considerations if you're using Trusted mode etc.

We do have a script here which does this for a select group. I'll see if I can find it and see if there's any hints there.

But again there is the requirment to initially answer a prompt.

----------------------
There are utilities to automatically script responses to questions from commands.

Can't think of it right now but you may be able to use on of those.

Cheers
The Devil is in the detail.
J Ramesh Kumar
Advisor

Re: Change Password without prompting

Hi Kevin,

Thanks for the quick response. My exact requirement is, my application server will run one m/c and agent will run the hp-ux system. User can change their password from my application client. If he changes the password from the client, the server will send out the request to the agent which written in C code. The agent will trigger a command which will change the password on the hpux m/c. Please let me know, if you have any utilities for handling prompting issue.

Thanks,
Ramesh
OFC_EDM
Respected Contributor

Re: Change Password without prompting

I'm on it....I believe I had a script some years ago that did this. Trying to find it for you.

May not have it today though.

Cheers
The Devil is in the detail.
OFC_EDM
Respected Contributor

Re: Change Password without prompting

Found this old script. But it needs the product "expect" on the system.

The con is that you have to know what your prompts will be:

#!/bin/sh
# \
exec expect -f "$0" ${1+"$@"}
set password [lindex $argv 1]
spawn passwd [lindex $argv 0]
expect "assword:"
send "$password\r"
expect "assword:"
send "$password\r"
expect eof

Usage
changepasswd username 123456
The Devil is in the detail.
OFC_EDM
Respected Contributor

Re: Change Password without prompting

This question has been asked before in these forums.

Here's one thread
http://forums11.itrc.hp.com/service/forums/questionanswer.do?threadId=598850

In the Forum search use the keywords "expect passwd" and you'll get a few more hits.

Good luck.

(If you can post your solution once done it would benefit others...oh and points are nice too :)
The Devil is in the detail.
OFC_EDM
Respected Contributor

Re: Change Password without prompting

You can download the expect software for HP-UX from here.

http://hpux.ece.ualberta.ca/hppd/hpux/Tcl/expect-5.43/
The Devil is in the detail.
OFC_EDM
Respected Contributor

Re: Change Password without prompting

There's some dependencies. So look at those and install in order.

You'll have to make sense of it by accessing the portal site I posted in my last link.

For example expect requires tcltk.
The Devil is in the detail.
CharlesC
Advisor

Re: Change Password without prompting

Can you generate the password first then copy to the other machines through script?

#!/opt/perl/bin/perl

print "Salt code: ";
$VAR{salt}=<>; #first argument
print "Password: ";
$VAR{pass}=<>; #second argument
$VAR{pass}=crypt($VAR{pass}, $VAR{salt});
print "Result: ", $VAR{pass}, "\n";
What if...
J Ramesh Kumar
Advisor

Re: Change Password without prompting

Hi,

Is the salt can be anything ? If the salt code is given by user, how the system interpret the /etc/passwd file. I am planing to encrypt the password and directly write to /etc/passwd file. Here, I am struggling with the salt code.


Thanks,
Ramesh