Está en la página 1de 2

CONEXIONES REMOTAS

1. Por seguridad, tras una instalacin por defecto de PostgreSQL en Centos, este aceptar
nicamente conexiones locales en el puerto 5432/tcp.
[root@localhost a]# netstat -punta | grep LISTEN
tcp
0
0 127.0.0.1:5432
0.0.0.0:*
LISTEN
3026/postmaster
2. Para
modificar
este
comportamiento
tenemos
que
editar
el
fichero /var/lib/pgsql/data/pg_hba.conf, que contiene la configuracin para la autenticacin de
clientes y aadir el listado de las redes y/o IPs desde las que nos vamos a conectar:
[root@localhost a]# vim /var/lib/pgsql/data/pg_hba.conf
host all
all
127.0.0.1/32
md5
host all
all
172.25.13.13/32 md5
host all
all
172.25.13.0/16 md5su [root@localhost a]# service postgresql stop
Stopping postgresql service:
[OK]
[root@localhost a]# service postgresql start
Starting postgresql service:

[OK]

3. Adems, tenemos que editar el fichero /var/lib/pgsql/data/postgresql.conf y modificar el


parmetro listen_addresses para indicar que escuche en las interfaces necesarias, en este caso
lo habilitaremos para todas:
[root@localhost a]# vim /var/lib/pgsql/data/postgresql.conf
listen_addresses='*'
[root@localhost a]# /etc/init.d/postgresql restart
[root@localhost a]# netstat -punta | grep LISTEN
tcp
tcp

0
0

0 0.0.0.0:22
0 0.0.0.0:5432

0.0.0.0:*
0.0.0.0:*

[root@localhost a]# service postgresql stop


Stopping postgresql service:
[root@localhost a]# service postgresql start
Starting postgresql service:

LISTEN
LISTEN

1711/sshd
29993/postmaster

[OK]
[OK]

Nota: para mayor informacin chequear el link: http://wiki.woop.es/PostgreSQL


4. Modificar la contrasea del usuario postgres de PostgreSQL
Para cambiar la contrasea de un usuario de PostgreSQL tenemos que utilizar la sentencia
sql: ALTER USER usuario WITH PASSWORD:
# su - postgres
$ psql -d template1 -U postgres
template1=# ALTER USER postgres WITH PASSWORD 'zaQ6RzRhFb';
ALTER ROLE
5. Comprobar la versin de PostgreSQL instalada.
La forma ms cmoda es ejecutando la sentencia SQL SELECT VERSION(), ejemplo:
template1=# SELECT VERSION();

Version
----------------------------------------------------------------------------------------------------------PostgreSQL 8.1.11 on x86_64-redhat-linux-gnu, compiled by GCC gcc (GCC) 4.1.2
20070626 (Red Hat 4.1.2-14)
(1 fila)
Nota:
Otros detalles que hay que tener en cuenta para la conexin remota, es desactivar el firewall en el
servidor de base de datos postgres.

También podría gustarte