postgresqlssl

FATAL: could not access private key file “/etc/ssl/private/ssl-cert-snakeoil.key”: Permission denied


I believe I ended up mixing up permissions at /etc/ssl directories tree as the last modification was made on 18th November and a day after I could not get my PostgreSQL to work.

When I type in

sudo service postgresql start

I get

FATAL: could not access private key file “/etc/ssl/private/ssl-cert-snakeoil.key”: Permission denied

Checking permissions

~$ sudo -i
~$ ls -la /etc/ssl/private
drw-r----- 2 root ssl-cert 4096 Nov 18 21:10 .
-rwxrwxrwx 1 postgres postgres 1704 Set 4 11:26 ssl-cert-snakeoil.key

Checking group composition

~$ id postgres
uid=114(postgres) gid=127(postgres) groups=127(postgres),114(ssl-cert)

Also I noticed that my ssl-cert-snakeoil.pem file at /etc/ssl/certs/ doesn't have a symlink. I don't know if this makes any difference...

Please, help me sort this out.

Thanks.

Edit: Should it be posted on serverfault instead?


Solution

  • Try adding postgres user to the group ssl-cert

    Run the below code to fix your issue:

    It happened to me and it turned out that I removed the postgres user from ssl-cert group. In order to set it back run the command:

    sudo gpasswd -a postgres ssl-cert
    

    Then fix ownership and mode

    sudo chown root:ssl-cert  /etc/ssl/private/ssl-cert-snakeoil.key
    sudo chmod 740 /etc/ssl/private/ssl-cert-snakeoil.key
    

    Now postgresql starts and install command doesn't fail anymore!

    sudo /etc/init.d/postgresql start
    

    courtsey to GabLeRoux