Error in response. First command must be AUTHENTICATE, COMMANDS or GET_VERSION

Thanks for your answer.
I wrote this code:

from gvm.connections import UnixSocketConnection
from gvm.protocols.latest import Osp
from gvm.transforms import EtreeCheckCommandTransform

path = ‘/var/run/openvasmd.sock’
connection = UnixSocketConnection(path=path)
transform = EtreeCheckCommandTransform()

osp = Osp(connection=connection, transform=transform)

targets = [{‘hosts’: ‘localhost’, ‘ports’: ‘80,43’}]
r = osp.start_scan(targets=targets)
print®

When I run my code, I get this Error:

raise GvmError(‘Error in response. {0}’.format(status_text), root)

gvm.errors.GvmError: (‘Error in response. First command must be AUTHENTICATE, COMMANDS or GET_VERSION’, <Element omp_response at 0x7f469b313c08>)

Cloud you please help me?
Thanks

First of all you are using the wrong protocol class to communicate with the manager daemon. You have to use Gmp (for the Greenbone Management Protocol) instead of Osp (Open Scanner Protocol for communication with an OSP scanner).

Second for privileged commands you need to authenticate against the manager. Please take a look at the usage docs for some more details

https://python-gvm.readthedocs.io/en/latest/usage.html

2 Likes