<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;
        mso-ligatures:standardcontextual;
        mso-fareast-language:EN-US;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
span.EmailStyle19
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-GB" link="blue" vlink="purple" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal">[postgres@catvmtspg02c DBToolkit]$ psql -h 10.78.121.1 -U postgres -p 9999<o:p></o:p></p>
<p class="MsoNormal">Password for user postgres:<o:p></o:p></p>
<p class="MsoNormal">psql (14.7)<o:p></o:p></p>
<p class="MsoNormal">SSL connection (protocol: TLSv1.3, cipher: TLS_AES_256_GCM_SHA384, bits: 256, compression: off)<o:p></o:p></p>
<p class="MsoNormal">Type "help" for help.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">postgres=#<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal" style="line-height:15.0pt"><span lang="EN-US" style="font-size:12.0pt;color:black;mso-ligatures:none"><o:p> </o:p></span></p>
<p class="MsoNormal" style="line-height:15.0pt"><span lang="EN-US" style="font-size:12.0pt;color:black;mso-ligatures:none"><o:p> </o:p></span></p>
<p class="MsoNormal" style="line-height:15.0pt"><span lang="EN-US" style="font-size:12.0pt;color:black;mso-ligatures:none">Regards,<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:15.0pt"><b><span lang="EN-US" style="font-size:12.0pt;color:black;mso-ligatures:none"><o:p> </o:p></span></b></p>
<p class="MsoNormal"><b><span lang="EN-US" style="font-size:12.0pt;color:black;mso-ligatures:none">Todd Stein</span></b><span lang="EN-US" style="mso-ligatures:none"><o:p></o:p></span></p>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span lang="EN-US" style="mso-ligatures:none;mso-fareast-language:EN-GB">From:</span></b><span lang="EN-US" style="mso-ligatures:none;mso-fareast-language:EN-GB"> pgpool-general <pgpool-general-bounces@pgpool.net>
<b>On Behalf Of </b>Ron<br>
<b>Sent:</b> Wednesday, March 29, 2023 12:00 PM<br>
<b>To:</b> pgpool-general@pgpool.net<br>
<b>Subject:</b> [pgpool-general: 8690] Re: password file format<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom:12.0pt">Can you connect to "the database" from port 9999?<br>
<br>
psql --host=blarge.example.com --username=postgres --port=9999<br>
<br>
<br>
<span style="mso-ligatures:none;mso-fareast-language:EN-GB"><o:p></o:p></span></p>
<div>
<p class="MsoNormal">On 3/29/23 10:35, Todd Stein wrote:<o:p></o:p></p>
</div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal">Hi Ron,<o:p></o:p></p>
<p class="MsoNormal">Thanks for your response.<o:p></o:p></p>
<p class="MsoNormal">I should have not included the reference to pcp.conf and pool_passwd files.  These are well documented, and made my question unclear.<o:p></o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal"><b>This one statement is the one I need help with:</b><i><br>
 </i><o:p></o:p></p>
<p class="MsoNormal"><i>“In my testing I find that if the password in ~/.pgpass includes the AES prefix in the encrypted password, I get password authentication failed for user “postgres” when the system tries to start a replication slot.”</i><o:p></o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal"><b>More detail:</b><o:p></o:p></p>
<p class="MsoNormal"><b> </b><o:p></o:p></p>
<p class="MsoNormal">Here are a few lines from the postgresql-Wed.log file.  This entry corresponds to a pcp_recovery_node command:<o:p></o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal">2023-03-29 11:20:27.378 EDT [660839] STATEMENT:  START_REPLICATION SLOT "pg_basebackup_660839" 3/7000000 TIMELINE 76<o:p></o:p></p>
<p class="MsoNormal">2023-03-29 11:20:30.860 EDT [660848] FATAL:  password authentication failed for user "postgres"<o:p></o:p></p>
<p class="MsoNormal">2023-03-29 11:20:30.860 EDT [660848] DETAIL:  Connection matched pg_hba.conf line 108: "host    all             postgres         0.0.0.0/0             scram-sha-256"<o:p></o:p></p>
<div>
<p class="MsoNormal" style="line-height:15.0pt"><span lang="EN-US" style="color:black;mso-ligatures:none"> </span><o:p></o:p></p>
<p class="MsoNormal" style="line-height:15.0pt"><span lang="EN-US" style="color:black;mso-ligatures:none">During the pcp_recovery_node process the system attempts to create a replicaion slot, and fails…  I’m trying to figure out why.</span><o:p></o:p></p>
<p class="MsoNormal" style="line-height:15.0pt"><span lang="EN-US" style="font-size:12.0pt;color:black;mso-ligatures:none"> </span><o:p></o:p></p>
<p class="MsoNormal" style="line-height:15.0pt"><span lang="EN-US" style="font-size:12.0pt;color:black;mso-ligatures:none"> </span><o:p></o:p></p>
<p class="MsoNormal" style="line-height:15.0pt"><span lang="EN-US" style="font-size:12.0pt;color:black;mso-ligatures:none"> </span><o:p></o:p></p>
<p class="MsoNormal" style="line-height:15.0pt"><span lang="EN-US" style="font-size:12.0pt;color:black;mso-ligatures:none">Regards,</span><o:p></o:p></p>
<p class="MsoNormal" style="line-height:15.0pt"><b><span lang="EN-US" style="font-size:12.0pt;color:black;mso-ligatures:none"> </span></b><o:p></o:p></p>
<p class="MsoNormal"><b><span lang="EN-US" style="font-size:12.0pt;color:black;mso-ligatures:none">Todd Stein</span></b><o:p></o:p></p>
</div>
<p class="MsoNormal"> <o:p></o:p></p>
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span lang="EN-US" style="mso-ligatures:none;mso-fareast-language:EN-GB">From:</span></b><span lang="EN-US" style="mso-ligatures:none;mso-fareast-language:EN-GB"> pgpool-general
<a href="mailto:pgpool-general-bounces@pgpool.net"><pgpool-general-bounces@pgpool.net></a>
<b>On Behalf Of </b>Ron<br>
<b>Sent:</b> Wednesday, March 29, 2023 11:18 AM<br>
<b>To:</b> <a href="mailto:pgpool-general@pgpool.net">pgpool-general@pgpool.net</a><br>
<b>Subject:</b> [pgpool-general: 8688] Re: password file format</span><o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal">On 3/29/23 09:52, Todd Stein wrote:<br>
<br>
<br>
<o:p></o:p></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal">Hi,<o:p></o:p></p>
<p class="MsoNormal">Will someone please correct or confirm my assumption of the SCRAM-SHA-256 password file format for $HOME/.pgpass and $HOME/.pcppass files?<o:p></o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal">I’m not sure if I should be using the password with the AES prefix outside of the pool_password file or not.  For example in the .pgpass and/or .pcppass files.<o:p></o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal">$ pg_enc -k ~/.pgpoolkey -u postgres -p<o:p></o:p></p>
<p class="MsoNormal">db password:<o:p></o:p></p>
<p class="MsoNormal">trying to read key from file /var/lib/pgsql/.pgpoolkey<o:p></o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal"><b>P1+l8j3GaTxzSBgcY1laEQ==</b><o:p></o:p></p>
<p class="MsoNormal">pool_passwd string: <b>AESP1+l8j3GaTxzSBgcY1laEQ==</b><o:p></o:p></p>
<p class="MsoNormal"><b> </b><o:p></o:p></p>
<p class="MsoNormal">My understanding (please correct me if I’m wrong), is that the pcp.conf file must use md5 encryption regardless of what your password_encryption in the DB is.<o:p></o:p></p>
</blockquote>
<p class="MsoNormal"><span style="mso-ligatures:none;mso-fareast-language:EN-GB"><br>
pcp is for managing PgPool.<br>
<br>
<br>
<br>
</span><o:p></o:p></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal">The pool_password file (when using scram-sha-256 encryption) requires the string it gets automatically (which includes the AES prefix) by the pg_enc command when providing the “-m” attribute.<o:p></o:p></p>
</blockquote>
<p class="MsoNormal"><span style="mso-ligatures:none;mso-fareast-language:EN-GB"><br>
pool_passwd is for accessing Postgresql databases.  Their "user lists" are completely separate.  You can, for example, have user "blarge" in pcp.conf but not in pool_passwd (and by extension be a Postgresql role).<br>
  </span><o:p></o:p></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal">However, I’ve not been able to find anything documented for the password files.<o:p></o:p></p>
</blockquote>
<p class="MsoNormal"><span style="mso-ligatures:none;mso-fareast-language:EN-GB"><br>
What do you mean? <a href="https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.pgpool.net%2Fdocs%2F43%2Fen%2Fhtml%2Fauth-methods.html&data=05%7C01%7Ctodd.stein%40microfocus.com%7C92bb7e8d69e84f8e7d2208db306ea0cb%7C856b813c16e549a585ec6f081e13b527%7C0%7C0%7C638157023930916931%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=htUrp0LDmcxeo5wNJ6%2BDMrtwiN%2BSIT8Dq4ohCenrfF8%3D&reserved=0">
https://www.pgpool.net/docs/43/en/html/auth-methods.html</a> describes pool_passwd, and describes how to create MD5 and SHA256 hashes.<br>
<br>
<br>
<br>
</span><o:p></o:p></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal">  I’m pretty sure I’ve seen that if I were to use an encrypted password (scram-sha-256) in the pgpool.conf file, it must include the AES prefix. 
<o:p></o:p></p>
</blockquote>
<p class="MsoNormal"><span style="mso-ligatures:none;mso-fareast-language:EN-GB"><br>
pg_enc does that for you.<br>
<br>
<br>
<br>
</span><o:p></o:p></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal">In my testing I find that if the password in ~/.pgpass includes the AES prefix in the encrypted password, I get password authentication failed for user “postgres” when the system tries to start a replication slot.<o:p></o:p></p>
</blockquote>
<p class="MsoNormal" style="margin-bottom:12.0pt"><span style="mso-ligatures:none;mso-fareast-language:EN-GB"><br>
That needs more detail.</span><o:p></o:p></p>
<div>
<p class="MsoNormal"><span style="mso-ligatures:none;mso-fareast-language:EN-GB">--
<br>
Born in Arizona, moved to Babylonia.</span><o:p></o:p></p>
</div>
</blockquote>
<p class="MsoNormal"><span style="mso-ligatures:none;mso-fareast-language:EN-GB"><o:p> </o:p></span></p>
<div>
<p class="MsoNormal"><span style="mso-ligatures:none;mso-fareast-language:EN-GB">--
<br>
Born in Arizona, moved to Babylonia.<o:p></o:p></span></p>
</div>
</div>
</body>
</html>