pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Adrian Klaver <adrian.klaver@aklaver.com>
To: stan <stanb@panix.com>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: Help with authentication on Debain/Ubuntu installation
Date: Thu, 21 Nov 2019 14:11:08 -0800
Message-ID: <76a1827a-b05c-a170-aace-2c07daf7ac32@aklaver.com> (raw)
In-Reply-To: <20191121215226.GA11603@panix.com>
References: <20191121124517.GA3320@panix.com>
	<CABUevEw3e97aG1Z8fhaFN9QpgdduE_yP3s+1huvLwkC6aWNAeg@mail.gmail.com>
	<20191121141502.GA14731@panix.com>
	<20191121143539.GA18839@panix.com>
	<ccd6af85-ae12-6e8e-82bb-f8ed6a46dd59@aklaver.com>
	<20191121161247.GE21704@panix.com>
	<a300b005-e176-2fb4-59bd-65c12acec8d9@aklaver.com>
	<20191121190927.GA21941@panix.com>
	<fe19e4f2-6549-ccdf-f3b4-83538711eeb0@aklaver.com>
	<20191121215226.GA11603@panix.com>

On 11/21/19 1:52 PM, stan wrote:
> 
> On Thu, Nov 21, 2019 at 12:14:16PM -0800, Adrian Klaver wrote:

>> 5) Now in your case you have peer auth(first in the list) for local socket
>> connections which means a user can only connect on the local socket as the
>> db postgres user if they are also the os postgres user.
>> You can work around that by having other users connect to the database using
>> a -h(host) connection that requires a password.
> 

I will answer your questions below, but I would suggest you spend some 
time going over:

https://www.postgresql.org/docs/11/auth-pg-hba-conf.html

It will answer a lot of questions.

> So, to implement it this way. I would
> 
> * set teh postgres database user password to one I know.
> * run tasks that need posgres superuser access with -h
> <external_ip_address> -U postgress -W
> 
> * enter the password.
> 
> Correct?

Yes and no.

If you are running tasks as the OS user postgres and connecting to the 
local socket(no -h) then this:

# Database administrative login by Unix domain socket
local   all             postgres                                peer

will apply and you will not need a password.

If you are not running as the OS user postgres or are not using the 
local socket, then another connection line in pg_hba.conf will come into 
play. In that case you probably want something like:

host   all             postgres                                md5

In the above case you can connect as an OS user other then 
postgres(using -U postgres) and you will be need to supply a password. 
Also if you connect as OS user postgres(using -h) then you will a 
password. The password can be supplied manually or it can come from .pgpass:

https://www.postgresql.org/docs/11/libpq-pgpass.html

or an env variable:

https://www.postgresql.org/docs/11/libpq-envars.html


> 
> I should  have thought of this technique, I have used it in the past when I
> had issues with pg_hba.conf file. Something abou IPV6 entries, or lack of
> them ?

Possibly, you can force a IPV4 connection by doing for instance:

-h 127.0.0.1 instead of -h localhost

in the case where localhost is pointing to ::1

> 
> Thanks for the help.
> 


-- 
Adrian Klaver
adrian.klaver@aklaver.com





view thread (10+ messages)

Message-ID: <76a1827a-b05c-a170-aace-2c07daf7ac32@aklaver.com>
Permalink:  ../76a1827a-b05c-a170-aace-2c07daf7ac32@aklaver.com/
Also on:    postgresql.org/message-id/76a1827a-b05c-a170-aace-2c07daf7ac32@aklaver.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: adrian.klaver@aklaver.com, stanb@panix.com
  Subject: Re: Help with authentication on Debain/Ubuntu installation
  In-Reply-To: <76a1827a-b05c-a170-aace-2c07daf7ac32@aklaver.com>
  References: <20191121124517.GA3320@panix.com> <CABUevEw3e97aG1Z8fhaFN9QpgdduE_yP3s+1huvLwkC6aWNAeg@mail.gmail.com> <20191121141502.GA14731@panix.com> <20191121143539.GA18839@panix.com> <ccd6af85-ae12-6e8e-82bb-f8ed6a46dd59@aklaver.com> <20191121161247.GE21704@panix.com> <a300b005-e176-2fb4-59bd-65c12acec8d9@aklaver.com> <20191121190927.GA21941@panix.com> <fe19e4f2-6549-ccdf-f3b4-83538711eeb0@aklaver.com> <20191121215226.GA11603@panix.com> <76a1827a-b05c-a170-aace-2c07daf7ac32@aklaver.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox