Sometimes you need to provide remote administration where you can not directly connect to your server via ssh and create tunnels. For security reasons, by default, postgresql disables all remote connections.
Here are my notes on how to make postgresql sql available to other systems on the same network. I found these instructions to be the easiest and generally secure. If you have a good understanding of networking, you can further lock this down.
Code Block |
---|
|
sudo vi /etc/postgresql/8.4/main/postgresql.conf |
Search for this line,
Code Block |
---|
|
#listen_addresses = 'localhost' # what IP address(es) to listen on; |
Change to,
Code Block |
---|
|
listen_addresses = '*' # what IP address(es) to listen on; |
Modify,
Code Block |
---|
sudo vi /etc/postgresql/8.4/main/pg_hba.conf |
And add this line to the bottom of the file where 192.168.0.0/16 is reflective of your particular network range. In this example, we are saying to allw any computer on the local network (in this case subnet 192.168.x.x) to connect to any database. The md5 indicates that the user must also supply a password.
Code Block |
---|
|
# Allow local connections from local network
host all all 192.168.0.0/16 md5 |
Restart the postgres service,
Code Block |
---|
|
sudo /etc/init.d/postgresql-8.4 restart |