0

I have a server named as servername.mydomain.com. I can do ssh to this server using a port number X using:

ssh  myusername@servername.mydomain.com -p X

From this server I can run:

psql -h localhost -d myDatabase -U myusername -p DBPORT

Instead of having to login using ssh I want to be able to use psql as:

psql -h servername.mydomain.com:X -d myDatabase -U myusername -p DBPORT

Is this possible? I tried this but I am getting the message: could not translate hostname ...

Jose Cabrera Zuniga
  • 179
  • 1
  • 3
  • 11

1 Answers1

1

leave out the :x

 psql -h servername.mydomain.com -d myDatabase -U myusername -p DBPORT

You may need to edit the listen_addresses directive in postgrersql.conf (and restare poastgresql.

Alternatively you can tunnel the postgres connection.

ssh  myusername@servername.mydomain.com -p X -R DBPORT:127.0.0.1:DBPORT

then on another command-line

psql -h 127.0.0.1 -d myDatabase -U myusername -p DBPORT
Jasen
  • 826
  • 6
  • 12