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)

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?

[Errno 111] Connection refused when I use openvas_lib

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