How to initiate GSSAPI in potgresql

Viewed 11055

I installed postgres in REDHAT 7. Then i installed python 3.6. I had created virtual environment. Also i created a table in postgres. Then i executed this python script and i got some error.

import psycopg2
conn = psycopg2.connect("dbname=postgres user=postgres host=localhost password=postgres")

Error is:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/data/scripts/san-automation/lib/python3.7/site-packages/psycopg2/__init__.py", line 126, in connect
    conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
psycopg2.OperationalError: could not initiate GSSAPI security context: Unspecified GSS failure.  Minor code may provide more information
could not initiate GSSAPI security context: Server not found in Kerberos database
FATAL:  Ident authentication failed for user "postgres"

cat /var/lib/pgsql/12/data/pg_hba.conf

# TYPE  DATABASE        USER            ADDRESS                 METHOD

# "local" is for Unix domain socket connections only
local   all             all                                     peer
# IPv4 local connections:
host    all             all             127.0.0.1/32            trust
# IPv6 local connections:
host    all             all             ::1/128                 ident
# Allow replication connections from localhost, by a user with the
# replication privilege.
local   replication     all                                     peer
host    replication     all             127.0.0.1/32            ident
host    replication     all             ::1/128                 ident
1 Answers

It looks like it is preemptively loading your gss/kerberos config files (even though it is not going to use them), and finds something it doesn't like in them. But that appears to be just a warning. The real error is the last line:

FATAL: Ident authentication failed for user "postgres"

and I don't think that has anything to do with GSS. Look in the server's log file to see why ident failed.

If the pg_hba.conf you show is the one in effect, then on your system localhost must be resolving to ::1, not to 127.0.0.1. That is, it is using ipv6 rather than ipv4.

Related