HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- changing password in a script
Operating System - HP-UX
1833323
Members
2868
Online
110051
Solutions
Forums
Categories
Company
Local Language
back
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
back
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
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- 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-09-2006 02:13 PM
08-09-2006 02:13 PM
changing password in a script
Hi There
I want to change passwds for all users in a do loop to a same string using a script.
Any idea please
Thanks in advance
Nisar
I want to change passwds for all users in a do loop to a same string using a script.
Any idea please
Thanks in advance
Nisar
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2006 02:26 PM
08-09-2006 02:26 PM
Re: changing password in a script
You can do that by using /usr/sam/lbin/usermod.sam -p login_name
The password here is the encrypted password which you can generate by writing a small c program or other option is to ass a dummy user and assign the password that you want to say "test123" you have the encrypted password in the passwd field in /etc/passwd for that user.
Now take that string and write a while loop
while read i
do
/usr/sam/lbin/usermod.sam -p $i
done where /tmp/1 contains all the users whose password you want to set.
Cheers
Rajeev
The password here is the encrypted password which you can generate by writing a small c program or other option is to ass a dummy user and assign the password that you want to say "test123" you have the encrypted password in the passwd field in /etc/passwd for that user.
Now take that string and write a while loop
while read i
do
/usr/sam/lbin/usermod.sam -p
done
Cheers
Rajeev
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2006 03:06 PM
08-09-2006 03:06 PM
Re: changing password in a script
a) you can use this command to fill you file of accounts:
cat /etc/passwd | awk -F : '{ print $1 }' > output.file
b) Or try extending the command with passwd -f. With passwd -f you force each user to change the password at next login.
cat /output.file | passwd -f (* wild guess *)
Use pwck to verify /etc/passwd.
And copy your /etc/passwd file before starting.
http://docs.hp.com/en/B2355-60103/passwd.1.html
cat /etc/passwd | awk -F : '{ print $1 }' > output.file
b) Or try extending the command with passwd -f. With passwd -f you force each user to change the password at next login.
cat /output.file | passwd -f (* wild guess *)
Use pwck to verify /etc/passwd.
And copy your /etc/passwd file before starting.
http://docs.hp.com/en/B2355-60103/passwd.1.html
Support Fatherhood - Stop Family Law
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-11-2006 11:18 AM
08-11-2006 11:18 AM
Re: changing password in a script
Michael, your 'awk' approach needs to consider whether the system is configured to use NIS, netgroups, other repositories, etc. There may be /etc/passwd entries starting with '+' for example.
Also, 'passwd -f' requires a user name, as noted on the man page and usage message for passwd.
$ echo foo | passwd -f
Usage:
passwd [name]
passwd -r files [-F files] [name]
passwd -r files [-e [shell]] [-gh] [name]
passwd -r files -s [-a]
passwd -r files -s [name]
passwd -r files [-d|-l] [-f] [-n min] [-w warn] [-x max] name
passwd -r nis [-e [shell]] [-gh] [name]
passwd -r dce [-e [shell]] [-gh] [name]
Tools such as 'expect' (available at expect.nist.gov) can be helpful for such tasks. http://en.wikipedia.org/wiki/Expect has some examples of automating ftp and telnet sessions.
http://rodopi.floydrussell.com/events.html has a 'password script' section that shows an example of an expect script for performing such tasks. (I know nothing of this site; it just happened to show a simple example of such a script.)
Also, 'passwd -f' requires a user name, as noted on the man page and usage message for passwd.
$ echo foo | passwd -f
Usage:
passwd [name]
passwd -r files [-F files] [name]
passwd -r files [-e [shell]] [-gh] [name]
passwd -r files -s [-a]
passwd -r files -s [name]
passwd -r files [-d|-l] [-f] [-n min] [-w warn] [-x max] name
passwd -r nis [-e [shell]] [-gh] [name]
passwd -r dce [-e [shell]] [-gh] [name]
Tools such as 'expect' (available at expect.nist.gov) can be helpful for such tasks. http://en.wikipedia.org/wiki/Expect has some examples of automating ftp and telnet sessions.
http://rodopi.floydrussell.com/events.html has a 'password script' section that shows an example of an expect script for performing such tasks. (I know nothing of this site; it just happened to show a simple example of such a script.)
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP