Connect python client (python-gvm) to GVM 11 via SSH

Hi, I’ve managed to setup a ssh connection like you want to use.

You need to create a user with a shell that points to a script that can expose unix socket. e.g

useradd -s /shell.sh test

Script content:

#!/bin/bash
socat UNIX:/usr/local/var/run/gvmd.sock -

That will make GVM unix socket to be exposed to test user TTY.

Here is code snippet that works:

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

connection = SSHConnection(hostname='192.168.99.121',username='test',password='test', port=2222)

transform = EtreeTransform()
with Gmp(connection, transform=transform) as gmp:
    gmp.authenticate("admin", "admin")
    version = gmp.get_version()
    pretty_print(version)
4 Likes