pmatos
pmatos

Reputation: 296

How to setup the pg_hba.conf

I need your help on correctly setup pg_hba.conf for 2 specific postgres servers on different networks. The first server is on local network and the second is on a Cloud server.

Since I will have to setup syncronization between them, I must make sure that both can communicate.

The 'listen_address' is already setup to '*', on postgresql.conf.

My question is, if I add:

host all all 0.0.0.0/0 trust

...to the pg_hba.conf file on both servers will they communicate free of errors?

Perhaps this is not the best way to do it, but since this is for testing purposes perhaps solves my problem for now. Any better and safest solution please?

Thank you all

Regards

Paulo Matos

Upvotes: 0

Views: 1903

Answers (1)

jjanes
jjanes

Reputation: 44363

Since you do not have a static IP for the system connecting to the database, then you should use some method other than "trust". You can use md5, and put the password into a .pgpass file on the client.

You could put the client's host name, rather than IP address, in the 4th field. But that requires a reverse DNS to work correctly (I don't know if dyndns.org supports that) and I've found it overly fiddly and unreliable.

You probably also want to use SSL ("hostssl"). Using md5 will kind of protect your password, but an eavesdropper can still see all the queries you send and all the responses to them.

Upvotes: 0

Related Questions