Install Yarn on Rocky Linux 8<\/a><\/p>\n\n\n\nInstall PostgreSQL on Rocky Linux 8<\/h4>\n\n\n\n
GVM 21.04 uses PostgreSQL as the backend database. Hence, run the command below to install PostgreSQL on Rocky Linux 8.<\/p>\n\n\n\n
sudo dnf -y install -y postgresql-server postgresql-contrib postgresql-server-devel<\/code><\/pre>\n\n\n\nOnce the installation is done, Initialize:<\/p>\n\n\n\n
\/usr\/bin\/postgresql-setup --initdb<\/code><\/pre>\n\n\n\nNext, start it and enable it to run on system boot;<\/p>\n\n\n\n
systemctl enable --now postgresql<\/code><\/pre>\n\n\n\nCreate PostgreSQL User and Database<\/h4>\n\n\n\n
Once the installation is done, create the PostgreSQL user and database for Greenbone Vulnerability Management Daemon (gvmd).<\/p>\n\n\n\n
Note that the database and user should be created as PostgreSQL user, postgres<\/strong>.<\/p>\n\n\n\nsudo -Hiu postgres\ncreateuser gvm\ncreatedb -O gvm gvmd<\/code><\/pre>\n\n\n\nGrant PostgreSQL User DBA Roles<\/p>\n\n\n\n
psql gvmd\ncreate role dba with superuser noinherit;\ngrant dba to gvm;\n\\q\nexit<\/code><\/pre>\n\n\n\nOnce that is done, restart PostgreSQL;<\/p>\n\n\n\n
systemctl restart postgresql<\/code><\/pre>\n\n\n\nCreate a symbolic link;<\/p>\n\n\n\n
ln -s \/usr\/include \/usr\/include\/postgresql<\/code><\/pre>\n\n\n\nBuilding GVM 21.04 from Source<\/h3>\n\n\n\n
There are different tools required to install and setup GVM 21.04 on Rocky Linux 8. These include;<\/p>\n\n\n\n
\n- GVM Libraries<\/li>\n\n\n\n
- OpenVAS Scanner<\/li>\n\n\n\n
- OSPd<\/li>\n\n\n\n
- ospd-openvas<\/li>\n\n\n\n
- Greenbone Vulnerability Manager<\/li>\n\n\n\n
- Greenbone Security Assistant<\/li>\n\n\n\n
- Python-GVM<\/li>\n\n\n\n
- GVM-Tools<\/li>\n\n\n\n
- OpenVAS SMB<\/li>\n<\/ul>\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\nSince we are running GVM as non-privileged user, gvm, then we will install all the GVM configuration files and libraries under, \/opt\/gvm<\/strong><\/code>.<\/p>\n\n\n\nUpdate the PATH environment variable on \/etc\/environment<\/strong><\/code>, to include the GVM binary path such that it looks like;<\/p>\n\n\n\necho \"PATH=$PATH:\/opt\/gvm\/bin:\/opt\/gvm\/sbin:\/opt\/gvm\/.local\/bin\" >> \/etc\/environment<\/code><\/pre>\n\n\n\nsource \/etc\/environment<\/code><\/pre>\n\n\n\nAdd GVM library path to \/etc\/ld.so.conf.d<\/strong><\/code>.<\/p>\n\n\n\necho \"\/opt\/gvm\/lib\" > \/etc\/ld.so.conf.d\/gvm.conf<\/code><\/pre>\n\n\n\nInstall and Setup GVM 21.04 on Rocky Linux 8<\/h4>\n\n\n\n
Switch to GVM user, gvm and create a temporary directory to store GVM source files.<\/p>\n\n\n\n
su - gvm<\/code><\/pre>\n\n\n\nmkdir gvm-source<\/code><\/pre>\n\n\n\nDownload GVM 21.04 Source Files<\/h4>\n\n\n\n
Navigate to temporary directory created above and run the subsequent commands to clone the GVM github branch files.<\/p>\n\n\n\n
cd gvm-source<\/code><\/pre>\n\n\n\ngit clone -b stable --single-branch https:\/\/github.com\/greenbone\/gvm-libs.git<\/code><\/pre>\n\n\n\ngit clone -b main --single-branch https:\/\/github.com\/greenbone\/openvas-smb.git<\/code><\/pre>\n\n\n\ngit clone -b stable --single-branch https:\/\/github.com\/greenbone\/openvas.git<\/code><\/pre>\n\n\n\ngit clone -b stable --single-branch https:\/\/github.com\/greenbone\/ospd.git<\/code><\/pre>\n\n\n\ngit clone -b stable --single-branch https:\/\/github.com\/greenbone\/ospd-openvas.git<\/code><\/pre>\n\n\n\ngit clone -b stable --single-branch https:\/\/github.com\/greenbone\/gvmd.git<\/code><\/pre>\n\n\n\ngit clone -b stable --single-branch https:\/\/github.com\/greenbone\/gsa.git<\/code><\/pre>\n\n\n\nOnce the source files are in place, proceed to build and install GVM on Rocky Linux<\/p>\n\n\n\n
Note the current working directory;<\/p>\n\n\n\n
pwd<\/code><\/pre>\n\n\n\n\/opt\/gvm\/gvm-source<\/code><\/pre>\n\n\n\nls -1<\/code><\/pre>\n\n\n\ngsa\ngvmd\ngvm-libs\nopenvas\nopenvas-smb\nospd\nospd-openvas<\/code><\/pre>\n\n\n\nNote that we will install all GVM 21.04 files and libraries to a non-standard location, \/opt\/gvm<\/code>.<\/p>\n\n\n\nAs such, you need to set the PKG_CONFIG_PATH<\/code> environment variable to the location of your pkg-config files before running the installation.<\/p>\n\n\n\nPay attention to the export command<\/strong>.<\/p>\n\n\n\nBe sure to replace the path, \/opt\/gvm<\/strong><\/code>, accordingly.<\/p>\n\n\n\nBuild and Install GVM 11 Libraries<\/h4>\n\n\n\n
From within the source directory, \/opt\/gvm\/gvm-source<\/code><\/strong>, in this setup, change to GVM libraries directory;<\/p>\n\n\n\ncd gvm-libs\nmkdir build && cd build\nexport PKG_CONFIG_PATH=\/opt\/gvm\/lib\/pkgconfig:$PKG_CONFIG_PATH\ncmake .. -DCMAKE_INSTALL_PREFIX=\/opt\/gvm\nmake\nsudo make install<\/code><\/pre>\n\n\n\nBuild and Install OpenVAS scanner and OpenVAS SMB<\/h4>\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 winexe<\/code> binary to execute processes remotely on that system.<\/p>\n\n\n\nBuild and install openvas-smb;<\/p>\n\n\n\n
cd ..\/..\/openvas-smb\/\nmkdir build && cd build\nexport PKG_CONFIG_PATH=\/opt\/gvm\/lib\/pkgconfig:\/opt\/heimdal\/lib\/pkgconfig:$PKG_CONFIG_PATH\ncmake .. -DCMAKE_INSTALL_PREFIX=\/opt\/gvm\nmake\nsudo make install<\/code><\/pre>\n\n\n\nBuild and install OpenVAS scanner;<\/p>\n\n\n\n
cd ..\/..\/openvas\nmkdir build && cd build\ncmake .. -DCMAKE_INSTALL_PREFIX=\/opt\/gvm\nmake\nmake install<\/code><\/pre>\n\n\n\nThe host scan information is stored temporarily on Redis server. The default configuration of Redis server is \/etc\/redis\/redis.conf<\/code>.<\/p>\n\n\n\nSwitch back to privileged user and proceed.<\/p>\n\n\n\n
exit<\/code><\/pre>\n\n\n\nTo begin run the command below to create the cache to the installed shared libraries;<\/p>\n\n\n\n
ldconfig<\/code><\/pre>\n\n\n\nNext, copy OpenVAS scanner Redis configuration file, redis-openvas.conf<\/code>, to the same Redis configuration file;<\/p>\n\n\n\nmv \/etc\/redis.conf{,.original}<\/code><\/pre>\n\n\n\ncp \/opt\/gvm\/gvm-source\/openvas\/config\/redis-openvas.conf \/etc\/redis.conf<\/code><\/pre>\n\n\n\nUpdate the ownership of the configuration.<\/p>\n\n\n\n
chown redis: \/etc\/redis.conf<\/code><\/pre>\n\n\n\nUpdate the path to Redis unix socket on the \/etc\/redis.conf:<\/p>\n\n\n\n
sed -i 's#\/run\/redis-openvas\/redis.sock#\/tmp\/redis.sock#' \/etc\/redis.conf<\/code><\/pre>\n\n\n\nSimilarly, specify the path to Redis socket file on the \/etc\/openvas\/openvas.conf<\/strong><\/code> configuration file using the db_address<\/code><\/strong> parameter as follows.<\/p>\n\n\n\necho \"db_address = \/tmp\/redis.sock<\/strong>\" > \/etc\/openvas\/openvas.conf<\/code><\/pre>\n\n\n\nchown gvm: \/etc\/openvas\/openvas.conf<\/code><\/pre>\n\n\n\nAdd gvm user to redis group;<\/p>\n\n\n\n
usermod -aG redis gvm<\/code><\/pre>\n\n\n\nYou 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
echo \"net.core.somaxconn = 1024\" >> \/etc\/sysctl.conf<\/code><\/pre>\n\n\n\nRedis background save may fail under low memory condition. To avoid this, enable memory overcommit (man 5 proc)<\/strong>.<\/p>\n\n\n\necho 'vm.overcommit_memory = 1' >> \/etc\/sysctl.conf<\/code><\/pre>\n\n\n\nReload sysctl variables created above.<\/p>\n\n\n\n
sysctl -p<\/code><\/pre>\n\n\n\nTo 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
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\nReload systemd configurations;<\/p>\n\n\n\n
systemctl daemon-reload<\/code><\/pre>\n\n\n\nStart and enable this service to run on system boot.<\/p>\n\n\n\n
systemctl enable --now disable_thp<\/code><\/pre>\n\n\n\nStart and enable Redis to run on system boot;<\/p>\n\n\n\n
systemctl enable --now redis<\/code><\/pre>\n\n\n\nA number of Network Vulnerability Tests (NVTs) require root privileges to perform certain operations. Since 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\necho \"gvm ALL = NOPASSWD: \/opt\/gvm\/sbin\/openvas\" > \/etc\/sudoers.d\/gvm<\/code><\/pre>\n\n\n\nAlso, update the secure_path<\/strong><\/code> to include the GVM \/sbin<\/code> paths, \/opt\/gvm\/sbin<\/strong><\/code>.<\/p>\n\n\n\nsed -i.bak '\/secure_path\/ s|$|:\/opt\/gvm\/sbin|' \/etc\/sudoers<\/code><\/pre>\n\n\n\nUpdate NVTs<\/h4>\n\n\n\n
Update Network Vulnerability Tests feed from Greenbone Security Feed\/Community Feed using the greenbone-nvt-sync<\/code> command.<\/p>\n\n\n\nThe 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\nEnsure that user can write to OpenVAS libraries directory, \/var\/lib\/openvas\/<\/strong><\/code>, directory.<\/p>\n\n\n\nchown -R gvm: \/var\/lib\/openvas\/<\/code><\/pre>\n\n\n\nsu - gvm<\/code><\/pre>\n\n\n\nNext, update the NVTs as openvas user;<\/p>\n\n\n\n
greenbone-nvt-sync<\/code><\/pre>\n\n\n\nOnce the update is done, you need to update Redis server with the same VT info from VT files;<\/p>\n\n\n\n
sudo openvas --update-vt-info<\/code><\/pre>\n\n\n\nBuild and Install Greenbone Vulnerability Manager<\/h4>\n\n\n\nexport PKG_CONFIG_PATH=\/opt\/gvm\/lib\/pkgconfig:\/opt\/heimdal\/lib\/pkgconfig:$PKG_CONFIG_PATH\ncd gvm-source\/gvmd\nmkdir build && cd build\ncmake .. -DCMAKE_INSTALL_PREFIX=\/opt\/gvm\nmake\nsudo make install<\/code><\/pre>\n\n\n\nBuild and Install Greenbone Security Assistant<\/h4>\n\n\n\nexport PKG_CONFIG_PATH=\/opt\/gvm\/lib\/pkgconfig:\/opt\/heimdal\/lib\/pkgconfig:$PKG_CONFIG_PATH\ncd ..\/..\/gsa\nmkdir build && cd build\ncmake .. -DCMAKE_INSTALL_PREFIX=\/opt\/gvm\nmake\nsudo make install<\/code><\/pre>\n\n\n\nExit the gvm user;<\/p>\n\n\n\n
exit<\/code><\/pre>\n\n\n\nEnable gvm<\/code> user to run GSA web application daemon, gsad<\/code>, with passwordless sudo.<\/p>\n\n\n\necho \"gvm ALL = NOPASSWD: \/opt\/gvm\/sbin\/gsad\" >> \/etc\/sudoers.d\/gvm<\/code><\/pre>\n\n\n\nKeeping the feeds up-to-date<\/h4>\n\n\n\n
The gvmd Data<\/strong><\/code>, SCAP<\/code><\/strong> and CERT<\/strong><\/code> Feeds should be kept up-to-date by calling the greenbone-feed-sync<\/code> script regularly (e.g. via a cron entry):<\/p>\n\n\n\nchown -R gvm: \/var\/lib\/gvm<\/code><\/pre>\n\n\n\nsudo -Hiu gvm greenbone-feed-sync --type GVMD_DATA<\/code><\/pre>\n\n\n\nsudo -Hiu gvm greenbone-feed-sync --type SCAP<\/code><\/pre>\n\n\n\nsudo -Hiu gvm greenbone-feed-sync --type CERT<\/code><\/pre>\n\n\n\nPlease note: The CERT<\/code> feed sync depends on data provided by the SCAP<\/code> feed and should be called after syncing the later.<\/strong><\/p>\n\n\n\nConsider setting cron jobs to run the nvts, cert and scap data update scripts at your preferred frequency to pull updates from the feed servers.<\/p>\n\n\n\n
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<\/strong><\/code>.<\/p>\n\n\n\ngvm-manage-certs -a<\/code><\/pre>\n\n\n\n