Enable Remote Access To PostgreSQL Database Server
Enable Remote Access To PostgreSQL Database Server
$ ssh [email protected]
Once connected, you need edit the PostgreSQL configuration file, edit the
PostgreSQL configuration
file /var/lib/pgsql/data/pg_hba.conf (or/etc/postgresql/8.2/main/pg_hba.conf for
latest 8.2 version) using a text editor such as vi.
Login as postgres user using su / sudo command, enter:
$ su - postgres
$ vi /var/lib/pgsql/data/pg_hba.conf
OR
$ vi /etc/postgresql/8.2/main/pg_hba.conf
Save and close the file. Make sure you replace 10.10.29.0/24 with actual network IP
address range of the clients system in your own network.
You need to enable TCP / IP networking. Use either step #3 or #3a as per your
PostgreSQL database server version.
Step # 3: Allow TCP/IP socket
# vi /etc/postgresql/8.2/main/postgresql.conf
OR
# vi /var/lib/pgsql/data/postgresql.conf
listen_addresses='localhost'
Next set IP address(es) to listen on; you can use comma-separated list of
addresses; defaults to ‘localhost’, and ‘*’ is all ip address:
listen_addresses='*'
listen_addresses='202.54.1.2 202.54.1.3'
# vi /var/lib/pgsql/data/postgresql.conf
Bind and open TCP/IP port by setting tcpip_socket to true. Set / modify tcpip_socket
to true:
tcpip_socket = true
# /etc/init.d/postgresql restart
Restart firewall:
# /etc/init.d/iptables restart
Use psql command from client system. Connect to remote server using IP address
10.10.29.50 and login using vivek username and sales database, enter: