- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Changing multiple passwords
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
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
тАО01-23-2002 01:48 PM
тАО01-23-2002 01:48 PM
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-23-2002 01:58 PM
тАО01-23-2002 01:58 PM
Re: Changing multiple passwords
I've attached a c program when given a password as an argument on the command line, will display the encrypted form suitable to be placed in /etc/passwd.
I would copy the list of userid's and passwords to a text file and use shell or perl to drive the "c" program and to do the necessary "editting" on /etc/passwd.
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-23-2002 02:31 PM
тАО01-23-2002 02:31 PM
Re: Changing multiple passwords
You can use /usr/lbin/makekey to create encrypted passwords. For ex., if you want to create an encrypted word for the string "test1234", you would do it like this
echo "test1234te" |/usr/lbin/makekey
This will generate an encrypted word that can be used as the second field in the /etc/passwd file on non-trusted systems.
The last two characters "te" after the password test1234 are collectively called "salt". You need to pick a random salt for each user. Probably you can get it by taking the 2 and 3rd characters using the cut command.
You would use awk to get the user name and the regular password from your file, get the salt from the user name and encrypted password using makekey. Then you need to get the password line from /etc/passwd for the corresponding user and replace the second field with the encrypted password. You need to use a combination of awk and sed with it.
Hope this will give you some direction.
There is also another way. Use the software "expect". But that would be too much. You need to install it with dependencies and then write expect scripts. You can get expect from the HP's distribution site.
-Sri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-23-2002 02:35 PM
тАО01-23-2002 02:35 PM
Re: Changing multiple passwords
echo "test12\0\0te" |/usr/lbin/makekey
-Sri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-24-2002 07:37 AM
тАО01-24-2002 07:37 AM
Re: Changing multiple passwords
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-24-2002 07:52 AM
тАО01-24-2002 07:52 AM
SolutionI believe Sridhar has already given you the solution
1) how to generate the encrypted password from the cleartext password
2) how to write a script to replace the password field in /etc/passwd ith the encrypted password.
Your script can go along ehse lines. Assuming a data file containing "userid:passwd" in each row and assuming that you are not using trusted HP-UX (which uses shadowed password file), then you can write something like this:
NOTE: This is off my head. You must use a sample passwd file to test this on.
======================================
#!/sbin/sh
uid=1000 # Starting uid
for line in `cat accounts.txt` # accounts.txt contains userid:passwd entries
do
user=`echo $line|cut -d: -f1`
passwd=`echo $line|cut -d: -f2`
encrypted=`echo $passwd|makekey # use Sridhar's method
if ! grep "^$user:" /etc/passwd
then
echo $user:$encrypted:$uid:20:$user account:/home/$user:/usr/bin/ksh >> /etc/passwd
uid=`expr $uid+1`
else
newline=`grep "^$user:" /etc/passwd | awk '{print $1":"$encrypted":"$2":"$3":"$4":"$5":"$6":"$7}'`
grep -v "^user:" > /tmp/passwd.tem
echo $newline >> /tmp/passwd.tem
mv -f /tmp/passwd.tem /etc/passwd
fi
done
======================================
Hope this helps. Regards.
Steven Sim Kok Leong
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-24-2002 08:17 AM
тАО01-24-2002 08:17 AM
Re: Changing multiple passwords
You can use Steven's script. But there are few precautions to take. You need to use a salt to encrypt a password. The password should be of eight chars long if not you need to use the solution in my second post. Embed these lines in his script.
...
passwd=`echo $line|cut -d: -f2`
salt=`echo $passwd|cut -c 3-4`
encrypted=`echo "${passwd}${salt}" |/usr/lbin/makekey`
...
I wouldn't mv /tmp/passwd.tem to /etc/passwd through the script. Prepare /tmp/pass.tem. Copy /etc/passwd as /etc/passwd.sav. Edit /etc/passwd and delete all the users entries leaving the root and other system default entries. Then you can append /tmp/pass.tmp to /etc/passwd. If something is not working, you can always login as root and revert back to /etc/passwd.sav.
I would recommend to build the script on your own using the methods given in the forums. Because none of the scripts given in these forums are supported.
-Sri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-24-2002 08:41 AM
тАО01-24-2002 08:41 AM
Re: Changing multiple passwords
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-24-2002 08:49 AM
тАО01-24-2002 08:49 AM
Re: Changing multiple passwords
This else portion of the script takes care of that:
newline=`grep "^$user:" /etc/passwd | awk '{print $1":"$encrypted":"$2":"$3":"$4":"$5":"$6":"$7}'` # creates a line containing the original fields but with the encrypted password substituted
grep -v "^user:" > /tmp/passwd.tem # creates a temporary passwd file with all existing entries except the line containing the user to be modified
echo $newline >> /tmp/passwd.tem # inserts the line containing the original fields but with the encrypted password substituted into the temporary password file
mv -f /tmp/passwd.tem /etc/passwd # overwrites the actual password file with the temporary password file
uids need not be in numerically ascending order in the password file.
As Sridhar has pointed out, it is safer for you to create a passwd.sav, check through all the entries generated in it, make a backup of the existing /etc/passwd before overwriting it with a copy from passwd.sav.
Hope this helps. Regards.
Steven Sim Kok Leong
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-24-2002 09:30 AM
тАО01-24-2002 09:30 AM