- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Change Password
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
Forums
Discussions
Discussions
Discussions
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
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
06-06-2005 03:49 PM
06-06-2005 03:49 PM
Change Password
How to change user's password in one line command with "passwd".
For example :
User : ky
Original Password : ky123
New Password : ky789
I want to change ky's passowrd in one line command with "passwd".
$passwd ky
Regards...KY
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2005 04:21 PM
06-06-2005 04:21 PM
Re: Change Password
I don't think it would be possible to change user's password in one command line, but you can achieve the same using "expect" script.
http://expect.nist.gov/
If you are wondering what is expect, then
Expect is a tool for automating interactive applications such as telnet, ftp, passwd, fsck, rlogin, tip, etc. Expect really makes this stuff trivial. Expect is also useful for testing these same applications. And by adding Tk, you can also wrap interactive applications in X11 GUIs.
Expect can make easy all sorts of tasks that are prohibitively difficult with anything else. You will find that Expect is an absolutely invaluable tool - using it, you will be able to automate tasks that you've never even thought of before - and you'll be able to do this automation quickly and easily.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2005 04:56 PM
06-06-2005 04:56 PM
Re: Change Password
#!/usr/local/bin/expect -f
set force_conservative 0
if {$force_conservative} {
set send_slow {1 .1}
proc send {ignore arg} {
sleep .1
exp_send -s -- $arg
}
}
set timeout 30
spawn $env(SHELL)
match_max 5000
send -- "passwd ky\r"
expect "Old password:"
send -- "ky123\r"
expect "New password:"
send -- "ky789\r"
expect "Re-type new password:"
send -- "ky789\r"
expect eof
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2005 08:37 PM
06-06-2005 08:37 PM
Re: Change Password
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2005 01:00 AM
06-07-2005 01:00 AM
Re: Change Password
As mentioned previously, expect is one good solution for this. I'm not crazy about expect's syntax though. If you're already familiar with perl, you should consider using the expect module for perl. All the power of expect with perl's syntax and regular expressions. Can't beat it...
To answer Victor's question as to why you'd want to do this. One client for whom I wrote a very similar script had over 200 Solaris and HP servers and a security policy stating that everyone had to change their passwords every 45 days. Manually changing the passwords literally took an entire day for some of the admins. After automation, it took 10 minutes.
HTH;
Doug
------
Senior UNIX Admin
O'Leary Computers Inc
linkedin: http://www.linkedin.com/dkoleary
Resume: http://www.olearycomputers.com/resume.html
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2005 01:10 AM
06-07-2005 01:10 AM
Re: Change Password
You can use undocumented command /usr/sam/lbin/usermod.sam -p "encrypted password" user_name"
You can user makekey to generate the encryped password. Else, you can use expect tool.
Anil
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2005 01:24 AM
06-07-2005 01:24 AM
Re: Change Password
It may be possible with input redirection to bypass this.
Try a combination like:
passwd < input_file
You may be able to automate the process. Make sure permissions are tight on that input file however.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2005 01:41 AM
06-07-2005 01:41 AM
Re: Change Password
You can't redirect the stdin to the password command. It won't work. You have to use expect, perl/expect, or /usr/sam/lbin/usermod -p...
Doug
------
Senior UNIX Admin
O'Leary Computers Inc
linkedin: http://www.linkedin.com/dkoleary
Resume: http://www.olearycomputers.com/resume.html
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2005 05:28 PM
06-07-2005 05:28 PM
Re: Change Password
Because I want to develop a session which let user can change UNIX's password with this session.
In my session, I have to combine user's old password and new password in one script, and let UNIX execute this script.
So I have to execute passwd command in one command line.
Is the command line correct ?
$passwd -r
Thanks...KY
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2005 12:44 AM
06-08-2005 12:44 AM
Re: Change Password
>> $passwd -r
No, it's not. The -r option specifies the name resolution protocol. The files option means you're using the /etc/passwd file. nis means NIS and NIS+ should, by now, be obvious. I would think there should be something for ldap, but I didn't see it in the man page.
As the posts have mentioned, in order to do what you're looking to do, you will need perl/expect or expect. At this point, even the /usr/lbin/usermod -p won't work because that requires root privileges...
HTH;
Doug
------
Senior UNIX Admin
O'Leary Computers Inc
linkedin: http://www.linkedin.com/dkoleary
Resume: http://www.olearycomputers.com/resume.html
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2005 09:14 PM
06-17-2005 09:14 PM
Re: Change Password
i will tell you an option, but the security is a problem... still if you need you can try this
after creating a user...
issue
# passwd -d -f
-d Allow user to login without a password by deleting it. In untrusted mode this unlocks/activates the user account if found locked/deactivated.
-f Force user to change password upon next login by expiring the current password
so that the user will enter the password at first logon and the administrator need not worry about the user's password part.
Regards
Vinod K