简体   繁体   中英

Format and content of lines in pg_hba.conf file

I installed Postgres 9.3 yesterday on Ubuntu 18.04 (using the Ubuntu package index). I need to add lines to the pg_hba.conf file to allow pgAdmin access on port 5432.

For example, I need to add a line in this format:

hostssl  database  user  address  auth-method  [auth-options]

My first question is what should I use for the the IP address in the "address" field. I am using pgAdmin on my local computer (Windows) to access my Ubuntu 18.04 server in the cloud, but I don't have a static IP address, so entering my IP address won't do. What IP address should I put in the address field for outside access from my local computer? It's not clear from the docs at https://www.postgresql.org/docs/11/auth-pg-hba-conf.html .

My second question is how do I indicate port 5432 in the line above? I believe that's the default listener port for Postgres, so doesn't it need to be specified in the line above?

What you have to specify in pg_hba.conf is not an IP address, but a netmask : an IP address followed by a number between 0 and 32 that tells how many bits of the address are significant.

For example

12.23.34.99/24

matches all IP addresses between 12.23.34.0 and 12.23.34.255 .

Find out in which range your possible IP addresses are and use that.

pg_hba.conf determines which authentication method is used for an incoming connection. It comes into play after the TCP connection to server port 5432 has been established.

To configure on which TCP port PostgreSQL should listen, edit postgresql.conf and restart PostgreSQL.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM