How can I access gvmd database from psql? (.deb Community Edition)

Hello everyone and thank you in advance for your help, I’m new here and this is my first post, I apologize if somehow I mis-posted this question, I could not find an answer in previous posts using the search functions.

I installed GVM Community Edition directly on a fresh Kali installation, with virtually no customizations:

GVM versions

gsad: 21.4.3
gvmd: 21.4.4
openvas-scanner: 21.4.2.
gvm-libs: 21.4.2

Environment

Operating system: Kali 2021.3
Kernel: Linux kali 5.14.0-kali2-amd64 #1 SMP Debian 5.14.9-2kali1 (2021-10-04) x86_64 GNU/Linux
Installation method / source: standard package manager.

The scanner runs fine, postgresql 14 is listening on port 5433/tcp, everything’s alright.

So, here’s my question:
I had a python script that extracted more information from the old sqlite database (mostly from the “hosts”, “hosts_identifiers” and “host_details” tables) to further customize my LaTeX reporting, but now that GVM has transitioned to postgresql I cannot connect anymore to the database directly via a script to collect data from those tables since I don’t know the password…

As far as I understand, during the installation process an ad-hoc postgresql user has been created for gvmd with a (possibly?) random password and only local connections are allowed. I have basically no previous experience with postgres. Is there a default password to access the database via command line?

here’s what I tried:

  • psql -h localhost -p 5433 -U postgres --no-password doesn’t work. I tried to launch that command as standard user, with sudo and as _gvm and postgres users with no luck. I assume that postgres user doesn’t exist.

  • psql -h localhost -p 5433 -U gvm --no-password doesn’t work either. I am pretty sure that user gvm exists, I can’t prove it though…

To create a new “superuser” - from what I can tell - I still need a valid postgres account with admin privileges.

Can any one of you point me to the right direction?

Thank you!

I think I found a solution to my own problem: in fact, I was overthinking the whole thing.
Somehow if I run as “_gvm” user the commands “psql” and “pg_dump” without specifying port, hostname and user/password everything works just fine:

  • sudo -u _gvm psql gvmd just works, as well as:

  • sudo -u _gvm pg_dump --inserts gvmd -t table> table.sql

Using python (as user “_gvm”), it is possible to fetch data from gvmd using psycopg2 and no other info than the DB name:

conn = psycopg2.connect(dbname = "gvmd")

Okay, probably it was a dumb question, but I hope someone will find the answer useful, somehow!
Thank you.

2 Likes

Hola Antonio
Se puede conectar a través de pgadmin?
Es que quiero personalizar un informe en Excel extrayendo esos datos.

Hi Oscar, I did not try it, but I guess that you could run pgadmin launching it as user “_gvm” from a shell…

1 Like