<?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: How to encrypt password in shell scripts ? in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-encrypt-password-in-shell-scripts/m-p/2740570#M67571</link>
    <description>Heres my use of crypt just using shell where fred contains the encrypted password - &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;ACCESS=/users/userpass&lt;BR /&gt;NAME=fred&lt;BR /&gt;echo "Please enter your root access password -&amp;gt; "                               &lt;BR /&gt;stty -echo                                                                      &lt;BR /&gt;read PASSWORD                                                                   &lt;BR /&gt;stty echo                                                                       &lt;BR /&gt;PASSIN=$(crypt $PASSWORD &amp;lt;$ACCESS/$NAME 2&amp;gt;/dev/null)                            &lt;BR /&gt;if [ $PASSWORD = $PASSIN ];then                                                 &lt;BR /&gt;echo "Thank You"                                                                &lt;BR /&gt;else  &lt;BR /&gt;exit&lt;BR /&gt;fi</description>
    <pubDate>Mon, 10 Jun 2002 11:23:02 GMT</pubDate>
    <dc:creator>Nick Wickens</dc:creator>
    <dc:date>2002-06-10T11:23:02Z</dc:date>
    <item>
      <title>How to encrypt password in shell scripts ?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-encrypt-password-in-shell-scripts/m-p/2740566#M67567</link>
      <description>Hi all,&lt;BR /&gt;&lt;BR /&gt;I've developed some scripts in which I need to embed the user name and password inside the scripts.  We really can't stand for such a big security hole!!  Is there any workaround solution(s) that I can encrypted the passwords inside the scripts?  Besides, changing password will be a nightmare if we embed the password inside the scripts !!!  Any idea?  I am think whether we can make use of the existing Unix password handling routines to accomplish this task !!!&lt;BR /&gt;&lt;BR /&gt;Please help, many thanks !!&lt;BR /&gt;&lt;BR /&gt;Chris,</description>
      <pubDate>Sun, 09 Jun 2002 08:20:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-encrypt-password-in-shell-scripts/m-p/2740566#M67567</guid>
      <dc:creator>Chris Fung</dc:creator>
      <dc:date>2002-06-09T08:20:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to encrypt password in shell scripts ?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-encrypt-password-in-shell-scripts/m-p/2740567#M67568</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;there is no standard shell command to do password encryptions. I think the best way is to use perl to verify the password:&lt;BR /&gt;&lt;BR /&gt;Assume you have a shell variable USERNAME and the entered PASSWORD (switch of tty outout with "stty -echo", when the user should enter his password, and switch it on again after entering with "stty echo"&lt;BR /&gt;&lt;BR /&gt;Then you can do the following (in sh or ksh):&lt;BR /&gt;&lt;BR /&gt;USERPW=`grep "^${USERNAME}:" /etc/passwd | cut -d: -f2`&lt;BR /&gt;if [ ! -z "${USERPW}" ];then&lt;BR /&gt;  ENCRPW=`perl -e "print crypt(${PASSWORD},${USERPW})"`&lt;BR /&gt;  if [ "${USERPW}" = "${ENCRPW}" ];then &lt;BR /&gt;    echo password OK&lt;BR /&gt;  else&lt;BR /&gt;    echo password WRONG&lt;BR /&gt;  fi&lt;BR /&gt;else&lt;BR /&gt;  echo no such user&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;You may write a little c-program which will do the check if you dont want to use perl.&lt;BR /&gt;&lt;BR /&gt;Heiner&lt;BR /&gt;</description>
      <pubDate>Sun, 09 Jun 2002 12:03:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-encrypt-password-in-shell-scripts/m-p/2740567#M67568</guid>
      <dc:creator>Heiner E. Lennackers</dc:creator>
      <dc:date>2002-06-09T12:03:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to encrypt password in shell scripts ?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-encrypt-password-in-shell-scripts/m-p/2740568#M67569</link>
      <description>Chris,&lt;BR /&gt;&lt;BR /&gt;Unless you write a c program that has the passwords embedded in them and encrypted - which of course makes your source code an issue, then there isn't much you can do.&lt;BR /&gt;&lt;BR /&gt;You could use the setuid or setgid on the process. Or "sudo". You could also make the file unreadable to those that don't need to "read" the code.&lt;BR /&gt;&lt;BR /&gt;live free or die&lt;BR /&gt;harry</description>
      <pubDate>Sun, 09 Jun 2002 15:57:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-encrypt-password-in-shell-scripts/m-p/2740568#M67569</guid>
      <dc:creator>harry d brown jr</dc:creator>
      <dc:date>2002-06-09T15:57:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to encrypt password in shell scripts ?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-encrypt-password-in-shell-scripts/m-p/2740569#M67570</link>
      <description>See the man page for crypt. &lt;BR /&gt;&lt;BR /&gt;Problem is you always need to have some password entered to regain access to your encrypted data. &lt;BR /&gt;&lt;BR /&gt;Failing that have you thought of using sudo to run that script only as root ?. I seem to recollect that sudo can also be used to run scripts as other users. You still need a user to enter their password so it is interactive but they would not need to know the password of the user running the function.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 10 Jun 2002 11:16:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-encrypt-password-in-shell-scripts/m-p/2740569#M67570</guid>
      <dc:creator>Nick Wickens</dc:creator>
      <dc:date>2002-06-10T11:16:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to encrypt password in shell scripts ?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-encrypt-password-in-shell-scripts/m-p/2740570#M67571</link>
      <description>Heres my use of crypt just using shell where fred contains the encrypted password - &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;ACCESS=/users/userpass&lt;BR /&gt;NAME=fred&lt;BR /&gt;echo "Please enter your root access password -&amp;gt; "                               &lt;BR /&gt;stty -echo                                                                      &lt;BR /&gt;read PASSWORD                                                                   &lt;BR /&gt;stty echo                                                                       &lt;BR /&gt;PASSIN=$(crypt $PASSWORD &amp;lt;$ACCESS/$NAME 2&amp;gt;/dev/null)                            &lt;BR /&gt;if [ $PASSWORD = $PASSIN ];then                                                 &lt;BR /&gt;echo "Thank You"                                                                &lt;BR /&gt;else  &lt;BR /&gt;exit&lt;BR /&gt;fi</description>
      <pubDate>Mon, 10 Jun 2002 11:23:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-encrypt-password-in-shell-scripts/m-p/2740570#M67571</guid>
      <dc:creator>Nick Wickens</dc:creator>
      <dc:date>2002-06-10T11:23:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to encrypt password in shell scripts ?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-encrypt-password-in-shell-scripts/m-p/2740571#M67572</link>
      <description>I have always had this problem with batch scripts.  The best solution I have found is to have a single file that contains the password.  Change the permissions on this file to 400.  All scripts retrieve this password using 'cat':  PWD=$(cat ~/file.txt).&lt;BR /&gt;Password changes only require updating a single file.  Security issue not removed, but chance of compromise greatly reduced using this technique.</description>
      <pubDate>Mon, 10 Jun 2002 15:12:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-encrypt-password-in-shell-scripts/m-p/2740571#M67572</guid>
      <dc:creator>Mark Seaman</dc:creator>
      <dc:date>2002-06-10T15:12:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to encrypt password in shell scripts ?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-encrypt-password-in-shell-scripts/m-p/2740572#M67573</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;See my response along with Rod's good suggestion this thread&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0xadb5d5fab40ed6118ff40090279cd0f9,00.html" target="_blank"&gt;http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0xadb5d5fab40ed6118ff40090279cd0f9,00.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;-Sri</description>
      <pubDate>Mon, 10 Jun 2002 15:43:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-encrypt-password-in-shell-scripts/m-p/2740572#M67573</guid>
      <dc:creator>Sridhar Bhaskarla</dc:creator>
      <dc:date>2002-06-10T15:43:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to encrypt password in shell scripts ?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-encrypt-password-in-shell-scripts/m-p/2740573#M67574</link>
      <description>Sri, which Rod? (I had a response at the top and another Rod had a response at the end.)&lt;BR /&gt;&lt;BR /&gt;-- Rod Hills  :-)</description>
      <pubDate>Mon, 10 Jun 2002 15:47:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-encrypt-password-in-shell-scripts/m-p/2740573#M67574</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2002-06-10T15:47:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to encrypt password in shell scripts ?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-encrypt-password-in-shell-scripts/m-p/2740574#M67575</link>
      <description>This is an old problem with no perfect solution. My approach has been to use the .netrc file concept. That is, a separate file containing the userid/password pair which can be read by your batch file. This separate file is easy to maintain and you can secure it better than you can a shell script.&lt;BR /&gt;&lt;BR /&gt;No matter what you do this file can be read by anybody who gains user level access to the account, and by root. So set up your environment so that if the userid/password are compromised the damage is minimized.&lt;BR /&gt;&lt;BR /&gt;1. Set the permissions on this file as restrictive as possible - 0400. &lt;BR /&gt;&lt;BR /&gt;2. Do not give group or other write permissions to the directory containing the file (so it can't be deleted to create a DoS).&lt;BR /&gt;&lt;BR /&gt;3. Limit the people who have access to the account which owns the password file. All of them can read that file.&lt;BR /&gt;&lt;BR /&gt;3. Do not use that userid/password for any other account. That way a compromise it somewhat contained.&lt;BR /&gt;&lt;BR /&gt;4. Check the permissions/content of the file regularly and alert on changes. (Consider Tripwire).&lt;BR /&gt;&lt;BR /&gt;Jerry&lt;BR /&gt;</description>
      <pubDate>Mon, 10 Jun 2002 16:20:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-encrypt-password-in-shell-scripts/m-p/2740574#M67575</guid>
      <dc:creator>Jerry Anderson_1</dc:creator>
      <dc:date>2002-06-10T16:20:33Z</dc:date>
    </item>
  </channel>
</rss>

