Home > Software design >  ssl file permission on postgresql 14 is not right
ssl file permission on postgresql 14 is not right

Time:05-13

After enabling ssl on postgresql 14, there is error when starting the Postgres server:

2022-05-13 00:09:39.791 CST [938050] FATAL:  private key file "/etc/postgresql/14/main/server.key" has group or world access
2022-05-13 00:23:09.163 CST [938097] DETAIL:  File must have permissions u=rw (0600) or less if owned by the database user, or permissions u=rw,g=r (0640) or less if owned by root.

What I did is to following the hint above and chmod 640 server.key. Here is the current permission output after chmod (seems only remove r for group)

-rw-r--r-- 1 root     root      2727 May 13 00:08 server.crt
-rw-r----- 1 root     root      3323 May 13 00:08 server.csr
-rw-r----- 1 root     root      1704 May 13 00:08 server.key

But restarting Postgres server still has error:

2022-05-13 00:38:09.331 CST [938235] FATAL:  could not load private key file "/etc/postgresql/14/main/server.key": Permission denied
    2022-05-13 00:38:09.331 CST [938235] LOG:  database system is shut down
    pg_ctl: could not start server

What is missing here with the ssl file permission?

CodePudding user response:

First, change the ownership of all files to the PostgreSQL user:

chown postgres server.crt server.key server.csr

Then remove the read permissions for the group from the private key file:

chmod g-r server.key
  • Related