- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: 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
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
08-07-2003 01:48 PM
08-07-2003 01:48 PM
change password without prompting
I want to use a script to change a user's password, but need to feed the command passwd a default password without prompting "new password?" and enter a password.
Can I use passwd command ,and just feed it a default password?
Or how do I replace the second field in /etc/passwd file with a default password? May be using "sed"?
Thanks,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2003 02:07 PM
08-07-2003 02:07 PM
Re: change password without prompting
Replacing the password field in /etc/passwd will work (of course you have to encode your password first). If you want to do the replacenent automatically be careful to use some kind of pattern, so you don't change other user's passwords.
Always test such utility, if you wipe /etc/passwd out - you're in trouble.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2003 02:13 PM
08-07-2003 02:13 PM
Re: change password without prompting
Can you please provide the detailed method to replace the 2nd field, ex, using sed?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2003 02:28 PM
08-07-2003 02:28 PM
Re: change password without prompting
http://search.cpan.org/author/SSNODGRA/Unix-ConfigFile-0.06/PasswdFile.pm
Your idea of editing the passwd field within the passwd file directly is "Mickey Mouse" and does not take into consideration either trusted systems or those running NIS or NIS+. That is why more robust solutions revolving around 'C' routines are really the preferred method.
You MIGHT be able to use the expect utility to run the passwd command. Passwd reads the passwd on file descriptor 3.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2003 03:14 PM
08-07-2003 03:14 PM
Re: change password without prompting
You can either have a hard coded password (default) in the script itself or pass the the new password to the script as a parameter.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2003 03:24 PM
08-07-2003 03:24 PM
Re: change password without prompting
awk -F: -v NAME=
$1 == NAME {$2=PASS; print $0; next }
{ print $0 }
' /etc/passwd > /tmp/passwd.new
Of course
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-10-2003 11:21 PM
08-10-2003 11:21 PM
Re: change password without prompting
We use this script:
#!/usr/local/bin/expect -f
# wrapper to make passwd(1) be non-interactive
# username is passed as 1st arg, passwd as 2nd, yo
# lo modifique para que el 3 argumento fuese la clave antigua
#
# Este es el dialogo de HP-UX
# Old passwd:
# New password:
# Re-enter new password:
set newpassword [lindex $argv 1]
spawn /usr/bin/passwd [lindex $argv 0]
# expect "New password:"
expect "Nueva clave:"
send "$newpassword\r"
# expect "Re-enter new password:"
expect "Vuelva a introducir la nueva clave:"
send "$newpassword\r"
expect eof
Dialog has been changed for spanish users.
To call this script:
autopasswd username newpassword
You can call this script from a loop that read the username and password from a file (don??t forget delete this file).
First you need install expect language.
I hope this help you.