0

i wonder why postgres allows trust Authentication method as it allow any role to connect without providing a password!!

if any role change the pg_hba.conf to trust then the server will be unsecure and will open to any role with any password

i would like to prevent any connection to the server without providing the right password , so how can we prevent this ? is their any best practices follow in order to secure postgres server ?

2 Answers 2

2

As described in the manual, the postgresql daemon should be run as a separate user account which is not used for other purposes. The data directory and all the files in it should be owned by this user and permissions set so that only this user has access to it.

The initdb command which is used to initialise the database cluster will set it up like this.

If set up correctly, only the postgres user, or root, can edit pg_hba.conf.

The basic assumption behind the trust method is that the user is pre-authenticated by the environment. For example, if the database is not configured to listen on any external interface, and you are sure only authorised users can log into the server.

Section 19.3.1 describes in more detail the circumstances under which you might want to use the 'trust' method.

Sign up to request clarification or add additional context in comments.

Comments

0

Check 19.3. Authentication Methods

2 Comments

i know there is another authentication methods , but if anyone can edit the pg_hba.conf file and change it to trust then the server will be unsecure , so i want to prevent the change
If anyone can edit the pg_hba.conf file, anyone can do anything with your server. It is up to administrator to make sure that nobody else has access to Postgres data folder.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.