Postgresql connection via terminal - pgadmin

I have a problem connecting (using SSH) to my postgres server on a virtual server (ubuntu). I configured everything well and correctly.

PostgreSQL settings:

  • postgresql.conf

    → Allow all incoming connections (*) and set ssl TRUE
  • pg_hba.con

    f -> after a lot of changes I ended up with what seems to work with these settings:

IP4

host all all 0.0.0.0/0 trust
hostssl all all 0.0.0.0/0 trust
host all all 192.168.x.x/32 trust 
hostssl all all 192.168.x.x/32 trust 

      

I tried:

  • Did a reboot of my postgres server in a virtual machine.

  • Then I went to my host machine (Snow Leopard), built an ssh connection to virtualbox (ubuntu) and it worked.

  • ping my guest machine on port 5432 also works.

  • Open pgadmin on my host machine (Snow Leopard) -> added 192.68.56.1 server and database pluto

    , user pippo

    . The connection worked and I can see the DB.

  • Tried open TERMINAL in Snow Leopard and ran the following cmd:

    psql -h 192.168.56.1 -U pippo -d pluto
    
          

    with ERROR:

    psql: FATAL:  no pg_hba.conf entry for host "192.168.56.1", 
                  user "pippo", database "pluto", SSL off
    
          

I also tried to connect through my Java program and I got the same error.
What am I doing wrong?

+3


source to share


2 answers


pgAdmin

tries to establish a connection with and without SSL by default.

I suspect that you are only trying to connect without SSL over psql

, while the server seems to require SSL for connections. Try:



psql "sslmode=require host=192.168.56.1 dbname=pluto" pippo

      

More on sslmode

in the manual.

0


source


Open my request in pgAdmin from the command line:

-f File containing your SQL script to load in the query window

-qc Connection string without password (you can also use ssl connections)

"C:\Program Files\PostgreSQL\9.4\bin\pgAdmin3.exe" -f "C:\slqFiles\FindFunctionByName.sql" -qc "host=localhost port=5432 dbname=myDatabase user=postgres"

      



The password will be collected from the password file located in the application folder:% APPDATA% \ postgresql \ pgpass.conf

You need permissions to connect . Try adding the following line to C: \ Program Files \ PostgreSQL \ 9.6 \ data \ pg_hba.conf:

host all all :: / 0 trust

0


source







All Articles