I am trying the python-gvm library. But while running the code that has basic code of printing the version, I am seeing the below error. What am I missing here?
Traceback (most recent call last):
File “/home/user/OpenVasTools/./openVasTest.py”, line 8, in
with Gmp(connection=connection) as gmp:
File “/usr/local/lib/python3.10/dist-packages/gvm/protocols/base.py”, line 51, in enter
self.connect()
File “/usr/local/lib/python3.10/dist-packages/gvm/protocols/base.py”, line 107, in connect
self._connection.connect()
File “/usr/local/lib/python3.10/dist-packages/gvm/connections.py”, line 464, in connect
self._socket.connect((self.hostname, int(self.port)))
File “/usr/lib/python3.10/ssl.py”, line 1375, in connect
self._real_connect(addr, False)
File “/usr/lib/python3.10/ssl.py”, line 1362, in _real_connect
super().connect(addr)
ConnectionRefusedError: [Errno 111] Connection refused
Please let me know if I need to provide any details. I have logged into the Ubuntu 22.04 VM and have not logged in as a root.
This is my code:
#!/usr/bin/env python3
import gvm
from gvm.connections import TLSConnection
from gvm.protocols.latest import Gmp
connection = gvm.connections.TLSConnection(hostname=‘<IP Address of the logged in server/ the IP address of the VM where we have installed the Greenbone Community Edition application.>’)
with Gmp(connection=connection) as gmp:
version = gmp.get_version()
print(version)
the connection could not be established. That’s it. You tried to connect via TLS which requires to setup the gvmd service accordingly. Normally this means you need to take a look at gvmd --help for the TLS related arguments and to adjust the gvmd.service file to add additional arguments.
Alternatively you can change the connection to use the unix socket if the code is running on the same machine as gvmd. This is much easier to handle by the way.
Thanks @bricks for your response. I tried the UnixSocketConnection as well but I don’t see the socket connection or the .socket file in the /run location. I don’t even see the gvmd folder under run folder. Is there something I am doing wrong? Can you please me here?
How did you install the Greenbone Community Edition? The socket location of course depends on the installations method and which paths the maintainer of the installation method/docs/packages/… did choose. The default is /run/gvmd/gvmd.sock. Did you also check if gvmd is running at all?
The gvmd services are not running in the server. Do I need to run anything steps of creating the directories and providing the permissions to the directories?
Ok. Let me ask the basic question here. Since I did the container based installation, just running the command mentioned in the Installation steps is enough (I assume just one command)? Or Do I need to follow any other command?
Or is there any specific command just to run gvmd services? I assume sudo systemctl enable gvmd is a manual command.
Regarding the /var/log/gvm/gvmd.log I do not see anything. Here is the snap of the log file directory. I assume the permissions should have been taken care with the Container based installation.
That command is for auto starting the service on your system startup (after a reboot). To actually start the service now you need to run sudo systemctl start gvmd.
If gvmd is not starting or running correctly there must be some error messages in /var/log/gvm/gvmd.log.
Btw. if that’s the content of you /var/log/gvm directory you are not following our docs and instead are most likely using some Kali installation.
I have followed the steps mentioned in the Container based installation using the same link. Still it did not star gvmd. I am able to work with the OpenVAS GUI with out any issues.
I was able to run the command and it failed to start the service. Is there any other dependent command to run? The log file info is as in the snippet below when I ran the command manually.
I have used the Container based installation for setting up the application on the Ubuntu 22.04 VM.
I have asked about the systemctl commands because I can try manual running of the command to bring up gvmd since Brics has mentioned that the gvmd service need to be up and running.
Not sure if the container setup has been followed because the screenshot of the logs shows that version 21.4.4 of the manager daemon is used while the docker container version is already at 22.4.2.
Or the logs are from a side-by-side installation of the GVM stack originating from a package based installation of the GVM stack of the Ubuntu maintained packages (which are outdated, in a at least partly non-working state and not maintained by Greenbone).
We have installed the application during October/November 2022. Do we need to update to the latest version? if yes, can you please share us the commands for upgradation?
Unfortunately i don’t have any knowledge to give support for such topics, especially as i also don’t now which of the installations is the “active” / productive one.
For now i can only suggest to first decide which of the deployment variant you want to use: