From: Adrian Klaver <adrian.klaver@aklaver.com>
To: Atul Kumar <akumar14871@gmail.com>
To: Andreas Kretschmer <andreas@a-kretschmer.de>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: strange behavior of pg_hba.conf file
Date: Wed, 22 Nov 2023 10:09:41 -0800
Message-ID: <1e3b7fe2-384b-4348-ad0b-24fe39932957@aklaver.com> (raw)
In-Reply-To: <CA+ONtZ5Yko8Uxzzbq-ecXaLirC7Er5iVp4N=20FW0-QpP4bPLQ@mail.gmail.com>
References: <CA+ONtZ7nMGfC23Gpgq7x9YtuP3YpqwXDQZNK6NdLTFn7e2fhrw@mail.gmail.com>
<CANzqJaBkoU6SBeVvN3=VtFLgDLP1wTm7a_v9W6KYOr990sHRtg@mail.gmail.com>
<CA+ONtZ63PUm0rEn_UxLwbv5Gg8a4RXgb2DQBOS9BZPSnd49ggg@mail.gmail.com>
<CA+ONtZ7+383OhJ1Z37V5dJUo9ivU01HmhXZ_oL2hmkoSL-SEVg@mail.gmail.com>
<d8a5560c-1363-426f-8144-fe3910ccf00c@aklaver.com>
<CA+ONtZ7RZs8YvrXO68K=txJyHi4VGQVA6aYzuwT-6cN3642WRg@mail.gmail.com>
<8758be84-0309-6ead-4d66-4d86a719f333@a-kretschmer.de>
<CA+ONtZ5Yko8Uxzzbq-ecXaLirC7Er5iVp4N=20FW0-QpP4bPLQ@mail.gmail.com>
On 11/22/23 10:03 AM, Atul Kumar wrote:
> Please can you share any command for due diligence whether ip is
> resolved to ipv6 ?.
This:
psql -d postgres -U postgres -p 5432 -h localhost
where pretty sure
/etc/hosts
is resolving localhost --> ::1
>
> On Wed, Nov 22, 2023 at 11:25 PM Andreas Kretschmer
> <andreas@a-kretschmer.de> wrote:
>
>
>
> Am 22.11.23 um 18:44 schrieb Atul Kumar:
> > I am giving this command
> > psql -d postgres -U postgres -p 5432 -h localhost
> > Then only I get that error.
>
> so localhost resolved to an IPv6 - address ...
>
> >
> > but when I pass ip or hostname of the local server then I don't
> get
> > such error message
> > 1. psql -d postgres -U postgres -p 5432 -h <ip of local server>
> > 2. psql -d postgres -U postgres -p 5432 -h <hostname of local
> server>
>
> resolves to an IPv4 - address. you can see the difference?
>
> localhost != iv4-address != hostname with ipv4 address
>
> Andreas
>
> >
> >
> > I don;t get that error while using the above two commands.
> >
> >
> > Regards.
> >
> >
> > On Wed, Nov 22, 2023 at 10:45 PM Adrian Klaver
> > <adrian.klaver@aklaver.com> wrote:
> >
> > On 11/22/23 09:03, Atul Kumar wrote:
> > > The entries that I changed were to replace the md5 with
> > scram-sha-256
> > > and remove unnecessary remote IPs.
> >
> > FYI from:
> >
> > https://www.postgresql.org/docs/current/auth-password.html
> >
> > md5
> >
> > The method md5 uses a custom less secure challenge-response
> > mechanism. It prevents password sniffing and avoids storing
> > passwords on
> > the server in plain text but provides no protection if an
> attacker
> > manages to steal the password hash from the server. Also,
> the MD5
> > hash
> > algorithm is nowadays no longer considered secure against
> determined
> > attacks.
> >
> > The md5 method cannot be used with the
> db_user_namespace feature.
> >
> > To ease transition from the md5 method to the newer SCRAM
> > method,
> > if md5 is specified as a method in pg_hba.conf but the user's
> > password
> > on the server is encrypted for SCRAM (see below), then
> SCRAM-based
> > authentication will automatically be chosen instead.
> >
> > >
> > > But it has nothing to do with connecting the server
> locally with
> > "psql
> > > -d postgres -U postgres -h localhost"
> >
> > The error:
> >
> > no pg_hba.conf entry for host "::1", user "postgres", database
> > "postgres
> >
> >
> > says it does and the error is correct as you do not have an IPv6
> > entry
> > for localhost in pg_hba.conf. At least in the snippet you
> showed us.
> >
> >
> > >
> > > But when I try to connect it locally I get this error. So
> it is
> > related
> >
> > When you say connect locally do you mean to localhost or to
> > local(socket)?
> >
> > > to local connections only and when I pass the hostname or
> ip of the
> > > server it works fine without any issue.
> > >
> > >
> > > Regards.
> > >
> >
> > --
> > Adrian Klaver
> > adrian.klaver@aklaver.com
> >
>
> --
> Andreas Kretschmer - currently still (garden leave)
> Technical Account Manager (TAM)
> www.enterprisedb.com <http://www.enterprisedb.com;
>
>
>
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, akumar14871@gmail.com, andreas@a-kretschmer.de
Subject: Re: strange behavior of pg_hba.conf file
In-Reply-To: <1e3b7fe2-384b-4348-ad0b-24fe39932957@aklaver.com>
References: <CA+ONtZ7nMGfC23Gpgq7x9YtuP3YpqwXDQZNK6NdLTFn7e2fhrw@mail.gmail.com> <CANzqJaBkoU6SBeVvN3=VtFLgDLP1wTm7a_v9W6KYOr990sHRtg@mail.gmail.com> <CA+ONtZ63PUm0rEn_UxLwbv5Gg8a4RXgb2DQBOS9BZPSnd49ggg@mail.gmail.com> <CA+ONtZ7+383OhJ1Z37V5dJUo9ivU01HmhXZ_oL2hmkoSL-SEVg@mail.gmail.com> <d8a5560c-1363-426f-8144-fe3910ccf00c@aklaver.com> <CA+ONtZ7RZs8YvrXO68K=txJyHi4VGQVA6aYzuwT-6cN3642WRg@mail.gmail.com> <8758be84-0309-6ead-4d66-4d86a719f333@a-kretschmer.de> <CA+ONtZ5Yko8Uxzzbq-ecXaLirC7Er5iVp4N=20FW0-QpP4bPLQ@mail.gmail.com> <1e3b7fe2-384b-4348-ad0b-24fe39932957@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