LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 07-17-2017, 04:06 AM   #1
Doug Hutcheson
Member
 
Registered: Jun 2009
Location: Philippines
Distribution: Fedora 36; Homebrew desktop with Ryzen 5600G and 32Gb. Using Red Hat since 1998
Posts: 304

Rep: Reputation: 22
Authentication not working for PostgreSQL 9.6 / Fedora 26


I have just upgraded from F25 to F26. The upgrade worked fine, except for PostgreSQL which moved from 9.5 to 9.6.

Now, the only authentication method that works is 'trust', which is clearly unsuitable.

I have hacked pg_ident.conf and pg_hba.conf to no avail.

If some kind soul could show me the obvious error I am making, I would be very grateful.

Doug
 
Old 07-17-2017, 03:23 PM   #2
dysonsimmons
LQ Newbie
 
Registered: Jul 2017
Posts: 5

Rep: Reputation: Disabled
Hmmm, it's strange you can connect with trust at the moment. I wouldn't have thought postgres would actually be running:

Quote:
systemctl status postgresql.service
● postgresql.service - PostgreSQL database server
Loaded: loaded (/usr/lib/systemd/system/postgresql.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Mon 2017-07-17 21:05:07 BST; 4s ago
Process: 15705 ExecStartPre=/usr/libexec/postgresql-check-db-dir postgresql (code=exited, status=1/FAILURE)

systemd[1]: Starting PostgreSQL database server...
postgresql-check-db-dir[15705]: An old version of the database format was found.
postgresql-check-db-dir[15705]: Use 'postgresql-setup --upgrade' to upgrade to version '9.6'
postgresql-check-db-dir[15705]: See /usr/share/doc/postgresql/README.rpm-dist for more information.
systemd[1]: postgresql.service: Control process exited, code=exited status=1
systemd[1]: Failed to start PostgreSQL database server.
systemd[1]: postgresql.service: Unit entered failed state.
systemd[1]: postgresql.service: Failed with result 'exit-code'.
You will need to download the upgrade package if you don't have it yet:

Quote:
sudo dnf install postgresql-upgrade
and run the upgrade setup to upgrade the actual databases:

Quote:
sudo postgresql-setup --upgrade
then you should see a message saying your old files are moved to /var/lib/pgsql/data-old so you will need to do a diff between /var/lib/data/pgsql/pg_hba.conf and /var/lib/data-old/pgsql/pg_hba.conf and carry over any old config info you want.

Finally restart postgresql:

Quote:
sudo systemctl restart postgresql

Last edited by dysonsimmons; 07-18-2017 at 12:49 PM.
 
Old 07-18-2017, 05:29 PM   #3
Doug Hutcheson
Member
 
Registered: Jun 2009
Location: Philippines
Distribution: Fedora 36; Homebrew desktop with Ryzen 5600G and 32Gb. Using Red Hat since 1998
Posts: 304

Original Poster
Rep: Reputation: 22
Quote:
Originally Posted by dysonsimmons View Post
You will need to download the upgrade package if you don't have it yet ... and run the upgrade setup to upgrade the actual databases ... then you should see a message saying your old files are moved to /var/lib/pgsql/data-old so you will need to do a diff between /var/lib/data/pgsql/pg_hba.conf and /var/lib/data-old/pgsql/pg_hba.conf and carry over any old config info you want.

Finally restart postgresql:
Thanks very much for replying dysonsimmons.

Sadly, I have already done all of the above, before posting my question. The only way I can make PostgreSQL available to psql and pgAdminIII is to add "host all all 192.168.0.100/16 trust" to my pg_hba.conf, but this does not make it accessible by LibreOffice which is my main concern. (Note: I chose the /16 suffix randomly and don't know if it achieves anything).

I am nerving myself to dive into the security documentation for pg 9.6, to see if I can understand enough to get it working. Shudder!

Kind regards,
Doug.
 
Old 07-18-2017, 05:55 PM   #4
dysonsimmons
LQ Newbie
 
Registered: Jul 2017
Posts: 5

Rep: Reputation: Disabled
Ah ok bugger. I've never used it with LibreOffice. Can you give me some basic instructions so I can reproduce the issue? I still want to help you sort it out if I can!

You should be able to access using psql or pgAdminIII on the same machine postgres is on using a username and password (you want to use username and password corret?) with the following change:

From:

Quote:
host all all 127.0.0.1/32 peer
To:

Quote:
host all all 127.0.0.1/32 md5
If you want access from another machine (suggested by the IP range you provided) you definitely don't want /16. That is a class b netmask of 65k hosts. Most home setups would be /24 (255.255.255.0). If you have a look at the computer you want to access postgres from (assuming there is no nat in the middle) for its network connections netmask you will be able to determine what to put in pg_hba.conf.

Last edited by dysonsimmons; 07-18-2017 at 06:10 PM.
 
Old 07-18-2017, 07:19 PM   #5
Doug Hutcheson
Member
 
Registered: Jun 2009
Location: Philippines
Distribution: Fedora 36; Homebrew desktop with Ryzen 5600G and 32Gb. Using Red Hat since 1998
Posts: 304

Original Poster
Rep: Reputation: 22
Quote:
Originally Posted by dysonsimmons View Post
Can you give me some basic instructions so I can reproduce the issue?
You may need to install the LibreOffice PostgreSQL driver:here. Then, open LibreOffice Base. It will ask you if you want to 'Connect to an existing database' (third option in the dialog). On my system, the PostgreSQL driver is at the bottom of the drop-down list. Click next and type in the appropriate URL details - for me, they are 'postgresql://localhost:5432/ABPA'. Click next and you will be asked for username and (optionally) password. Fill in your details and click 'Test Connection' - this is where my system fails. The actual error message is 'An error has occurred: Error connecting to the server: FATAL: password authentication failed for user "postgres"'

Quote:
Originally Posted by dysonsimmons View Post
I still want to help you sort it out if I can!
Thanks a million for sticking with me!

Quote:
Originally Posted by dysonsimmons View Post
You should be able to access using psql or pgAdminIII on the same machine postgres is on using a username and password (you want to use username and password correct?) with the following change:<snip>
If you want access from another machine (suggested by the IP range you provided) you definitely don't want /16. That is a class b netmask of 65k hosts. Most home setups would be /24 (255.255.255.0). If you have a look at the computer you want to access postgres from (assuming there is no nat in the middle) for its network connections netmask you will be able to determine what to put in pg_hba.conf.
Yes, I want to use passwords and I want to allow computers on the local network (192.168.0.*) to connect to pg.

I have changed my pg_hba.conf to set "host all all 192.168.0.0/24 trust" and that much still works. However, I am getting a feeling there must be some kind of 'security server' missing from my system, because changing 'trust' to 'md5' (or 'peer', or 'password', or ident ...) still breaks my ability to connect using PgAdminIII. Even changing to '127.0.0.1/32 all all md5' I can connect via psql - without being prompted for a password - but PgAdminII returns the error.

Given the above, I am unsure if I am fighting a PostgreSQL problem or a Fedora26 security problem.

To summarise:
with 'host all all 127.0.0.1/32 md5' I can connect with psql but not PgAdminII or LibreOffice.
with 'host all all 192.168.0.100/24 trust' I can connect with both psql and PgAdminII but not LibreOffice.
with any kind of security other than 'trust' I cannot connect with PgAdminIII.
I cannot connect with LibreOffice using any combination I have tried.

Sigh!
 
Old 07-19-2017, 12:05 AM   #6
Doug Hutcheson
Member
 
Registered: Jun 2009
Location: Philippines
Distribution: Fedora 36; Homebrew desktop with Ryzen 5600G and 32Gb. Using Red Hat since 1998
Posts: 304

Original Poster
Rep: Reputation: 22
Got it! I changed my pg_hdb.conf to contain ONLY these specifications:

host all all 0.0.0.0/0 md5
host all all ::1/128 md5

Now I can connect using psql, PgAdminIII, PgModeler and LibreOffice Basic - in other words, my problem has been fixed. Obviously I had garbled my .conf during my attempts to force it into submission.

Thanks for your help, dysonsimmons, as it encouraged me to keep looking.

(Takes note to self: if all else fails, RTFM).
 
Old 07-19-2017, 05:56 PM   #7
dysonsimmons
LQ Newbie
 
Registered: Jul 2017
Posts: 5

Rep: Reputation: Disabled
Great to know you got your access back!

Now that you have it working I would attempt to restrict the IP and netmask again to the smallest range suitable for your requirements.

Good job sticking with it and reading the docs!
 
Old 07-19-2017, 06:33 PM   #8
Doug Hutcheson
Member
 
Registered: Jun 2009
Location: Philippines
Distribution: Fedora 36; Homebrew desktop with Ryzen 5600G and 32Gb. Using Red Hat since 1998
Posts: 304

Original Poster
Rep: Reputation: 22
Quote:
Originally Posted by dysonsimmons View Post
I would attempt to restrict the IP and netmask again to the smallest range suitable for your requirements.
Good point. I am comfortable with changing the IPv4 address to 192.168.0.0/24 again, but have never fiddled with IPv6. How should I define that to allow access only from the local network? I have Googled, but my search terms are obviously not adequate. "8-[
 
Old 07-20-2017, 12:36 PM   #9
dysonsimmons
LQ Newbie
 
Registered: Jul 2017
Posts: 5

Rep: Reputation: Disabled
This doesn't really answer your question but the easiest thing to do is not include the IPv6 line as I'm assuming you aren't using IPv6 in your network.
 
Old 07-20-2017, 04:03 PM   #10
Doug Hutcheson
Member
 
Registered: Jun 2009
Location: Philippines
Distribution: Fedora 36; Homebrew desktop with Ryzen 5600G and 32Gb. Using Red Hat since 1998
Posts: 304

Original Poster
Rep: Reputation: 22
Quote:
Originally Posted by dysonsimmons View Post
I'm assuming you aren't using IPv6 in your network.
I thought so too, until I discovered pgModeler connects via IPv6; at least, without that line in the .config Modeler does not run and with that line it does run. Curious.
 
Old 07-20-2017, 04:40 PM   #11
dysonsimmons
LQ Newbie
 
Registered: Jul 2017
Posts: 5

Rep: Reputation: Disabled
Oh yeah you're right. Good to know and to learn something new!

Double checking the IP6 address ::1/128 is the loopback range so leave it but maybe just change it from md5 to ident which is the default.
 
Old 07-20-2017, 05:01 PM   #12
Doug Hutcheson
Member
 
Registered: Jun 2009
Location: Philippines
Distribution: Fedora 36; Homebrew desktop with Ryzen 5600G and 32Gb. Using Red Hat since 1998
Posts: 304

Original Poster
Rep: Reputation: 22
Quote:
Originally Posted by dysonsimmons View Post
Good to know and to learn something new!
Glad to be of service. "8-D

I'll try ident and see what happens, but I must admit I adhere to the rule "if it ain't broke, don't fix it". I'll let you know how I get on.

---------------

Later:

With 'ident', pgModeler returns an error trying to connect. Switched it back to md5 and all was sweetness and light. I think I'll leave it alone, because I only need pgModeler on this machine.

Many thanks for all the help. "8-)

Last edited by Doug Hutcheson; 07-20-2017 at 05:12 PM. Reason: Tested ident
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't get LDAP authentication working on Fedora 13 Xudonax Fedora 11 11-06-2010 02:08 AM
Get authentication error when starting postgresql for the first time mrj Linux - Software 0 09-04-2009 12:34 PM
working with php and postgresql mamta Linux - Server 1 03-07-2007 04:44 AM
postgresql authentication problem yasasvi Linux - Software 0 08-08-2005 01:09 PM
Help getting PostgreSQL working -- createuser johnMG Debian 3 03-31-2004 08:19 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 08:13 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration