PostgreSQL Authentication

From Wiki

(Difference between revisions)
Jump to: navigation, search
(How to enable MD5 authentication for PostgreSQL)
 
Line 21: Line 21:
* vi /var/lib/pgsql/data/pg_hba.conf
* vi /var/lib/pgsql/data/pg_hba.conf
* add the following lines in the pg_hba.conf file (note that those are all rules that you might need for 1h products PostgreSQL authentication):
* add the following lines in the pg_hba.conf file (note that those are all rules that you might need for 1h products PostgreSQL authentication):
-
local quotastats quotastats_cpanel md5
 
-
host quotastats quotastats_cpanel 127.0.0.1 255.255.255.255 md5
 
-
host quotastats quotastats_cpanel ::1/128 md5
 
-
local quotastats quotastats_local md5
 
-
host quotastats quotastats_local 127.0.0.1 255.255.255.255 md5
 
-
host quotastats quotastats_local ::1/128 md5
 
-
local lprstats lprstats_local md5
 
-
host lprstats lprstats_local 127.0.0.1 255.255.255.255 md5
 
-
host lprstats lprstats_local ::1/128 md5
 
  local cpustats cpustats_cpanel md5
  local cpustats cpustats_cpanel md5
  host cpustats cpustats_cpanel 127.0.0.1 255.255.255.255 md5
  host cpustats cpustats_cpanel 127.0.0.1 255.255.255.255 md5

Latest revision as of 06:02, 23 April 2013

This article describes the specific setup needed in order for the root user on your machine to be able to login to PostgreSQL without entering a password for the connection.

Introduction

Each cPanel server comes with the following cron job:

/scripts/update_db_cache

If there is no PostgreSQL installed for the server this specific cron job works for the MySQL database only.

In case PostgreSQL is installed for the server the expected behavior for the root user is to be able to connect to the postgre databases without supplying a password each time. In order for this to be possible MD5 authentication should be enabled instead of ident authentication.

How to enable MD5 authentication for PostgreSQL

Here are the steps that needs to be taken in order to allow connection for the root user to PostgreSQL without requesting a password.

local cpustats cpustats_cpanel md5
host cpustats cpustats_cpanel 127.0.0.1 255.255.255.255 md5
host cpustats cpustats_cpanel ::1/128 md5
local cpustats cpustats_local md5
host cpustats cpustats_local 127.0.0.1 255.255.255.255 md5
host cpustats cpustats_local ::1/128 md5
local portal_local portal_local md5
host portal_local portal_local 127.0.0.1 255.255.255.255 md5
host portal_local portal_local ::1/128 md5
*:*:*:postgres:NEWPASSHERE

That is all. You should now be able to login without being asked for password using the root user:

psql -Upostgres template1
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox