From within the source directory, /opt/gvm/gvm-source, in this setup, change to GVM libraries directory;
cd /opt/gvm-source/gvm-libs
mkdir build && cd build
export PKG_CONFIG_PATH=/opt/gvm/lib/pkgconfig:$PKG_CONFIG_PATH
cmake .. -DCMAKE_INSTALL_PREFIX=/opt/gvm
make
sudo make install
Build and Install OpenVAS scanner and OpenVAS SMB
Open Vulnerability Assessment Scanner (OpenVAS) is a full-featured scan engine that executes a continuously updated and extended feed of Network Vulnerability Tests (NVTs).
OpenVAS SMB provides modules for the OpenVAS Scanner to interface with Microsoft Windows Systems through the Windows Management Instrumentation API and a winexe binary to execute processes remotely on that system.
Build and install openvas-smb
cd /opt/gvm-source/openvas-smb/
mkdir build && cd build
export PKG_CONFIG_PATH=/opt/gvm/lib/pkgconfig:/opt/heimdal/lib/pkgconfig:$PKG_CONFIG_PATH
cmake .. -DCMAKE_INSTALL_PREFIX=/opt/gvm
make
sudo make install
Build and install OpenVAS scanner
cd /opt/gvm-source/openvas
mkdir build && cd build
cmake .. -DCMAKE_INSTALL_PREFIX=/opt/gvm
make
sudo make install
Configuring OpenVAS Scanner
The host scan information is stored temporarily on Redis server. The default configuration of Redis server is /etc/redis/redis.conf.
Switch back to privileged user and proceed.
exit
To begin run the command below to create the cache to the installed shared libraries.
ldconfig
Next, copy OpenVAS scanner Redis configuration file, redis-openvas.conf, to the same Redis configuration file.
mv /etc/redis.conf{,.original}
cp /opt/gvm/gvm-source/openvas/config/redis-openvas.conf /etc/redis.conf
Update the ownership of the configuration.
chown redis: /etc/redis.conf
Update the path to Redis unix socket on the /etc/redis.conf.
sed -i 's#/run/redis-openvas/redis.sock#/tmp/redis.sock#' /etc/redis.conf
Similarly, specify the path to Redis socket file on the /etc/openvas/openvas.conf configuration file using the db_address parameter as follows.
echo "db_address = /tmp/redis.sock" > /etc/openvas/openvas.conf
chown gvm: /etc/openvas/openvas.conf
Add gvm user to redis group;
usermod -aG redis gvm
You can also optimize Redis server itself improve the performance by making the following adjustments;
Increase the value of somaxconn in order to avoid slow clients connections issues.
echo "net.core.somaxconn = 1024" >> /etc/sysctl.conf
Redis background save may fail under low memory condition. To avoid this, enable memory overcommit (man 5 proc).
echo 'vm.overcommit_memory = 1' >> /etc/sysctl.conf
Reload sysctl variables created above.
sysctl -p
To avoid creation of latencies and memory usage issues with Redis, disable Linux Kernel’s support for Transparent Huge Pages (THP). To easily work around this, create a systemd service unit for this purpose.
cat > /etc/systemd/system/disable_thp.service << 'EOL'
[Unit]
Description=Disable Kernel Support for Transparent Huge Pages (THP)
[Service]
Type=simple
ExecStart=/bin/sh -c "echo 'never' > /sys/kernel/mm/transparent_hugepage/enabled && echo 'never' > /sys/kernel/mm/transparent_hugepage/defrag"
[Install]
WantedBy=multi-user.target
EOL
Reload systemd configurations
systemctl daemon-reload
Start and enable this service to run on system boot.
systemctl enable --now disable_thp
Start and enable Redis to run on system boot;
systemctl enable --now redis
A number of Network Vulnerability Tests (NVTs) require root privileges to perform certain operations. Since openvas is launched from an ospd-openvas process, via sudo, add the line below to sudoers file to ensure that the gvm user used in this demo can run the openvas with elevated rights using passwordless sudo.
echo "gvm ALL = NOPASSWD: /opt/gvm/sbin/openvas" >> /etc/sudoers.d/gvm
Also, update the secure_path to include the GVM /sbin paths, /opt/gvm/sbin.
sed -i.bak '/secure_path/ s|$|:/opt/gvm/sbin|' /etc/sudoers
Update NVTs
Update Network Vulnerability Tests feed from Greenbone Security Feed/Community Feed using the greenbone-nvt-sync command.
The greenbone-nvt-sync command must not be executed as privileged user root, hence switch back to GVM user we created above and update the NVTs.
Ensure that user can write to OpenVAS libraries directory, /var/lib/openvas/, directory.
chown -R gvm: /var/lib/openvas/
su - gvm
Next, update the NVTs as openvas user;
greenbone-nvt-sync
Once the update is done, you need to update Redis server with the same VT info from VT files;
sudo openvas --update-vt-info
Build and Install Greenbone Vulnerability Manager
export PKG_CONFIG_PATH=/opt/gvm/lib/pkgconfig:/opt/heimdal/lib/pkgconfig:$PKG_CONFIG_PATH
cd /opt/gvm-source/gvmd
mkdir build && cd build
cmake .. -DCMAKE_INSTALL_PREFIX=/opt/gvm
make
sudo make install
Build and Install Greenbone Security Assistant
export PKG_CONFIG_PATH=/opt/gvm/lib/pkgconfig:/opt/heimdal/lib/pkgconfig:$PKG_CONFIG_PATH
cd /opt/gvm-source/gsa
mkdir build && cd build
cmake .. -DCMAKE_INSTALL_PREFIX=/opt/gvm
make
sudo make install
Exit the gvm user
exit
Enable gvm user to run GSA web application daemon, gsad, with passwordless sudo.
echo "gvm ALL = NOPASSWD: /opt/gvm/sbin/gsad" >> /etc/sudoers.d/gvm
Keeping the feeds up-to-date
The gvmd Data, SCAP and CERT Feeds should be kept up-to-date by calling the greenbone-feed-sync script regularly (e.g. via a cron entry):
chown -R gvm: /var/lib/gvm
sudo -Hiu gvm greenbone-feed-sync --type GVMD_DATA
sudo -Hiu gvm greenbone-feed-sync --type SCAP
sudo -Hiu gvm greenbone-feed-sync --type CERT
Please note: The CERT feed sync depends on data provided by the SCAP feed and should be called after syncing the later.
Consider setting cron jobs to run the nvts, cert and scap data update scripts at your preferred frequency to pull updates from the feed servers.
Next, run the command below to generate certificates gvmd. Server certificates are used for authentication while client certificates are primarily used for authorization. More on man gvm-manage-certs.
gvm-manage-certs -a
chown -R gvm: /opt/gvm/ /var/lib/gvm
cat > /etc/systemd/system/ospd-openvas.service << 'EOL'
[Unit]
Description=Description=OSPd Wrapper for the OpenVAS Scanner (ospd-openvas)
After=redis.service
After=postgresql.service
[Service]
ExecStartPre=-rm -rf /run/gvm/ospd-openvas.pid /run/gvm/ospd-openvas.sock
Type=simple
User=gvm
Group=gvm
RuntimeDirectory=gvm
Environment=PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/opt/gvm/bin:/opt/gvm/sbin
Environment=PYTHONPATH=/opt/gvm/lib/python3.7/site-packages
ExecStart=/opt/gvm/bin/ospd-openvas \
--pid-file /run/gvm/ospd-openvas.pid \
--log-file /var/log/gvm/ospd-openvas.log \
--lock-file-dir /run/gvm/ -u /run/gvm/ospd-openvas.sock
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
EOL
chown -R gvm: /run/gvm /var/log/gvm
Reload systemd service unit configurations.
systemctl daemon-reload
systemctl start ospd-openvas
Check the status of the service
systemctl status ospd-openvas
Check the logs;
tail -f /var/log/gvm/ospd-openvas.log
Enable OpenVAS scanner to run on system boot
systemctl enable ospd-openvas
Create GVMD Systemd Service files
cp /lib/systemd/system/gvmd.service{,.bak}
cat > /lib/systemd/system/gvmd.service << 'EOL'
[Unit]
Description=Greenbone Vulnerability Manager daemon (gvmd)
After=ospd-openvas.service
Wants=postgresql.service ospd-openvas.service
[Service]
Type=simple
User=gvm
Group=gvm
RuntimeDirectory=gvm
Environment=PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/opt/gvm/bin:/opt/gvm/sbin
Environment=PYTHONPATH=/opt/gvm/lib/python3.7/site-packages
ExecStart=/opt/gvm/sbin/gvmd --osp-vt-update=/run/gvm/ospd-openvas.sock --unix-socket=/run/gvm/gvmd.sock
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
EOL
Reload systemd configs and start GVMD.
systemctl daemon-reload
systemctl start gvmd
Check the status
systemctl status gvmd
Create GSA systemd service Unit file
cp /lib/systemd/system/gsad.service{,.bak}
cat > /etc/systemd/system/gsad.service << 'EOL'
[Unit]
Description=Greenbone Security Assistant daemon (gsad)
Documentation=man:gsad(8) https://www.greenbone.net
After=network.target gvmd.service
Wants=gvmd.service
[Service]
Type=forking
User=gvm
Group=gvm
#PIDFile=/run/gvm/gsad.pid
Environment=PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/opt/gvm/bin:/opt/gvm/sbin:/opt/gvm/.local/bin
Environment=PYTHONPATH=/opt/gvm/lib/python3.7/site-packages
ExecStart=/usr/bin/sudo /opt/gvm/sbin/gsad --munix-socket=/run/gvm/gvmd.sock -k /var/lib/gvm/private/CA/clientkey.pem -c /var/lib/gvm/CA/clientcert.pem
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
Alias=greenbone-security-assistant.service
EOL
Reload system unit configs and start the services
systemctl daemon-reload
systemctl enable --now gsad
Checking the status
systemctl status gsad
Create GVM Scanner
Since we launched the scanner and set it to use our non-standard scanner host path (/run/gvm/ospd-openvas.sock), we need to create and register our scanner;
sudo -Hiu gvm gvmd --create-scanner="ViduTech OpenVAS Scanner" --scanner-type="OpenVAS" --scanner-host=/run/gvm/ospd-openvas.sock
Next, you need to verify your scanner. For this, you first need to get the scanner identifier;
sudo -Hiu gvm gvmd --get-scanners
Based on the output above, our scanner UUID is, 09f20626-f515-40d2-bb32-e70cc04b9e45.
Verify the scanner
sudo -Hiu gvm gvmd --verify-scanner=09f20626-f515-40d2-bb32-e70cc04b9e45
Command output
Create OpenVAS (GVM) Admin User
Create OpenVAS administrative user by running the command below;
sudo -Hiu gvm gvmd --create-user admin --password=password@123
An administrator user can later create further users or administrators via clients like the Greenbone Security Assistant (GSA).
Set the Feed Import Owner
According to gvmd/INSTALL.md, certain resources that were previously part of the gvmd source code are now shipped via the feed. An example is the config “Full and Fast”.
gvmd will only create these resources if a “Feed Import Owner” is configured:
sudo -Hiu gvm gvmd --modify-setting 78eceaec-3385-11ea-b237-28d24461215b --value <uuid_of_user>
The UUIDs of all created users can be found using
sudo -Hiu gvm gvmd --get-users --verbose
Then Modify the gvmd settings with the user UUID.
sudo -Hiu gvm gvmd --modify-setting 78eceaec-3385-11ea-b237-28d24461215b --value dcb71e02-44ef-47a8-8b74-3e277c0017a7
GVM Log Files
Various Log files are located under the /opt/gvm/var/log/gvm directory.
ls /opt/gvm/var/log/gvm
gsad.log
ls -1 /var/log/gvm/
gvmd.log
openvas.log
ospd-openvas.log
Accessing GVM 21.04 (OpenVAS)
Greenbone Security Assistant (GSA) WebUI daemon opens port 443 and listens on all interfaces. If firewall is running, open this port to allow external access.
firewall-cmd --add-port=443/tcp --permanent
firewall-cmd --reload
You can now access GSA via the url https:<serverIP-OR-hostname>. Accept the self-signed SSL warning and proceed.