How to communicate with a remote Greenbone Community Containers server via TLSConnection

Hello, I install the Greenbone Community Containers 22.4 according to this wizard:Greenbone Community Containers 22.4 - Greenbone Community Documentation
I use docker-compose to pull Greenbone Community Containers 22.4, and open Greenbone Security Assistant in the browser successfully。
I want to use python combined with API(python-gvm) to get scan results and create new scan tasks. How to communicate with a remote Greenbone Community Containers server via TLSConnection, How to configure it on the server side. An error occurred when I used the following code

import gvm
from gvm.protocols.latest import Gmp
from gvm.transforms import EtreeTransform
from gvm.xml import pretty_print

connection =gvm.connections.TLSConnection(hostname='xxx.xxx.xxx.xxx', port='xxxx')
gmp = Gmp(connection)
gmp.authenticate('admin', 'admin')

# Retrieve current GMP version
version = gmp.get_version()

# Prints the XML in beautiful form
pretty_print(version)


error like this "FileNotFoundError: [Errno 2] No such file or directory".

My environment:vmware kali (Greenbone Community Containers 22.4)
windows10 (where python code runs)

I want to get the scan results through the python code in windows, what should I do.

1 Like

I’ve written two sections for accessing gvmd via gvm-tools in our docs

If that doesn’t fit to your use case and you really want to use TLS you need to adjust the starting command of gvmd to use TLS instead of a unix socket. That requires generating TLS certs and putting them into the container. Personally I don’t know all the details about the setup and there is also no documentation at Greenbone side.

1 Like

Thanks for the documentation.

I followed the second part of exposing the Unix socket. This solution worked partially. I am able to start a scan using python but I cant fetch the status. On the GUI I am getting internal server error.

Also, I would really appreciate if you can confirm that I have made correct changes. Here is the part of the compose file.

gvmd:
image: registry.community.greenbone.net/community/gvmd:stable
restart: on-failure
volumes:
- gvmd_data_vol:/var/lib/gvm
- scap_data_vol:/var/lib/gvm/scap-data/
- cert_data_vol:/var/lib/gvm/cert-data
- data_objects_vol:/var/lib/gvm/data-objects/gvmd
- vt_data_vol:/var/lib/openvas/plugins
- psql_data_vol:/var/lib/postgresql
# - gvmd_socket_vol:/run/gvmd
- /tmp/gvm/gvmd:/run/gvmd
- ospd_openvas_socket_vol:/run/ospd
- psql_socket_vol:/var/run/postgresql


gsa:
image: registry.community.greenbone.net/community/gsa:stable
restart: on-failure
ports:
- 127.0.0.1:9392:80
volumes:
# - gvmd_socket_vol:/run/gvmd
- /tmp/gvm/gvmd:/run/gvmd
depends_on:
- gvmd

Thank you.