I am trying to run a simple script using the python-gvm library from a windows machine to connect to my Breenbone Security Manager on another machine.
The script goes like this:
from gvm.connections import SSHConnection
from gvm.protocols.gmp import Gmp
from gvm.transforms import EtreeTransform
connection = SSHConnection(hostname=<HOSTNAME>, username=<ADMIN>, password=<PASSWORD>)
transform = EtreeTransform()
with Gmp(connection, transform=transform) as gmp:
# Retrieve GMP version supported by the remote daemon
version = gmp.get_version()
But I keep getting the same error, which I can’t understand why is popping up:
GvmError Traceback (most recent call last)
<ipython-input-21-1e67790e5056> in <module>
----> 1 with Gmp(connection=connection) as gmp:
2 pretty_print(gmp.get_version())
3
4
c:\users\user\appdata\local\programs\python\python38-32\lib\site-packages\gvm\protocols\gmp.py in __enter__(self)
122
123 def __enter__(self):
--> 124 gmp = self.determine_supported_gmp()
125
126 gmp.connect()
c:\users\user\appdata\local\programs\python\python38-32\lib\site-packages\gvm\protocols\gmp.py in determine_supported_gmp(self)
101 corresponding Gmp class instance
102 """
--> 103 version = self.determine_remote_gmp_version()
104 major_version = int(version.split('.')[0])
105 if major_version == 7:
c:\users\user\appdata\local\programs\python\python38-32\lib\site-packages\gvm\protocols\gmp.py in determine_remote_gmp_version(self)
85 """Determine the supported GMP version of the remote daemon"""
86 self.connect()
---> 87 resp = self._send_xml_command(XmlCommand("get_version"))
88 self.disconnect()
89
c:\users\user\appdata\local\programs\python\python38-32\lib\site-packages\gvm\protocols\base.py in _send_xml_command(self, xmlcmd)
84 xmlcmd (gvm.xml.XmlCommand): XmlCommand instance to send
85 """
---> 86 return self.send_command(xmlcmd.to_string())
87
88 def is_connected(self) -> bool:
c:\users\user\appdata\local\programs\python\python38-32\lib\site-packages\gvm\protocols\base.py in send_command(self, cmd)
138 except Exception as e:
139 self.disconnect()
--> 140 raise e
141
142 return self._transform(response)
c:\users\user\appdata\local\programs\python\python38-32\lib\site-packages\gvm\protocols\base.py in send_command(self, cmd)
135 try:
136 self._send(cmd)
--> 137 response = self._read()
138 except Exception as e:
139 self.disconnect()
c:\users\user\appdata\local\programs\python\python38-32\lib\site-packages\gvm\protocols\base.py in _read(self)
61 str: Response from server.
62 """
---> 63 return self._connection.read()
64
65 def _send(self, data):
c:\users\user\appdata\local\programs\python\python38-32\lib\site-packages\gvm\connections.py in read(self)
139 if not data:
140 # Connection was closed by server
--> 141 raise GvmError("Remote closed the connection")
142
143 self._feed_xml(data)
GvmError: Remote closed the connection
What could cause this issue?
GVM versions
Wasn’t sure to which each of those fields refer to, but the version of python-gvm I downloaded from pip was 21.1.3 and the version of the Greenbone OS is 20.08.7
I hope this is OK.
Environment
The Environment that runs the script is a windows 10 and the Greenbone Security Manager runs on a Greenbone OS 20.08.7