{"id":11734,"date":"2022-07-08T08:44:33","date_gmt":"2022-07-08T05:44:33","guid":{"rendered":"https:\/\/kifarunix.com\/?p=11734"},"modified":"2024-03-09T20:32:50","modified_gmt":"2024-03-09T17:32:50","slug":"install-gvm-21-04-on-ubuntu","status":"publish","type":"post","link":"https:\/\/kifarunix.com\/install-gvm-21-04-on-ubuntu\/","title":{"rendered":"Install GVM 21.4 on Ubuntu 20.04"},"content":{"rendered":"\n
In this guide, you will learn how to install GVM 21.4 on Ubuntu 20.04. G<\/strong>reenbone V<\/strong>ulnerability M<\/strong>anagement (GVM)<\/a>, previously known as OpenVAS, is a network security scanner which provides a set of network vulnerability tests (NVTs) to detect security loopholes in systems and applications. As of this writing, GVM 21.4 is the current stable release<\/a> and <\/em>is the latest release.<\/p>\n\n\n\n In this demo, we will install and setup GVM 21.4 on Ubuntu 20.04 from source code. As such, below are the system requirements I would personally recommend.<\/p>\n\n\n\n These requirements will vary depending on your use cases, however. Just be sure to provide “enough”.<\/p>\n\n\n\n To begin with, update your system package cache and upgrade your system packages;<\/p>\n\n\n\n In this demo, we will run GVM 21.4 as a non privileged system user. Thus, create In order to successfully build GVM 21.4 on Ubuntu 20.04, you need to install a number of required dependencies and build tools.<\/p>\n\n\n\n Next, install Yarn JavaScript package manager<\/p>\n\n\n\n GVM 21.4 uses PostgreSQL as the backend database.<\/p>\n\n\n\n Therefore, run the command below to install PostgreSQL on Ubuntu 20.04;<\/p>\n\n\n\n Start and enable PostgreSQL to run on system boot;<\/p>\n\n\n\n Once the installation is done, create the PostgreSQL user and database for Greenbone Vulnerability Management Daemon (gvmd). Note that the database and user should be created as PostgreSQL user, postgres<\/strong>.<\/p>\n\n\n\n Grant PostgreSQL GVM User DBA Roles<\/p>\n\n\n\n Once that is done, restart PostgreSQL;<\/p>\n\n\n\n There are different tools required to install and setup GVM 21.4 on Ubuntu 20.04. These include;<\/p>\n\n\n\n Every component has README.md<\/strong> and a INSTALL.md<\/strong> file that explains how to build and install it.<\/p>\n\n\n\n Since we are running GVM as non-privileged user, gvm, then we will install all the GVM configuration files and libraries under, Update the PATH environment variable on Add GVM library path to Before you can proceed, enable gvm user to run installation command with sudo rights;<\/p>\n\n\n\n Switch to GVM user, gvm and create a temporary directory to store GVM source files.<\/p>\n\n\n\n Clone the GVM github branch files into directory created above.<\/p>\n\n\n\n The source files are in now place;<\/p>\n\n\n\n Note that we will install all GVM 21.4 files and libraries to a non-standard location, Switch to GVM user;<\/p>\n\n\n\n As such, you need to set the Be sure to replace the path, From within the source directory, Create a build directory and change into it;<\/p>\n\n\n\n Configure the build;<\/p>\n\n\n\n Next, compile and install GVM libraries<\/p>\n\n\n\n Open Vulnerability Assessment Scanner (OpenVAS) is a full-featured scan engine that executes a continuously updated and extended feed of Network Vulnerability Tests (NVTs).<\/p>\n\n\n\n OpenVAS SMB provides modules for the OpenVAS Scanner to interface with Microsoft Windows Systems through the Windows Management Instrumentation API and a Build and install openvas-smb;<\/p>\n\n\n\n Build and install OpenVAS scanner;<\/p>\n\n\n\n If you get the error below while running the make command;<\/p>\n\n\n\n The exit as gvm user and run the command below as privileged user;<\/p>\n\n\n\n Then rerun the compilation and installation command.<\/p>\n\n\n\n The host scan information is stored temporarily on Redis server. The default configuration of Redis server is Switch back to privileged user and proceed.<\/p>\n\n\n\n To begin run the command below to create the cache to the installed shared libraries;<\/p>\n\n\n\n Next, copy OpenVAS scanner Redis configuration file, Update the ownership of the configuration.<\/p>\n\n\n\n Update the path to Redis unix socket on the Note, the Unix socket path is defined on Add gvm user to redis group;<\/p>\n\n\n\n You can also optimize Redis server itself improve the performance by making the following adjustments;<\/p>\n\n\n\n Increase the value of somaxconn in order to avoid slow clients connections issues.<\/p>\n\n\n\n Redis background save may fail under low memory condition. To avoid this, enable memory overcommit (man 5 proc)<\/strong>.<\/p>\n\n\n\n Reload sysctl variables created above.<\/p>\n\n\n\n To avoid creation of latencies and memory usage issues with Redis, disable Linux Kernel\u2019s support for Transparent Huge Pages (THP). To easily work around this, create a systemd service unit for this purpose.<\/p>\n\n\n\n Reload systemd configurations;<\/p>\n\n\n\n Start and enable this service to run on system boot.<\/p>\n\n\n\n Restart OpenVAS Redis server<\/p>\n\n\n\n A number of Network Vulnerability Tests (NVTs) require root privileges to perform certain operations. Since Also, enable Also, update the Update Network Vulnerability Tests feed from Greenbone Security Feed\/Community Feed using the The Ensure the GVM user can write to Next, update the NVTs as openvas user;<\/p>\n\n\n\n Once the update is done, you need to update Redis server with the same VT info from VT files;<\/p>\n\n\n\n The Greenbone Vulnerability Manager is the central management service between security scanners and the user clients.<\/p>\n\n\n\n To build and install GVM;<\/p>\n\n\n\n Similarly, if you get the error;<\/p>\n\n\n\n Exit as GVM user and run the command below as privileged user;<\/p>\n\n\n\n Switch back to GVM user and rerun the installation.<\/p>\n\n\n\n The Greenbone Security Assistant is the web interface developed for the Greenbone Security Manager<\/p>\n\n\n\nInstall GVM 21.4 on Ubuntu 20.04<\/h2>\n\n\n\n
Prerequisites<\/h3>\n\n\n\n
\n
Run System Update<\/h3>\n\n\n\n
apt update<\/code><\/pre>\n\n\n\n
Create GVM User on Ubuntu<\/h3>\n\n\n\n
gvm<\/strong><\/code> system user account.<\/p>\n\n\n\n
useradd -r -m -d \/opt\/gvm -c \"GVM User\" -s \/bin\/bash gvm<\/code><\/pre>\n\n\n\n
Install Required Build Tools<\/h3>\n\n\n\n
apt install gcc g++ make bison flex libksba-dev curl redis libpcap-dev \\\ncmake git pkg-config libglib2.0-dev libgpgme-dev nmap libgnutls28-dev uuid-dev \\\nlibssh-gcrypt-dev libldap2-dev gnutls-bin libmicrohttpd-dev libhiredis-dev \\\nzlib1g-dev libxml2-dev libradcli-dev clang-format libldap2-dev doxygen libnet1-dev \\\ngcc-mingw-w64 xml-twig-tools libical-dev perl-base heimdal-dev libpopt-dev \\\nlibsnmp-dev python3-setuptools python3-paramiko python3-lxml python3-defusedxml \\\npython3-dev gettext python3-polib xmltoman python3-pip texlive-fonts-recommended \\\ntexlive-latex-extra --no-install-recommends xsltproc libunistring-dev vim -y\n<\/code><\/pre>\n\n\n\n
Install Yarn on Ubuntu 20.04<\/h4>\n\n\n\n
curl -sS https:\/\/dl.yarnpkg.com\/debian\/pubkey.gpg | gpg --dearmor > \/etc\/apt\/trusted.gpg.d\/yarn.gpg<\/code><\/pre>\n\n\n\n
echo \"deb https:\/\/dl.yarnpkg.com\/debian\/ stable main\" > \/etc\/apt\/sources.list.d\/yarn.list<\/code><\/pre>\n\n\n\n
apt update<\/code><\/pre>\n\n\n\n
apt install yarn -y<\/code><\/pre>\n\n\n\n
Install PostgreSQL on Ubuntu 20.04<\/h4>\n\n\n\n
apt install postgresql postgresql-contrib postgresql-server-dev-all<\/code><\/pre>\n\n\n\n
systemctl enable --now postgresql<\/code><\/pre>\n\n\n\n
Create PostgreSQL User and Database<\/h4>\n\n\n\n
sudo -Hiu postgres createuser gvm<\/code><\/pre>\n\n\n\n
sudo -Hiu postgres createdb -O gvm gvmd<\/code><\/pre>\n\n\n\n
sudo -Hiu postgres psql gvmd -c 'create role dba with superuser noinherit;'<\/code><\/pre>\n\n\n\n
sudo -Hiu postgres psql gvmd -c 'grant dba to gvm;'<\/code><\/pre>\n\n\n\n
sudo -Hiu postgres psql gvmd -c 'create extension \"uuid-ossp\";'<\/code><\/pre>\n\n\n\n
sudo -Hiu postgres psql gvmd -c 'create extension \"pgcrypto\";'<\/code><\/pre>\n\n\n\n
systemctl restart postgresql<\/code><\/pre>\n\n\n\n
Building GVM 21.4 from Source Code<\/h3>\n\n\n\n
\n
\/opt\/gvm<\/strong><\/code> (
\/opt\/gvm\/bin:\/opt\/gvm\/sbin:\/opt\/gvm\/.local\/bin<\/code><\/em><\/strong>).<\/p>\n\n\n\n
\/etc\/environment<\/strong><\/code>, to include the GVM binary path such that it looks like;<\/p>\n\n\n\n
sed -i.bak '\/^PATH\/s|\"$|:\/opt\/gvm\/bin:\/opt\/gvm\/sbin:\/opt\/gvm\/.local\/bin\"|' \/etc\/environment<\/code><\/pre>\n\n\n\n
source \/etc\/environment<\/code><\/pre>\n\n\n\n
\/etc\/ld.so.conf.d<\/strong><\/code>. <\/p>\n\n\n\n
echo \"\/opt\/gvm\/lib\" > \/etc\/ld.so.conf.d\/gvm.conf<\/code><\/pre>\n\n\n\n
Build and Install GVM on Ubuntu 20.04<\/h4>\n\n\n\n
echo \"gvm ALL = NOPASSWD: \/usr\/bin\/make install\" >> \/etc\/sudoers.d\/gvm<\/code><\/pre>\n\n\n\n
sudo -Hiu gvm mkdir gvm-source<\/code><\/pre>\n\n\n\n
Download GVM 21.4 Source Files<\/h4>\n\n\n\n
sudo -Hiu gvm git clone -b stable --single-branch https:\/\/github.com\/greenbone\/gvm-libs.git gvm-source\/gvm-libs<\/code><\/pre>\n\n\n\n
sudo -Hiu gvm git clone -b main --single-branch https:\/\/github.com\/greenbone\/openvas-smb.git gvm-source\/openvas-smb<\/code><\/pre>\n\n\n\n
sudo -Hiu gvm git clone -b stable --single-branch https:\/\/github.com\/greenbone\/openvas.git gvm-source\/openvas<\/code><\/pre>\n\n\n\n
sudo -Hiu gvm git clone -b stable --single-branch https:\/\/github.com\/greenbone\/ospd.git gvm-source\/ospd<\/code><\/pre>\n\n\n\n
sudo -Hiu gvm git clone -b stable --single-branch https:\/\/github.com\/greenbone\/ospd-openvas.git gvm-source\/ospd-openvas<\/code><\/pre>\n\n\n\n
sudo -Hiu gvm git clone -b stable --single-branch https:\/\/github.com\/greenbone\/gvmd.git gvm-source\/gvmd<\/code><\/pre>\n\n\n\n
sudo -Hiu gvm git clone -b stable --single-branch https:\/\/github.com\/greenbone\/gsa.git gvm-source\/gsa<\/code><\/pre>\n\n\n\n
sudo -Hiu gvm git clone -b stable --single-branch https:\/\/github.com\/greenbone\/gsad.git gvm-source\/gsad<\/code><\/pre>\n\n\n\n
ls -1 \/opt\/gvm\/gvm-source<\/code><\/pre>\n\n\n\n
ls -1<\/code><\/pre>\n\n\n\n
gsa\ngsad\ngvm-libs\ngvmd\nopenvas\nopenvas-smb\nospd\nospd-openvas\n<\/code><\/pre>\n\n\n\n
\/opt\/gvm<\/code>.<\/p>\n\n\n\n
su - gvm<\/code><\/pre>\n\n\n\n
PKG_CONFIG_PATH<\/code> environment variable to the location of your pkg-config files before configuring:<\/p>\n\n\n\n
echo \"export PKG_CONFIG_PATH=\/opt\/gvm\/lib\/pkgconfig:$PKG_CONFIG_PATH\" >> ~\/.bashrc<\/code><\/pre>\n\n\n\n
source ~\/.bashrc<\/code><\/pre>\n\n\n\n
\/opt\/gvm<\/strong><\/code>, accordingly.<\/p>\n\n\n\n
Build and Install GVM Libraries<\/h4>\n\n\n\n
\/opt\/gvm\/gvm-source<\/code><\/strong>, in this setup, change to GVM libraries directory;<\/p>\n\n\n\n
cd ~\/gvm-source\/gvm-libs<\/code><\/pre>\n\n\n\n
mkdir build && cd build<\/code><\/pre>\n\n\n\n
cmake .. -DCMAKE_INSTALL_PREFIX=\/opt\/gvm<\/code><\/pre>\n\n\n\n
make && sudo make install<\/code><\/pre>\n\n\n\n
Build and Install OpenVAS scanner and OpenVAS SMB<\/h4>\n\n\n\n
winexe<\/code> binary to execute processes remotely on that system.<\/p>\n\n\n\n
cd ..\/..\/openvas-smb\/\nmkdir build && cd build\ncmake .. -DCMAKE_INSTALL_PREFIX=\/opt\/gvm\nmake && sudo make install<\/code><\/pre>\n\n\n\n
cd ..\/..\/openvas\nsed -i.bak 's\/-Werror\/-Wno-error\/' misc\/CMakeLists.txt\nmkdir build && cd build\ncmake .. -DCMAKE_INSTALL_PREFIX=\/opt\/gvm\nmake\nsudo make install<\/code><\/pre>\n\n\n\n
CMake Error at \/opt\/gvm\/gvm-source\/openvas\/cmake\/GetGit.cmake:33 (string):\n string sub-command REPLACE requires at least four arguments.\nCall Stack (most recent call first):\n \/opt\/gvm\/gvm-source\/openvas\/cmake\/GetGit.cmake:39 (Git_GET_REVISION)<\/code><\/pre>\n\n\n\n
sudo git config --global --add safe.directory \/opt\/gvm\/gvm-source\/openvas<\/code><\/pre>\n\n\n\n
Configuring OpenVAS Scanner<\/h4>\n\n\n\n
\/etc\/redis\/redis.conf<\/code>.<\/p>\n\n\n\n
exit<\/code><\/pre>\n\n\n\n
ldconfig<\/code><\/pre>\n\n\n\n
redis-openvas.conf<\/code>, to the same Redis config directory;<\/p>\n\n\n\n
cp \/opt\/gvm\/gvm-source\/openvas\/config\/redis-openvas.conf \/etc\/redis\/<\/code><\/pre>\n\n\n\n
chown redis:redis \/etc\/redis\/redis-openvas.conf<\/code><\/pre>\n\n\n\n
\/etc\/openvas\/openvas.conf<\/strong><\/code> using the
db_address<\/code><\/strong> parameter as follows;<\/p>\n\n\n\n
echo \"db_address = \/run\/redis-openvas\/redis.sock<\/strong><\/strong>\" > \/etc\/openvas\/openvas.conf<\/code><\/pre>\n\n\n\n
\/etc\/redis\/redis-openvas.conf<\/code> file.<\/p>\n\n\n\n
chown gvm:gvm \/etc\/openvas\/openvas.conf<\/code><\/pre>\n\n\n\n
usermod -aG redis gvm<\/code><\/pre>\n\n\n\n
echo \"net.core.somaxconn = 1024\" >> \/etc\/sysctl.conf<\/code><\/pre>\n\n\n\n
echo 'vm.overcommit_memory = 1' >> \/etc\/sysctl.conf<\/code><\/pre>\n\n\n\n
sysctl -p<\/code><\/pre>\n\n\n\n
cat > \/etc\/systemd\/system\/disable_thp.service << 'EOL'\n[Unit]\nDescription=Disable Kernel Support for Transparent Huge Pages (THP)\n\n[Service]\nType=simple\nExecStart=\/bin\/sh -c \"echo 'never' > \/sys\/kernel\/mm\/transparent_hugepage\/enabled && echo 'never' > \/sys\/kernel\/mm\/transparent_hugepage\/defrag\"\n\n[Install]\nWantedBy=multi-user.target\nEOL\n<\/code><\/pre>\n\n\n\n
systemctl daemon-reload<\/code><\/pre>\n\n\n\n
systemctl enable --now disable_thp<\/code><\/pre>\n\n\n\n
systemctl enable --now redis-server@openvas<\/code><\/pre>\n\n\n\n
openvas<\/code> is launched from an
ospd-openvas<\/code> process, via sudo, add the line below to sudoers file to ensure that the
gvm<\/code> user used in this demo can run the openvas with elevated rights using passwordless sudo.<\/p>\n\n\n\n
echo \"gvm ALL = NOPASSWD: \/opt\/gvm\/sbin\/openvas\" >> \/etc\/sudoers.d\/gvm<\/code><\/pre>\n\n\n\n
gvm<\/code> user to run GSA web application daemon,
gsad<\/code>, with passwordless sudo.<\/p>\n\n\n\n
secure_path<\/strong><\/code> to include the GVM
\/sbin<\/code> paths,
\/opt\/gvm\/sbin<\/strong><\/code>.<\/p>\n\n\n\n
sed -i '\/secure_path=\"\/s|\"$|:\/opt\/gvm\/sbin\"|' \/etc\/sudoers<\/code><\/pre>\n\n\n\n
Update NVTs<\/h4>\n\n\n\n
greenbone-nvt-sync<\/code> command.<\/p>\n\n\n\n
greenbone-nvt-sync<\/code> command must not<\/strong> be executed as privileged user root, hence switch back to GVM user we created above and update the NVTs.<\/p>\n\n\n\n
\/var\/lib\/openvas\/<\/code>.<\/p>\n\n\n\n
chown -R gvm: \/var\/lib\/openvas\/<\/code><\/pre>\n\n\n\n
sudo -Hiu gvm greenbone-nvt-sync<\/code><\/pre>\n\n\n\n
sudo openvas --update-vt-info<\/code><\/pre>\n\n\n\n
Build and Install Greenbone Vulnerability Manager<\/h4>\n\n\n\n
su - gvm<\/code><\/pre>\n\n\n\n
cd gvm-source\/gvmd\nexport PKG_CONFIG_PATH=\/opt\/gvm\/lib\/pkgconfig:$PKG_CONFIG_PATH\nsed -i.bak 's\/-Werror\/-Wno-error\/' CMakeLists.txt\nmkdir build && cd build\ncmake .. -DCMAKE_INSTALL_PREFIX=\/opt\/gvm\nmake\nsudo make install<\/code><\/pre>\n\n\n\n
-- Found Git: \/usr\/bin\/git (found version \"2.25.1\") \nfatal: unsafe repository ('\/opt\/gvm\/gvm-source\/gvmd' is owned by someone else)\nTo add an exception for this directory, call:<\/code><\/pre>\n\n\n\n
sudo git config --global --add safe.directory \/opt\/gvm\/gvm-source\/gvmd<\/code><\/pre>\n\n\n\n
Build and Install Greenbone Security Assistant<\/h4>\n\n\n\n
cd ..\/..\/gsa\nrm -rf build\nyarn\nyarn build<\/code><\/pre>\n\n\n\n