More than 8 GB disk space (We used 16 GB in this demo)<\/li>\n<\/ul>\n\n\n\nThese requirements will vary depending on your use cases, however. Just be sure to provide \u201cenough\u201d.<\/p>\n\n\n\n
Run System Update<\/h3>\n\n\n\n
To begin with, update and upgrade your system packages;<\/p>\n\n\n\n
apt update<\/code><\/pre>\n\n\n\napt upgrade<\/code><\/pre>\n\n\n\nCreate GVM User on Ubuntu<\/h3>\n\n\n\n
In this demo, we will run GVM 21.08 as a non privileged system user. Thus, create gvm<\/strong><\/code> system user account.<\/p>\n\n\n\nuseradd -r -d \/opt\/gvm -c \"GVM User\" -s \/bin\/bash gvm<\/code><\/pre>\n\n\n\nCreate the GVM user directory as specified by option -d<\/code> in the command above and set the user and group ownership to gvm<\/code>.<\/p>\n\n\n\nmkdir \/opt\/gvm && chown gvm: \/opt\/gvm<\/code><\/pre>\n\n\n\nIn order to successfully build GVM 21.04 on Debian 11\/Debian 10, you need to install a number of required dependencies and build tools.<\/p>\n\n\n\n
apt install gcc g++ make bison flex libksba-dev \\\ncurl redis libpcap-dev cmake git pkg-config libglib2.0-dev libgpgme-dev \\\nnmap libgnutls28-dev uuid-dev libssh-gcrypt-dev libldap2-dev gnutls-bin \\\nlibmicrohttpd-dev libhiredis-dev zlib1g-dev libxml2-dev libnet-dev libradcli-dev \\\nclang-format libldap2-dev doxygen gcc-mingw-w64 xml-twig-tools libical-dev perl-base \\\nheimdal-dev libpopt-dev libunistring-dev graphviz libsnmp-dev python3-setuptools \\\npython3-paramiko python3-lxml python3-defusedxml python3-dev gettext python3-polib \\\nxmltoman python3-pip texlive-fonts-recommended \\\ntexlive-latex-extra --no-install-recommends xsltproc sudo vim rsync -y\n<\/code><\/pre>\n\n\n\nInstall Yarn on Debian 11\/Debian 10<\/h4>\n\n\n\n
Next, install Yarn JavaScript package manager<\/p>\n\n\n\n
curl -sL https:\/\/dl.yarnpkg.com\/debian\/pubkey.gpg | gpg --dearmor | sudo tee \/usr\/share\/keyrings\/yarnkey.gpg >\/dev\/null<\/code><\/pre>\n\n\n\necho \"deb [signed-by=\/usr\/share\/keyrings\/yarnkey.gpg] https:\/\/dl.yarnpkg.com\/debian stable main\" | sudo tee \/etc\/apt\/sources.list.d\/yarn.list<\/code><\/pre>\n\n\n\napt update<\/code><\/pre>\n\n\n\napt install yarn -y<\/code><\/pre>\n\n\n\nInstall PostgreSQL on Debian 11\/Debian 10<\/h4>\n\n\n\n
GVM 21.04 uses PostgreSQL as the backend database. We use version 11 in this setup.<\/p>\n\n\n\n
On Debian 10, run the command below to install PostgreSQL;<\/p>\n\n\n\n
apt install postgresql-11 postgresql-contrib-11 postgresql-server-dev-11 -y<\/code><\/pre>\n\n\n\nOn Debian 11, run the command below;<\/p>\n\n\n\n
echo \"deb http:\/\/apt.postgresql.org\/pub\/repos\/apt $(lsb_release -cs)-pgdg main\" > \/etc\/apt\/sources.list.d\/pgdg.list\ncurl -sL https:\/\/www.postgresql.org\/media\/keys\/ACCC4CF8.asc | sudo tee \/etc\/apt\/trusted.gpg.d\/pgdg.asc >\/dev\/null\napt update\napt install postgresql-11 postgresql-contrib-11 postgresql-server-dev-11 -y<\/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\nsystemctl enable postgresql<\/code><\/pre>\n\n\n\nAllow the user to run the installation with sudo rights;<\/p>\n\n\n\n
echo \"gvm ALL = NOPASSWD: $(which make) install\" > \/etc\/sudoers.d\/gvm<\/code><\/pre>\n\n\n\nBuilding GVM 21.04 from Source Code<\/h3>\n\n\n\n
There are different tools required to install and setup GVM 21.04 on Debian 11\/Debian 10. 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\nBuild and Install GVM<\/h4>\n\n\n\n
Switch to GVM user created above;<\/p>\n\n\n\n
su - gvm<\/code><\/pre>\n\n\n\nCreate a directory where to download the source files to;<\/p>\n\n\n\n
mkdir 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\ngit clone -b stable --single-branch https:\/\/github.com\/greenbone\/gsad.git<\/code><\/pre>\n\n\n\nOnce the source files are in place, proceed to build and install GVM.<\/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\nopenvas-smb<\/code><\/pre>\n\n\n\nI would suggest you take a snapshot of your machine at this point, <\/strong>just in case things don\u2019t work out, you can revert to this stage without having to start from scratch!<\/p>\n\n\n\nNote that we will install all GVM 21.04 files and libraries to the default location, \/usr\/local<\/code><\/strong>.<\/p>\n\n\n\nBuild and Install GVM 11 Libraries<\/h4>\n\n\n\nwhoami<\/code><\/pre>\n\n\n\ngvm<\/code><\/pre>\n\n\n\nFrom within the source directory, \/opt\/gvm\/gvm-source<\/strong><\/code>, in this setup, change to GVM libraries directory;<\/p>\n\n\n\ncd gvm-libs\nmkdir build && cd build\ncmake ..\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\ncmake ..\nmake\nsudo make install<\/code><\/pre>\n\n\n\nBuild and install OpenVAS scanner;<\/p>\n\n\n\n
cd ..\/..\/openvas\n[ -d build ] || mkdir build && cd build\ncmake ..\nmake\nsudo make install<\/code><\/pre>\n\n\n\nConfiguring OpenVAS Scanner<\/h4>\n\n\n\n
The host scan information is stored temporarily on Redis server.<\/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
exit<\/code><\/pre>\n\n\n\nldconfig<\/code><\/pre>\n\n\n\nThe default configuration of Redis server is \/etc\/redis\/redis.conf<\/code>.<\/p>\n\n\n\nNext, copy OpenVAS scanner Redis configuration file from the OpenVAS source directory, redis-openvas.conf<\/code>, to the Redis config directory;<\/p>\n\n\n\ncp \/opt\/gvm\/gvm-source\/openvas\/config\/redis-openvas.conf \/etc\/redis\/<\/code><\/pre>\n\n\n\nUpdate the ownership of the configuration.<\/p>\n\n\n\n
chown redis:redis \/etc\/redis\/redis-openvas.conf<\/code><\/pre>\n\n\n\nUpdate the path to Redis unix socket on the \/etc\/openvas\/openvas.conf<\/strong><\/code> using the db_address<\/code><\/strong> parameter.<\/p>\n\n\n\nTo get the path to the Redis unix socket, run the command;<\/p>\n\n\n\n
grep unixsocket \/etc\/redis\/redis-openvas.conf<\/code><\/pre>\n\n\n\nSample output;<\/p>\n\n\n\n
unixsocket \/run\/redis-openvas\/redis.sock<\/strong>\nunixsocketperm 770<\/code><\/pre>\n\n\n\nOnce you get the path to Redis unix socket, run the command;<\/p>\n\n\n\n
echo \"db_address = \/run\/redis-openvas\/redis.sock<\/strong><\/strong>\" > \/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
\ncat > \/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\nRestart OpenVAS Redis server<\/p>\n\n\n\n
systemctl enable --now redis-server@openvas<\/code><\/pre>\n\n\n\nConfirm the status;<\/p>\n\n\n\n
systemctl status redis-server@openvas<\/code><\/pre>\n\n\n\n\u25cf redis-server@openvas.service - Advanced key-value store (openvas)\n Loaded: loaded (\/lib\/systemd\/system\/redis-server@.service; enabled; vendor preset: enabled)\n Active: active (running) since Sat 2021-08-28 09:40:06 EAT; 5s ago\n Docs: http:\/\/redis.io\/documentation,\n man:redis-server(1)\n Main PID: 9001 (redis-server)\n Status: \"Ready to accept connections\"\n Tasks: 5 (limit: 4679)\n Memory: 2.9M\n CPU: 42ms\n CGroup: \/system.slice\/system-redis\\x2dserver.slice\/redis-server@openvas.service\n \u2514\u25009001 \/usr\/bin\/redis-server 127.0.0.1:0\n\nAug 28 09:40:06 bullseye.kifarunix-demo.com redis-server[9001]: `-._ `-._`-.__.-'_.-' _.-'\nAug 28 09:40:06 bullseye.kifarunix-demo.com redis-server[9001]: `-._ `-.__.-' _.-'\nAug 28 09:40:06 bullseye.kifarunix-demo.com redis-server[9001]: `-._ _.-'\nAug 28 09:40:06 bullseye.kifarunix-demo.com redis-server[9001]: `-.__.-'\nAug 28 09:40:06 bullseye.kifarunix-demo.com redis[9001]: _._ \n _.-``__ ''-._ \n _.-`` `. `_. ''-._ Redis 6.0.15 (00000000\/0) 64 bit\n .-`` .-```. ```\\\/ _.,_ ''-._ \n ( ' , .-` | `, ) Running in standalone mode\n |`-._`-...-` __...-.``-._|'` _.-'| Port: 0\n | `-._ `._ \/ _.-' | PID: 9001\n `-._ `-._ `-.\/ _.-' _.-' \n |`-._`-._ `-.__.-' _.-'_.-'| \n | `-._`-._ _.-'_.-' | http:\/\/redis.io \n `-._ `-._`-.__.-'_.-' _.-' \n |`-._`-._ `-.__.-' _.-'_.-'| \n | `-._`-._ _.-'_.-' | \n `-._ `-._`-.__.-'_.-' _.-' \n `-._ `-.__.-' _.-' \n `-._ _.-' \n `-.__.-'\nAug 28 09:40:06 bullseye.kifarunix-demo.com redis-server[9001]: 9001:M 28 Aug 2021 09:40:06.710 # Server initialized\nAug 28 09:40:06 bullseye.kifarunix-demo.com redis[9001]: Server initialized\nAug 28 09:40:06 bullseye.kifarunix-demo.com redis-server[9001]: 9001:M 28 Aug 2021 09:40:06.711 * The server is now ready to accept connections at \/run\/redis-openvas\/redis>\nAug 28 09:40:06 bullseye.kifarunix-demo.com redis[9001]: The server is now ready to accept connections at \/run\/redis-openvas\/redis.sock\nAug 28 09:40:06 bullseye.kifarunix-demo.com systemd[1]: Started Advanced key-value store (openvas).\n<\/code><\/pre>\n\n\n\nUpdate Network Vulnerability Tests (NVTs)<\/h4>\n\n\n\n
Update Network Vulnerability Tests feed from Greenbone Security Feed\/Community Feed using the greenbone-nvt-sync<\/code> command. rsync<\/code> tool is required for a successful synchronization.<\/p>\n\n\n\nNote that greenbone-nvt-sync<\/code><\/strong> must not be executed as privileged user root. For this reason, update the NVTs as gvm user created above.<\/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\nAlso, allow GVM user to run openvas with sudo rights.<\/p>\n\n\n\n
echo \"gvm ALL = NOPASSWD: $(which openvas)\" >> \/etc\/sudoers.d\/gvm<\/code><\/pre>\n\n\n\nNext, update the NVTs GVM user;<\/p>\n\n\n\n
su - gvm<\/code><\/pre>\n\n\n\ngreenbone-nvt-sync<\/code><\/pre>\n\n\n\nIf the command fails with:<\/p>\n\n\n\n
rsync: [receiver] read error: Connection reset by peer (104)\nrsync error: error in socket IO (code 10) at io.c(784) [receiver=3.2.3]\nrsync: connection unexpectedly closed (1913648 bytes received so far) [generator]\nrsync error: error in rsync protocol data stream (code 12) at io.c(228) [generator=3.2.3]<\/code><\/pre>\n\n\n\nThen append --rsync<\/code> option and rerun the command.<\/p>\n\n\n\ngreenbone-nvt-sync --rsync<\/code><\/pre>\n\n\n\nOnce the update is done, you need to upload the plugins into Redis server;<\/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\ncd gvm-source\/gvmd\nmkdir build && cd build\ncmake ..\nmake\nsudo make install<\/code><\/pre>\n\n\n\nBuild and Install Greenbone Security Assistant<\/h4>\n\n\n\n
The Greenbone Security Assistant is the web interface developed for the Greenbone Security Manager<\/p>\n\n\n\n
cd ..\/..\/gsa\nrm -rf build\nyarn\nyarn build<\/code><\/pre>\n\n\n\nAll content of the production build can be shipped with every web server. For providing GSA via