Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fNy4i-0003nw-T3 for pgsql-general@arkaria.postgresql.org; Wed, 30 May 2018 10:11:25 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fNy4h-0004ru-AJ for pgsql-general@arkaria.postgresql.org; Wed, 30 May 2018 10:11:23 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fNy4g-0004rk-Qe for pgsql-general@lists.postgresql.org; Wed, 30 May 2018 10:11:23 +0000 Received: from inv-18.93.247.146.static.fprt.com ([146.247.93.18] helo=mail.groupesirap.fr) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fNy4Y-00009c-MU for pgsql-general@lists.postgresql.org; Wed, 30 May 2018 10:11:21 +0000 Received: (qmail 31335 invoked by uid 105); 30 May 2018 10:11:10 -0000 Reply-To: s.dunand@sirap.fr Subject: Re: Pgagent is not reading pgpass file either in Windows or Linux. To: pgsql-general@lists.postgresql.org References: From: =?UTF-8?Q?St=c3=a9phane_Dunand?= Message-ID: <69337c2d-eb23-3560-dc4c-35998443b1ae@sirap.fr> Date: Wed, 30 May 2018 12:11:23 +0200 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/alternative; boundary="------------E656328B5715C72C986F0844" Content-Language: fr Received: from mail.groupesirap.fr (HELO mail.groupesirap.fr) (127.0.0.1) by mail.groupesirap.fr (qpsmtpd/0.96) with ESMTPSA (ECDHE-RSA-AES256-GCM-SHA384 encrypted); Wed, 30 May 2018 12:11:10 +0200 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------E656328B5715C72C986F0844 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Le 29/05/2018 à 21:14, nageswara Bandla a écrit : > > The intention of this post is to find out ways to run pgagent without > passing password in its connection string. > > *Windows:* > > I have installed pgagent on windows and configured to run under Local > System account. > > Command:- > > C:\PostgreSQL\bigsql\pgagent\bin\pgagent.exeINSTALL pgagent -l 2 -u > LocalSystem hostaddr=127.0.0.1 dbname=postgresdb user=postgres > > I have logged into my windows account; where my profile has > pgpass.conf in %APPDATA%/postgresql/pgpass.conf file. > > 127.0.0.1:5432:*:postgres:postgres1 > > Pgagent is not started and throws error –“The pgagent service on Local > Computer started and then stopped. Some services stop automatically if > they are not in use by other services or programs”. > > Eventvwr log messages have these error messages - “Couldn't create the > primary connection (attempt 10): fe_sendauth: no password supplied” > > *PGPASSFILE env variable:* > > As per the link- > (https://www.postgresql.org/docs/9.6/static/libpq-pgpass.html) I set > PGPASSFILE environment variable to point to pgpass.conf location. Even > then, it’s throwing same above error message. I have found out that > pgagent is not reading pgpass.conf file when configured under > LocalSystem account. > > When I change the properties of the pgagent service to run under my > login user account. Then, it’s reading pgpass.conf file under > %APPDATA%/postgresql/pgpass.conf. > try without "-u LocalSystem", without PGPASSFILE env variable and with your login account plus your %APPDATA%/postgresql/pgpass.conf file > I am clueless, why pgagent is not honoring PGPASSFILE env variable. > > *Linux:* > > In Linux, I have installed pgagent_96 using yum command. And tried to > run pgagent using command /etc/init.d/pgagent_96 from postgres user > account. > > It fails with error message – “WARNING: Couldn't create the primary > connection (attempt 2): fe_sendauth: no password supplied” > > I made sure that I have .pgpass configuration file with 0600 > permissions in postgres user home directory. > > I have tried by defining PGPASSFILE env variable in postgres user > account. But it’s not working. > > Pgagent is starting only when we pass password in it’s connection > string. But which is not a good practice at all. > > in your /etc/init.d/pgagent_96 file, verify that the user starting the command "pgagent ..." is postgres in your case. Stéphane Dunand --------------E656328B5715C72C986F0844 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit


Le 29/05/2018 à 21:14, nageswara Bandla a écrit :

 

The intention of this post is to find out ways to run pgagent without passing password in its connection string.

 

Windows:

I have installed pgagent on windows and configured to run under Local System account.

 

Command:-

C:\PostgreSQL\bigsql\pgagent\bin\pgagent.exe  INSTALL pgagent -l 2 -u LocalSystem hostaddr=127.0.0.1 dbname=postgresdb user=postgres

 

I have logged into my windows account; where my profile has pgpass.conf in %APPDATA%/postgresql/pgpass.conf file.

 

127.0.0.1:5432:*:postgres:postgres1

 

Pgagent is not started and throws error –“The pgagent service on Local Computer started and then stopped. Some services stop automatically if they are not in use by other services or programs”.

Eventvwr log messages have these error messages - “Couldn't create the primary connection (attempt 10): fe_sendauth: no password supplied”

 

PGPASSFILE env variable:

As per the link- (https://www.postgresql.org/docs/9.6/static/libpq-pgpass.html)   I set PGPASSFILE environment variable to point to pgpass.conf location. Even then, it’s throwing same above error message. I have found out that pgagent is not reading pgpass.conf file when configured under LocalSystem account.

 

When I change the properties of the pgagent service to run under my login user account. Then, it’s reading pgpass.conf file under %APPDATA%/postgresql/pgpass.conf. 

try without "-u LocalSystem", without PGPASSFILE env variable and with your login account plus your %APPDATA%/postgresql/pgpass.conf file

 

I am clueless, why pgagent is not honoring PGPASSFILE env variable.

 

 

Linux:

In Linux, I have installed pgagent_96 using yum command. And tried to run pgagent using command /etc/init.d/pgagent_96 from postgres user account.

It fails with error message – “WARNING: Couldn't create the primary connection (attempt 2): fe_sendauth: no password supplied”

I made sure that I have .pgpass configuration file with 0600 permissions in postgres user home directory.

 

I have tried by defining PGPASSFILE env variable in postgres user account. But it’s not working.

 

Pgagent is starting only when we pass password in it’s connection string. But which is not a good practice at all.


in your /etc/init.d/pgagent_96 file, verify that the user starting the command "pgagent ..." is postgres in your case.

Stéphane Dunand

--------------E656328B5715C72C986F0844--