<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Changing multiple passwords in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/changing-multiple-passwords/m-p/2651408#M836192</link>
    <description>Well if you're going to spell it out for me, even I can understand it.  My only remaining concern is that the script increments the user id by 1, and assigns a new number.  I'm changing passwords on existing accounts, so I don't necessarily need to assign new user id's (though I can it's not critical), but I do need to overwrite the existing entry in the password file with the new password.  Sorry for my ignorance but the &amp;gt;&amp;gt; to the password file will overwrite the correct entry?  These accounts are not contiguous and are a small subset of a password file with 4000 accounts.</description>
    <pubDate>Thu, 24 Jan 2002 16:41:55 GMT</pubDate>
    <dc:creator>Terrence</dc:creator>
    <dc:date>2002-01-24T16:41:55Z</dc:date>
    <item>
      <title>Changing multiple passwords</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/changing-multiple-passwords/m-p/2651401#M836185</link>
      <description>I need to batch change 500 passwords.  I have the user id's and passwords in a spreadsheet, but my humble scripting abilities are for naught.  (I'm fraught with naught).  Suggestions?</description>
      <pubDate>Wed, 23 Jan 2002 21:48:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/changing-multiple-passwords/m-p/2651401#M836185</guid>
      <dc:creator>Terrence</dc:creator>
      <dc:date>2002-01-23T21:48:20Z</dc:date>
    </item>
    <item>
      <title>Re: Changing multiple passwords</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/changing-multiple-passwords/m-p/2651402#M836186</link>
      <description>If you don't have a trusted system, then you can edit the /etc/passwd file directly.&lt;BR /&gt;&lt;BR /&gt;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.&lt;BR /&gt;&lt;BR /&gt;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.&lt;BR /&gt;&lt;BR /&gt;-- Rod Hills</description>
      <pubDate>Wed, 23 Jan 2002 21:58:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/changing-multiple-passwords/m-p/2651402#M836186</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2002-01-23T21:58:35Z</dc:date>
    </item>
    <item>
      <title>Re: Changing multiple passwords</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/changing-multiple-passwords/m-p/2651403#M836187</link>
      <description>Hi Terry,&lt;BR /&gt;&lt;BR /&gt;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&lt;BR /&gt;&lt;BR /&gt;echo "test1234te" |/usr/lbin/makekey&lt;BR /&gt;&lt;BR /&gt;This will generate an encrypted word that can be used as the second field in the /etc/passwd file on non-trusted systems.&lt;BR /&gt;&lt;BR /&gt;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.&lt;BR /&gt;&lt;BR /&gt;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.&lt;BR /&gt;&lt;BR /&gt;Hope this will give you some direction.&lt;BR /&gt;&lt;BR /&gt;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.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;-Sri</description>
      <pubDate>Wed, 23 Jan 2002 22:31:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/changing-multiple-passwords/m-p/2651403#M836187</guid>
      <dc:creator>Sridhar Bhaskarla</dc:creator>
      <dc:date>2002-01-23T22:31:38Z</dc:date>
    </item>
    <item>
      <title>Re: Changing multiple passwords</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/changing-multiple-passwords/m-p/2651404#M836188</link>
      <description>...forgot one more thing.. make sure the string you supply to makekey is of 10 char length including salt. For ex., if your password is only of 6 char length say test12, then you would do the following,&lt;BR /&gt;&lt;BR /&gt;echo "test12\0\0te" |/usr/lbin/makekey&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;-Sri</description>
      <pubDate>Wed, 23 Jan 2002 22:35:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/changing-multiple-passwords/m-p/2651404#M836188</guid>
      <dc:creator>Sridhar Bhaskarla</dc:creator>
      <dc:date>2002-01-23T22:35:39Z</dc:date>
    </item>
    <item>
      <title>Re: Changing multiple passwords</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/changing-multiple-passwords/m-p/2651405#M836189</link>
      <description>Thanks guys, but I was really looking for a piece of script that would automatically enter in each user id using the password command and then the script would feed in the password.  Since I have the user accounts and passwords in a text file I wanted to automate what I usually do manually since there are so many.</description>
      <pubDate>Thu, 24 Jan 2002 15:37:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/changing-multiple-passwords/m-p/2651405#M836189</guid>
      <dc:creator>Terrence</dc:creator>
      <dc:date>2002-01-24T15:37:48Z</dc:date>
    </item>
    <item>
      <title>Re: Changing multiple passwords</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/changing-multiple-passwords/m-p/2651406#M836190</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I believe Sridhar has already given you the solution&lt;BR /&gt;1) how to generate the encrypted password from the cleartext password&lt;BR /&gt;2) how to write a script to replace the password field in /etc/passwd ith the encrypted password.&lt;BR /&gt;&lt;BR /&gt;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:&lt;BR /&gt;&lt;BR /&gt;NOTE: This is off my head. You must use a sample passwd file to test this on.&lt;BR /&gt;&lt;BR /&gt;======================================&lt;BR /&gt;#!/sbin/sh&lt;BR /&gt;&lt;BR /&gt;uid=1000 # Starting uid&lt;BR /&gt;for line in `cat accounts.txt` # accounts.txt contains userid:passwd entries&lt;BR /&gt;do&lt;BR /&gt;  user=`echo $line|cut -d: -f1`&lt;BR /&gt;  passwd=`echo $line|cut -d: -f2`&lt;BR /&gt;  encrypted=`echo $passwd|makekey # use Sridhar's method&lt;BR /&gt;  if ! grep "^$user:" /etc/passwd&lt;BR /&gt;  then&lt;BR /&gt;    echo $user:$encrypted:$uid:20:$user account:/home/$user:/usr/bin/ksh &amp;gt;&amp;gt; /etc/passwd&lt;BR /&gt;    uid=`expr $uid+1`&lt;BR /&gt;  else&lt;BR /&gt;    newline=`grep "^$user:" /etc/passwd | awk '{print $1":"$encrypted":"$2":"$3":"$4":"$5":"$6":"$7}'`&lt;BR /&gt;    grep -v "^user:" &amp;gt; /tmp/passwd.tem&lt;BR /&gt;    echo $newline &amp;gt;&amp;gt; /tmp/passwd.tem&lt;BR /&gt;    mv -f /tmp/passwd.tem /etc/passwd&lt;BR /&gt;  fi&lt;BR /&gt;done&lt;BR /&gt;======================================&lt;BR /&gt;&lt;BR /&gt;Hope this helps. Regards.&lt;BR /&gt;&lt;BR /&gt;Steven Sim Kok Leong</description>
      <pubDate>Thu, 24 Jan 2002 15:52:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/changing-multiple-passwords/m-p/2651406#M836190</guid>
      <dc:creator>Steven Sim Kok Leong</dc:creator>
      <dc:date>2002-01-24T15:52:04Z</dc:date>
    </item>
    <item>
      <title>Re: Changing multiple passwords</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/changing-multiple-passwords/m-p/2651407#M836191</link>
      <description>Hi Terry,&lt;BR /&gt;&lt;BR /&gt;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.&lt;BR /&gt;&lt;BR /&gt;...&lt;BR /&gt;passwd=`echo $line|cut -d: -f2` &lt;BR /&gt;salt=`echo $passwd|cut -c 3-4`&lt;BR /&gt;encrypted=`echo "${passwd}${salt}" |/usr/lbin/makekey`&lt;BR /&gt;...&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;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.&lt;BR /&gt;&lt;BR /&gt;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.&lt;BR /&gt;&lt;BR /&gt;-Sri&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 24 Jan 2002 16:17:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/changing-multiple-passwords/m-p/2651407#M836191</guid>
      <dc:creator>Sridhar Bhaskarla</dc:creator>
      <dc:date>2002-01-24T16:17:09Z</dc:date>
    </item>
    <item>
      <title>Re: Changing multiple passwords</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/changing-multiple-passwords/m-p/2651408#M836192</link>
      <description>Well if you're going to spell it out for me, even I can understand it.  My only remaining concern is that the script increments the user id by 1, and assigns a new number.  I'm changing passwords on existing accounts, so I don't necessarily need to assign new user id's (though I can it's not critical), but I do need to overwrite the existing entry in the password file with the new password.  Sorry for my ignorance but the &amp;gt;&amp;gt; to the password file will overwrite the correct entry?  These accounts are not contiguous and are a small subset of a password file with 4000 accounts.</description>
      <pubDate>Thu, 24 Jan 2002 16:41:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/changing-multiple-passwords/m-p/2651408#M836192</guid>
      <dc:creator>Terrence</dc:creator>
      <dc:date>2002-01-24T16:41:55Z</dc:date>
    </item>
    <item>
      <title>Re: Changing multiple passwords</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/changing-multiple-passwords/m-p/2651409#M836193</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;This else portion of the script takes care of that:&lt;BR /&gt;&lt;BR /&gt;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&lt;BR /&gt;grep -v "^user:" &amp;gt; /tmp/passwd.tem # creates a temporary passwd file with all existing entries except the line containing the user to be modified&lt;BR /&gt;echo $newline &amp;gt;&amp;gt; /tmp/passwd.tem # inserts the line containing the original fields but with the encrypted password substituted into the temporary password file&lt;BR /&gt;mv -f /tmp/passwd.tem /etc/passwd # overwrites the actual password file with the temporary password file&lt;BR /&gt;&lt;BR /&gt;uids need not be in numerically ascending order in the password file.&lt;BR /&gt;&lt;BR /&gt;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.&lt;BR /&gt;&lt;BR /&gt;Hope this helps. Regards.&lt;BR /&gt;&lt;BR /&gt;Steven Sim Kok Leong</description>
      <pubDate>Thu, 24 Jan 2002 16:49:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/changing-multiple-passwords/m-p/2651409#M836193</guid>
      <dc:creator>Steven Sim Kok Leong</dc:creator>
      <dc:date>2002-01-24T16:49:16Z</dc:date>
    </item>
    <item>
      <title>Re: Changing multiple passwords</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/changing-multiple-passwords/m-p/2651410#M836194</link>
      <description>Brilliant!  I completely misread the else statement, I thought it was a fail-safe in case the account didn't already exist.  Thanks for all the help, you guys just saved me from carpal tunnel.</description>
      <pubDate>Thu, 24 Jan 2002 17:30:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/changing-multiple-passwords/m-p/2651410#M836194</guid>
      <dc:creator>Terrence</dc:creator>
      <dc:date>2002-01-24T17:30:25Z</dc:date>
    </item>
    <item>
      <title>Re: Changing multiple passwords</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/changing-multiple-passwords/m-p/2651411#M836195</link>
      <description />
      <pubDate>Thu, 24 Jan 2002 17:38:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/changing-multiple-passwords/m-p/2651411#M836195</guid>
      <dc:creator>Sridhar Bhaskarla</dc:creator>
      <dc:date>2002-01-24T17:38:24Z</dc:date>
    </item>
    <item>
      <title>Re: Changing multiple passwords</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/changing-multiple-passwords/m-p/2651412#M836196</link>
      <description>Terry,&lt;BR /&gt;&lt;BR /&gt;If you're on a trusted system using HP-UX 11 you can use the command:&lt;BR /&gt;/usr/sam/lbin/usermod.sam -p`echo "aaaa1111te" |/usr/lbin/makekey` smithj&lt;BR /&gt;to set the password for smithj to aaaa1111.  This is probably safer than fiddling /etc/passwd directly even for a non trusted system&lt;BR /&gt;&lt;BR /&gt;Rod</description>
      <pubDate>Fri, 24 May 2002 07:52:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/changing-multiple-passwords/m-p/2651412#M836196</guid>
      <dc:creator>Rod McLean</dc:creator>
      <dc:date>2002-05-24T07:52:19Z</dc:date>
    </item>
  </channel>
</rss>

