0

On a CentOS 9 system I installed postgres via dnf

    # dnf info postgresql
Last metadata expiration check: 3:26:33 ago on Tue 21 Nov 2023 12:13:48 PM PST.
Installed Packages
Name         : postgresql
Version      : 13.11

Then I edited the pg_hba.conf to allow md5 passwords

    # TYPE  DATABASE        USER            ADDRESS                 METHOD
    
    # "local" is for Unix domain socket connections only
    #local   all             all                                     peer
    local   all             all                                     md5
    # IPv4 local connections:
    host    all             all             127.0.0.1/32            ident
    # 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
host  rt5  rt_user   all  md5
host  rt5  rt_admin  all  md5

Then I created a user for my perl application to connect using sql:

 $ sudo -u postgres psql



postgres=# CREATE USER rt_user WITH PASSWORD 'foobar';
CREATE ROLE

postgres=# ALTER USER rt_user with SUPERUSER;

postgres=# ALTER USER rt_user with CREATEDB;

I can then see the privileges are set properly: rt_user | Superuser, Create DB

I add my connection details to my perl app config (in this case the perl app is request tracker 5: https://rt-wiki.bestpractical.com/wiki/ManualInstallation#Red_Hat_Enterprise_Linux)

# DatabaseUser is the name of the database account RT uses to read and store
# data. 'rt_user' is the default but you can change it if you like.
# DO NOT use the 'rt_admin' superuser created in the instructions above.
Set($DatabaseUser, 'rt_user');
# DatabasePassword is the password for DatabaseUser.
Set($DatabasePassword, 'foobar');
# DatabaseHost is the hostname of the database server RT should use.
# Change 'localhost' if it lives on a different server.
Set($DatabaseHost, 'localhost');
# DatabasePort is the port number of the database server RT should use.
# `undef` means the default for that database. Change it if you're not
# using the standard port.
Set($DatabasePort, undef);
# DatabaseName is the name of RT's database hosted on DatabaseHost.
# 'rt5' is the default but you can change it if you like.
Set($DatabaseName, 'rt5');
# DatabaseAdmin is the name of the user in the database used to perform
# major administrative tasks. Change 'rt_admin' if you're using a user
# besides the one created in this guide.
Set($DatabaseAdmin, 'rt_admin');

Although the connection details appear to be correct, it still won't connect with this user:

# make initialize-database
/usr/bin/env -S perl -I/opt/rt5/local/lib/perl5 -I/opt/rt5/local/lib -I/opt/rt5/lib sbin/rt-setup-database --action init --prompt-for-dba-password
In order to create or update your RT database, this script needs to connect to your  Pg instance on localhost (port '') as rt_admin
Please specify that user's database password below. If the user has no database
password, just press return.

Password: 
Working with:
Type:   Pg
Host:   localhost
Port:   
Name:   rt5
User:   rt_user
DBA:    rt_admin
Failed to connect to dbi:Pg:dbname=template1;host=localhost;client_encoding=UTF8 as user 'rt_admin': FATAL:  Ident authentication failed for user "rt_admin"make: *** [Makefile:390: initialize-database] Error 255
[root@localhost rt-5.0.3]# 

1 Answer 1

0

The issue was resolved by ensuring the users were created in the database with the appropriate permissions and editing pga_hba.conf as follows:

# "local" is for Unix domain socket connections only
local   all             all                                     trust

# IPv4 local connections:
host    all             all             127.0.0.1/32            trust

# IPv6 local connections:
host    all             all             ::1/128                 trust

# Allow password authentication for the user rt_admin from a specific IP range
host    all             rt_admin        192.168.1.0/24          md5
host    all             rt_user        192.168.1.0/24          md5

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .