Postgresql Password Recovery

postgresql
authentication

#1

I was reviewing the Event Maintenance document in the Wiki and decided to at least take a look at some of the useful queries. I can’t seem to access pslq using the creds that I documented for the database as entering at install.

psql -U dlcopennms -W
Password for user dlcopennms:
psql: FATAL: Peer authentication failed for user “dlcopennms”

Are there other things I should do/look at before I embark on the password recovery process documented in
https://stackoverflow.com/questions/10845998/i-forgot-the-password-i-entered-during-postgres-installation ?

Thanks …


#2

Have a look at opennms-datasources.xml.
In a default installation the credentials should be stored there.


#3

Hmmm … my creds are correct per the file you
referenced.

      [ctbradt@dlc-opennms etc]$ cat  opennms-datasources.xml
<?xml version="1.0" encoding="UTF-8"?>
<datasource-configuration>
<connection-pool
factory="org.opennms.core.db.C3P0ConnectionFactory" idleTimeout="600"  loginTimeout="3" minPool="50" maxPool="50" maxSize="50" />

<jdbc-data-source name="opennms"
database-name="opennms"
class-name="org.postgresql.Driver"
url="jdbc:postgresql://localhost:5432/opennms"
user-name="dlcopennms"
password="xxxxxxxx" />
<jdbc-data-source name="opennms-admin"
database-name="template1"
class-name="org.postgresql.Driver                
url="jdbc:postgresql://localhost:5432/template1"
user-name="dlcopennms"
password="xxxxxxxx" />

#4

Check also your pg_hba.conf file.
https://www.postgresql.org/docs/10/auth-pg-hba-conf.html


#5

Resolved … in pg_hba.conf changed
local all all peer
to
local all all password

Not sure why ‘peer’ does not work, I created an OS user account with the same id/password but that did not help. Am I missing something else to make that work? The document you referenced states " Peer authentication is only available on operating systems providing the getpeereid() function, the SO_PEERCRED socket parameter, or similar mechanisms. Currently that includes Linux, most flavors of BSD including macOS, and Solaris." I’m using a minimal CentOS image but not enough of a Linux geek to know if the function is provided.

Thanks …