Operating System - HP-UX
1822357 Members
5605 Online
109642 Solutions
New Discussion юеВ

Non-interactive mode Pwd change of a user

 
santosh11
Occasional Visitor

Non-interactive mode Pwd change of a user

Hello Experts,

I am very new to HPUX system and looking for a command to set the user constant password (non-interactive mode , i mean terminal should not prompt for to type the password to newPassword and confirm Password).

When i was using the command in terminal to set the pwd of a user "echo "Welcome1234" | passwd "John"  though its working but command prompting for pwd and new pwd ; also i tried using below command to set the non-interactive mode password,

/usr/lbin/modprpw -v -l john -s Welcome1234. but the Output of the terminal is "modprpw: error in argument; check before and after John"

Appreciate any help in advance !

 

4 REPLIES 4
Steven Schweda
Honored Contributor

Re: Non-interactive mode Pwd change of a user

> [...] looking for a command to set the user constant password
> (non-interactive mode [...]

   I'd expect a Forum search for terms like, say:
      change password script
to find a suggestion or two in a couple of previous threads on this
topic.


> /usr/lbin/modprpw -v -l john -s Welcome1234. but the Output of the
< terminal is "modprpw: error in argument; check before and after John"

   I'd avoid modprpw, and I don't have an HP-UX system running at the
moment, so I know nothing, but who says that modprpw has a "-s" option?

      man modprpw

   My quick Web search found, for example:
      https://nixdoc.net/man-pages/HP-UX/man1m/modprpw.1m.html
where I see no such option.  (Note that "-s" is "after John" in your
failing command.)

Re: Non-interactive mode Pwd change of a user

You may want to try to use a "here" script to accomplish it.

As a non-root user you will be asked to type in the old password, and 2-times the new one:

E.g. (can┬┤t test as i don┬┤t have access to HPUX systems anymore):

#!/sbin/sh
username="John" pw="old_password" new_pw="Welcome1234" passwd ${username} << EOD ${pw} ${new_pw} ${new_pw} EOD

 



I work at HPE
HPE Support Center offers support for your HPE services and products when and how you need it. Get started with HPE Support Center today.
[Any personal opinions expressed are mine, and not official statements on behalf of Hewlett Packard Enterprise]
Accept or Kudo
Steven Schweda
Honored Contributor

Re: Non-interactive mode Pwd change of a user

> You may want to try to use a "here" script [...]

   That's a "here document" (which is used in a script).

      https://en.wikipedia.org/wiki/Here_document

   The problem with that is when the program ("passwd" in this case)
reads from the user's terminal device rather than the process stdin.
Like you, I can't test it at the moment, but I'd guess that that's why
practically all the suggestions for similar queries over many years have
involved using "expect".

> As a non-root user [...]

If he's specifying a user name, then he'd better not be a non-root
user.

Steven Schweda
Honored Contributor

Re: Non-interactive mode Pwd change of a user

> [...] echo "Welcome1234" | passwd "John" though its working but
> command prompting for pwd and new pwd ; [...]

   I doubt that that's working.  The reason that "passwd" might be
prompting with "New password: " and "Re-enter new password:" is that
it's ignoring your piped input.  (I claim.)  If you put in some
_different_ string at the prompts, then I suspect that you'll find that
the user's password has been changed to whatever you put in at the
prompts, _not_ what's in your "echo" command.  That's what I saw on my
system:

dyi# uname -a
HP-UX dyi B.11.31 U ia64 4235313755 unlimited-user license

   If you decide to try a method which I'd expect to work:

      http://hpux.connect.org.uk/hppd/hpux/Tcl/expect-5.45/
      https://www.nist.gov/services-resources/software/expect
      https://sourceforge.net/projects/expect/files/

   Sadly, "expect" does seem to have a bunch of prerequisites, so using
"depothelper" from the HP-UX Porting and Archive Centre might be the
best way for someone who is "very new to HPUX system" to get it.  Should
be educational.