- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Change Password without prompting
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-27-2008 11:04 PM
тАО04-27-2008 11:04 PM
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
Solved! Go to Solution.
- Tags:
- Password
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-27-2008 11:14 PM
тАО04-27-2008 11:14 PM
SolutionAre 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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-27-2008 11:32 PM
тАО04-27-2008 11:32 PM
Re: Change Password without prompting
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-27-2008 11:41 PM
тАО04-27-2008 11:41 PM
Re: Change Password without prompting
May not have it today though.
Cheers
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-27-2008 11:47 PM
тАО04-27-2008 11:47 PM
Re: Change Password without prompting
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-27-2008 11:51 PM
тАО04-27-2008 11:51 PM
Re: Change Password without prompting
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 :)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-28-2008 12:07 AM
тАО04-28-2008 12:07 AM
Re: Change Password without prompting
http://hpux.ece.ualberta.ca/hppd/hpux/Tcl/expect-5.43/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-28-2008 12:11 AM
тАО04-28-2008 12:11 AM
Re: Change Password without prompting
You'll have to make sense of it by accessing the portal site I posted in my last link.
For example expect requires tcltk.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-28-2008 08:52 PM
тАО04-28-2008 08:52 PM
Re: Change Password without prompting
#!/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";
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-28-2008 09:37 PM
тАО04-28-2008 09:37 PM
Re: Change Password without prompting
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-28-2008 10:08 PM
тАО04-28-2008 10:08 PM
Re: Change Password without prompting
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-28-2008 10:10 PM
тАО04-28-2008 10:10 PM
Re: Change Password without prompting
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-28-2008 11:20 PM
тАО04-28-2008 11:20 PM
Re: Change Password without prompting
Thanks for your help. Since my product will be installed in many customer places, I tried to remove the dependency with 'expect' command. So I directly change the /etc/passwd file by doing the following steps,
* My agent C code encrypt the password using crypt(password,salt); function. Following link contains some information about this,
http://www.sunmanagers.org/archives/1996/0603.html
* The generated encrypted password will be passed to a script. That script will directly change the /etc/passwd file with the encrypted password. Following are the content of the script which may be helpful for others,
#!/bin/sh
echo $#
if [ $# -ne 3 ]
then
echo "Usage : sh changePassword.sh
exit 1
fi
USER_NAME=$1
OLD_PASSWD=$2
NEW_PASSWD=$3
FILE_NAME='passwd'
FILE_FULL_PATH='/etc/passwd'
if [ ! -f $FILE_NAME.orig ]
then
cp -f $FILE_FULL_PATH $FILE_NAME.orig
fi
cp -f $FILE_FULL_PATH $FILE_NAME.bkup
OLD_LINE=`cat $FILE_FULL_PATH | grep $USER_NAME":"$OLD_PASSWD`
if [ "$OLD_LINE" != "" ]
then
OLD_DATA=`echo $OLD_LINE | cut -d ":" -f3-10`
NEW_LINE=$USER_NAME":"$NEW_PASSWD":"$OLD_DATA
cat $FILE_FULL_PATH | grep -v $USER_NAME":"$OLD_PASSWD > $FILE_NAME.tmp
echo $NEW_LINE >> $FILE_NAME.tmp
cp -f $FILE_NAME.tmp $FILE_FULL_PATH
chmod 644 $FILE_FULL_PATH
echo "Password for "$USER_NAME" has been changed successfully at "`date` >>chpwd.log
exit 0
else
echo "Could not find old entry." >>chpwd.log
exit 1
fi
Thanks,
Ramesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-29-2008 03:41 AM
тАО04-29-2008 03:41 AM
Re: Change Password without prompting
It may not be right place to ask solaris related question. I did the same thing in solaris and it is not working. In solaris, I have modified the /etc/shadow instead of /etc/passwd. Any help ?
Thanks,
Ramesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-29-2008 04:37 AM
тАО04-29-2008 04:37 AM
Re: Change Password without prompting
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-05-2008 01:15 AM
тАО05-05-2008 01:15 AM
Re: Change Password without prompting
Finally I got a command which accepts the password as arguments. Following are the command details,
/usr/sam/lbin/usermod.sam -p
/usr/sam/lbin/usermod.sam -p "xyZz5eiXOP3r." rameshj
Is there any issue on the above command ?
Thanks,
Ramesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-05-2008 01:29 AM
тАО05-05-2008 01:29 AM
Re: Change Password without prompting
In Hp-UX, unfortunately we only have:
usermod [-u uid [-o]] [-g group] [-G group [, group...]]
[-d dir [-m]] [-s shell] [-c comment] [-f inactive]
[-l new_logname] [-e expire] login
unline linux, solaris etc
hope this helps too!
kind regards
yogeeraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-05-2008 01:52 AM
тАО05-05-2008 01:52 AM
Re: Change Password without prompting
sorry for the confusion in my previous post.
the -p option do exist when using usermod.sam
SRV2:>/usr/sam/lbin/usermod.sam
User name must be specified
Usage: usermod.sam -p
- Tags:
- usermod.sam
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-05-2008 02:39 AM
тАО05-05-2008 02:39 AM
Re: Change Password without prompting
The attached program will generate the encrypted password up to 8 characters long. Passwords longer than 8 characters are undefined. usermod.sam will immediately expire a new password if there is no aging provided so use passwd -o and -n to set the aging, or modprpw -v to refresh the aging.
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-31-2008 04:07 PM
тАО10-31-2008 04:07 PM
Re: Change Password without prompting
MAKEKEY=/usr/lbin/makekey
read cpypwd?"enter your password again for verification: "
if [[ $cpypwd != $mypwd ]]; then
echo
echo "You have a lousy memory or you cannot type or both, try again"
else
break
fi
done
#. $mypwd needs to be 8 characters long
#. 10 <= $seed <= 23+59+10 (92)
#. so you are supplying a 2 character SEED
#. This gives you a 13 character encrpted pw
((seed=`date +%H+%M+10`))
echo "${mypwd}"${seed}|$MAKEKEY|read cryptpw
echo "We will use pw=[${mypwd}] aka $cryptpw for $loginid" >&2
rstat=`ssh $server "$SAMMOD -F -p $cryptpw $loginid; echo $?" 2>/dev/null`
if [[ $rstat -ne 0 ]]; then
echo "Password initialization failed for $loginid" >&2
fi