- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Script for changing root passwd
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
10-20-2004 01:13 AM
10-20-2004 01:13 AM
Script for changing root passwd
I'm trying to change root passwd (I have many HP servers), using vipw:
#!/usr/bin/sh
export NEW=$(cat /tmp/pas) #this file contains a crypt passwd
vipw << EOF
/^root:
f:lct:$NEW^[x!
EOF
the problem is when I execute this script - error message: Input read error ...
any hints ?
rgs
Marcia Ferreira
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2004 01:30 AM
10-20-2004 01:30 AM
Re: Script for changing root passwd
Try usermod.sam instead.
# /usr/sam/lbin/usermod.sam -F -p encrypted_passwd root
Personally I think changing root password from a script is a dangerous thing to do.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2004 01:31 AM
10-20-2004 01:31 AM
Re: Script for changing root passwd
I know you can use ":" for ex(1) mode within
vi or vipw.
might want to test this script out using something other than root login.
best of luck
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2004 01:42 AM
10-20-2004 01:42 AM
Re: Script for changing root passwd
As told you have option of using
/usr/sam/lbin/sam.usermod -p "ebcrypted_pass" root
echo "anil1234te"|/usr/lbin/makekey Will give you the encrypted password. the first 8 chars is a password and last two chars are salt.
The other option is to use expect. Get it here.
http://hpux.connect.org.uk
Anil
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2004 01:42 AM
10-20-2004 01:42 AM
Re: Script for changing root passwd
if I can guess it right, it is nothing more than a wrapper to vi, with some additional code for lock/temp file creation, etc.
If you already have the encrypted password, you can try something like this
#!/usr/sbin/sh
NEW_PASS=$(cat /tmp/pas)
cp /etc/passwd /etc/passwd.save
awk -F: -v PASS=$NEW_PASS '$1 ~ /root/ {OFS=":";$2=PASS; print}' /etc/passwd.save > /etc/passwd
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2004 01:48 AM
10-20-2004 01:48 AM
Re: Script for changing root passwd
This will work
#!/usr/bin/sh
NEW_PASS=$(cat /tmp/pas)
awk -F: -v PASS=$NEW_PASS '{if ($1 == "root") {OFS=":";$2=PASS;print} else print }' /etc/passwd.save > /etc/passwd