Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jw9ym-0003ph-Jw for pgsql-general@arkaria.postgresql.org; Thu, 16 Jul 2020 19:55:41 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jw9yl-0008BV-GF for pgsql-general@arkaria.postgresql.org; Thu, 16 Jul 2020 19:55:39 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jw9yj-0008BJ-T0 for pgsql-general@lists.postgresql.org; Thu, 16 Jul 2020 19:55:39 +0000 Received: from [64.147.123.19] (helo=wout3-smtp.messagingengine.com) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jw9yg-0002H5-48 for pgsql-general@postgresql.org; Thu, 16 Jul 2020 19:55:36 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 70FDF3F6; Thu, 16 Jul 2020 15:55:22 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Thu, 16 Jul 2020 15:55:22 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= subject:to:references:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=fm3; bh=V DMc9z+EE/Ha6liFyrSMbfuIU93MEXR/+8DiCIWNYOw=; b=GDvraDjLGNgVL/0fl VJfjYiLfp9B436VyuYwFNzFOu7vujpPQoAfp6MgUyCjpSZZkSLYLhyxiCFYKj4KO zhFiDf/SrQjdCDy/JUuCYM3Hx5ASDRTDih0x7EBhEBeqRI2Gxqc7EzR0UQRhySuX +pMJBAb9tcSsSSlSEYSu0NgRJ58pnW3xef5QbKVTkMt40Rfo13ZI6TDWgk8nx6+Y RPz/xmXUNaL+XStclzqDY49auC9n4QsWAs22Xl9MVOu7bjPC91hK3XU9GfaCkqMG qUF/rPbomI1TRgC88/4nmRdWElCKiT6vVnxyYa/8iADWLjZc0xcPGfWRnJ9lZUa3 6kAGw== 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-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; bh=VDMc9z+EE/Ha6liFyrSMbfuIU93MEXR/+8DiCIWNY Ow=; b=HHk9uqz2JJVevGdeTzJIUO4h++z9bvhSBQKQbYHhORa1dtDb3MAv6oFlN 8NrK+3vmD1sYIFNbI5N5Xy1UVzTSO5xsYlLG3Sr1lY1J8D0Fs+e/5PohaH3UrOkF tpXm29BVKP8SXv51ItBAQnGtYvyHa4Q1zRLiJsp6JekGbKIeUcPDzj4ybdbteWsZ 06G08uTN/9X1JndWkm52ZMyma6cso9tAntJpSh6T4n2LM6olL3Mt2TR7dxZYpgv4 pGxsecqHjW3RaT8cbVa0VICP/tpgn/GZj172A3QIvMnt/jwpgfSbgg1y9lSqJU5E GdpFOeo+8Tp2TQRfK0y8Ye4JDV7ZA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedrfeeggddugeegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefuvfhfhffkffgfgggjtgfgsehtke ertddtfeejnecuhfhrohhmpeetughrihgrnhcumfhlrghvvghruceorggurhhirghnrdhk lhgrvhgvrhesrghklhgrvhgvrhdrtghomheqnecuggftrfgrthhtvghrnhepkeegteevvd duudfhtedtgffggfejveeghfekgefhhedugefhkeelieejueekfeejnecuffhomhgrihhn pehmhigtohhmphgrnhihrdgtohhmpdhpohhsthhgrhgvshhqlhdrohhrghenucfkphepje ehrddujedvrdehrddvfedunecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehm rghilhhfrhhomheprggurhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtghomh X-ME-Proxy: Received: from [192.168.1.3] (75-172-5-231.tukw.qwest.net [75.172.5.231]) by mail.messagingengine.com (Postfix) with ESMTPA id 498BE30600DC; Thu, 16 Jul 2020 15:55:21 -0400 (EDT) Subject: Re: Fwd: How to connect PostgreSQL (9.6.17) database from Macbook Pro Terminal using JumpCloud password? To: Devraj B , pgsql-general@postgresql.org References: From: Adrian Klaver Message-ID: <0c66c0ed-087f-d60d-dccd-3e94b9cf227c@aklaver.com> Date: Thu, 16 Jul 2020 12:55:20 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.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 X-Host-Lookup-Failed: Reverse DNS lookup failed for 64.147.123.19 (deferred) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 7/16/20 12:04 PM, Devraj B wrote: > I login to my Macbook Pro using my JumpCloud password. My userid is > firstname.lastname > /Users/firstname.lastname > whoami > firstname.lastname > > After connecting to VPN, from my Macbook Pro Terminal, I connect to > PostgreSQL server staging.mycompany.com > having CentOS 6.10 > /Users/firstname.lastname > ssh staging.mycompany.com > > [firstname.lastname@staging] $ > > Than I connect to root using my JumpCloud password > [firstname.lastname@staging] $ sudo su - > [sudo] password for firstname.lastname:  < I enter my JumpCloud Password > here > > [root@staging] # > (Above, I could connect to root using my JumpCloud Password. I don't > know what setup would have been done for that.) > > Checked the O/S > [root@staging] # uname -a > Linux  staging.local 2.6.32-696.16.1.el6.x86_64 #1 SMP Wed Nov 15 > 16:51:15 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux > [root@staging] # lsb_release -d | awk -F"\t" '{print $2}' > CentOS release 6.10 (Final) > > Connected to PostgreSQL (9.6.17) to create a user exactly SAME as of my > Macbook Pro (or JumpCloud) username. > [root@staging] # psql -h localhost -U postgres > postgres=# > postgres=# select version(); > PostgreSQL 9.6.17 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.4.7 > 20120313 (Red Hat 4.4.7-23), 64-bit > postgres=# create user "firstname.lastname"; > CREATE ROLE > postgres=# grant connect on database my_test_db to "firstname.lastname"; > GRANT > postgres=# \q > > From server staging.mycompany.com I can > connect to the database using user  firstname.lastname successfully. > [root@staging] #  psql -h localhost -U firstname.lastname -d my_test_db > my_test_db=> > > But I want to setup JumpCloud or LDAP or any other authentication so > that I can connect PostgreSQL user  "firstname.lastname" directly from > my Macbook Pro Terminal using my JumpCloud Password. Like:- > > /Users/firstname.lastname >  psql -h staging.mycompany.com > -U firstname.lastname -d my_test_db > Password for user firstname.lastname:  < I have Not given any password > when I created PostgreSQL user firstname.lastname above and trying to > authenticate here using my JumpCloud password, May be the same way as I > could connect above to root. But when I enter my JumpCloud Password here > there is an error. > > psql: error: could not connect to server: FATAL:  password > authentication failed for user "firstname.lastname" Well I would say the Postgres server has pg_hba.conf setup to require password authentication for host(ssl) connections. A good idea. You need to back to part above where you shelled into psql prompt and use ALTER ROLE: https://www.postgresql.org/docs/12/sql-alterrole.html and do ALTER ROLE firstname.lastname WITH LOGIN PASSWORD 'the_password'; You need the LOGIN if you want that role to connect directly to database. FYI, the above can be done as part of CREATE ROLE also: https://www.postgresql.org/docs/12/sql-createrole.html You probably want to read through above anyway to see what the options are and they do. > > What more to set up so that I can connect PostgreSQL (9.6.17) database > using PostgreSQL user ( with the Same name as of my JumpCloud/ Macbook > Pro user) directly from my Macbook Pro terminal using my JumpCloud > Password authentication? > What do I need to set up in pg_hba.conf ? > Please suggest in detail. > Thks > -- Adrian Klaver adrian.klaver@aklaver.com