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 1fNlIh-0004Xe-T4 for pgsql-general@arkaria.postgresql.org; Tue, 29 May 2018 20:33:00 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fNlIc-0000xZ-MB for pgsql-general@arkaria.postgresql.org; Tue, 29 May 2018 20:32:54 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fNlIb-0000xP-Li for pgsql-general@lists.postgresql.org; Tue, 29 May 2018 20:32:54 +0000 Received: from out1-smtp.messagingengine.com ([66.111.4.25]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fNlIX-0002Nw-3t for pgsql-general@postgresql.org; Tue, 29 May 2018 20:32:53 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id AFAE420FAD; Tue, 29 May 2018 16:32:47 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Tue, 29 May 2018 16:32:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; bh=MCw/6JjdwHFMSNussM8crFpnAQN90 GQ3K/tj4KxHemQ=; b=DGTvTOksqpS+0vW2Jq7i9EADTBIYwtSPCOD7rfz90rDmE vpu5lYKCzWmmB4BM1FbUJ8P6nM0KsM2ys3kf9pSwN2jGim8PqvrWImhZfnEOhTO+ OGRmp7m03uK/9Uc7XTBNxtqVsFk/wKs7Djih8JkpV92RWLDfi12kzqPzxz3n7Rbz S+ZgJqNupMzrMGW2CcQNpeaZhh/FzaPTEhs0cfkpA3x5W2npOq1iteFlOIV5PnW/ 6/qjbg+9lNi3At/tH6t8zflLh9oSYImzwqGisgYneCnD4c2KHSdrG34/juZoHR5f FdJB/7uFToHdnWa9VOgpthbUnfW38QfAlkuIt0LRQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=MCw/6J jdwHFMSNussM8crFpnAQN90GQ3K/tj4KxHemQ=; b=P6iKO0hIhOft20WMpKi81f 5IF2xHAsXb2oE0F7CG+tTGEZH1Vvzb1c7a9nQMPrkff/ghEoCxtI2foDDjspZ7i4 8T9fvLNkB6sJefvt64QyReqWU3RtHVQc4f5BVhV0y3Gj5jNhPCAk48sEiLvo1DHX nuvXYsSvZaC8MP0hev2qsL8QpClJYOvwFiL7oytOxGx/DY7U+6VzMDUke7Vb+7jT DzQg3/LUw+Jqahdzv+fX8b6sPwpxYopHFk9tX0PI2vejQ54NF27pyn5Aszy5LE/A S7d4f3sWn5hcwrnlrpSMCcN+lg2gm3OAXLk7xR4xnGbL7ODITCXOi0tdOg+rVE4w == X-ME-Proxy: X-ME-Proxy: X-ME-Proxy: X-ME-Proxy: X-ME-Proxy: X-ME-Proxy: X-ME-Sender: Received: from [192.168.1.3] (unknown [71.212.159.209]) by mail.messagingengine.com (Postfix) with ESMTPA id E9F7EE4394; Tue, 29 May 2018 16:32:46 -0400 (EDT) Subject: Re: Pgagent is not reading pgpass file either in Windows or Linux. To: nageswara Bandla , pgsql-general@postgresql.org References: From: Adrian Klaver Message-ID: <5595335e-32e8-80da-9c65-8d79fce554a7@aklaver.com> Date: Tue, 29 May 2018 13:32:46 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 05/29/2018 12:14 PM, nageswara Bandla wrote: > 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. > > I am clueless, why pgagent is not honoring PGPASSFILE env variable. My guess because the LocalSystem user does not have permissions on your: %APPDATA%/postgresql/pgpass.conf file. This seems to be confirmed by it working when you run pgagent as the login user. Also: passfile Specifies the name of the file used to store passwords (see Section 33.15). Defaults to ~/.pgpass, or %APPDATA%\postgresql\pgpass.conf on Microsoft Windows. (No error is reported if this file does not exist.) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > > *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. This is going to depend on what pgagent_96 is doing? > > It fails with error message – “WARNING: Couldn't create the primary > connection (attempt 2): fe_sendauth: no password supplied” What happens if from the terminal as the postgres user you do?: /path/to/pgagent 'connection string' > > 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. > > -- Adrian Klaver adrian.klaver@aklaver.com