{"id":2712,"date":"2019-06-18T19:17:52","date_gmt":"2019-06-18T16:17:52","guid":{"rendered":"https:\/\/kifarunix.com\/?p=2712"},"modified":"2019-06-18T19:17:53","modified_gmt":"2019-06-18T16:17:53","slug":"install-openvas-9-with-postgresql-in-ubuntu-18-04","status":"publish","type":"post","link":"https:\/\/kifarunix.com\/install-openvas-9-with-postgresql-in-ubuntu-18-04\/","title":{"rendered":"Install OpenVAS 9 with PostgreSQL in Ubuntu 18.04"},"content":{"rendered":"\n<p>In this guide, we are going to learn how to install OpenVAS 9 with PostgreSQL in Ubuntu 18.04. In our previous guide, we covered the installation of OpenVAS 9 on Ubuntu 18.04, see the link below. OpenVAS 9 uses SQLite as the database by default.<\/p>\n\n\n\n<p><a href=\"https:\/\/kifarunix.com\/how-to-install-and-setup-openvas-9-vulnerability-scanner-on-ubuntu-18-04\/\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\">Installing OpenVAS 9 on Ubuntu 18.04<\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Install OpenVAS 9 with PostgreSQL in Ubuntu 18.04<\/h3>\n\n\n\n<p>To begin with, update and upgrade your system packages.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>sudo apt update<br>sudo apt upgrade<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Install PostgreSQL on Ubuntu 18.04<\/h4>\n\n\n\n<p>Run the command below to install PostgreSQL and the required dependencies to function with OpenVAS 9.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>sudo apt install postgresql postgresql-contrib postgresql-server-dev-10<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Running PostgreSQL<\/h4>\n\n\n\n<p>PostgreSQL is set to run after installation by default. You can check status by running the command below;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo systemctl status postgresql\n\u25cf postgresql.service - PostgreSQL RDBMS\n   Loaded: loaded (\/lib\/systemd\/system\/postgresql.service; enabled; vendor preset: enabled)\n   Active: active (exited) since Mon 2019-06-17 22:47:18 EAT; 10min ago\n Main PID: 2019 (code=exited, status=0\/SUCCESS)\n    Tasks: 0 (limit: 1130)\n   CGroup: \/system.slice\/postgresql.service<\/code><\/pre>\n\n\n\n<p>It is also enabled to run on system boot.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>systemctl is-enabled postgresql<br>enabled<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Create PostgreSQL User and Database<\/h4>\n\n\n\n<p>Once the installation is done, create the PostgreSQL user and database for OpenVAS manager. Note that the database and user should be created as PostgreSQL user, <strong>postgres<\/strong>.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>sudo -Hiu postgres\ncreateuser root\ncreatedb -O root tasks<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Grant PostgreSQL User DBA Roles<\/h4>\n\n\n\n<p>Next, login to PostgreSQL database and grant the user (created above) the administrative roles on that database.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>sudo -Hiu postgres\npsql tasks\ncreate role dba with superuser noinherit;\ngrant dba to root;\ncreate extension \"uuid-ossp\";\n\\q\nexit<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Build OpenVAS 9 Manager From Source<\/h4>\n\n\n\n<p>To build OpenVAS 9 from the source, you need to download the source code. Hence, before you can proceed, create a directory to which the OpenVAS manager source will be downloaded. This guide used the local source code directory.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>sudo mkdir -p \/usr\/local\/src\/openvas\/debs<\/code><\/pre>\n\n\n\n<p>Add the mrazavi OpenVAS repository to enable use install OpenVAS Manager as shown below.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>sudo apt install software-properties-common\nsudo add-apt-repository ppa:mrazavi\/openvas<\/code><\/pre>\n\n\n\n<p>After that, edit the created source list to enable OpenVAS source repository by uncommenting source repository as shown below<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>sudo vim \/etc\/apt\/sources.list.d\/mrazavi-ubuntu-openvas-bionic.list<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>deb http:\/\/ppa.launchpad.net\/mrazavi\/openvas\/ubuntu bionic main\ndeb-src http:\/\/ppa.launchpad.net\/mrazavi\/openvas\/ubuntu bionic main\n<\/code><\/pre>\n\n\n\n<p>Next, run system update to resynchronize packages to the latest versions.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>sudo apt update<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Install Required Build Tools and Dependencies<\/h4>\n\n\n\n<p>Next, run the command below to install the build tools and the required dependencies.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>sudo apt install dpkg-dev debhelper cmake pkg-config libglib2.0-dev libgnutls28-dev build-essential libgcrypt11-dev libsqlite3-dev libgpgme-dev rats libopenvas9-dev<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Download OpenVAS Manager Source code<\/h4>\n\n\n\n<p>Navigate to OpenVAS 9 source directory created above and run the command below to download the source code.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>cd \/usr\/local\/src\/openvas\nsudo apt source openvas9-manager<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Verify OpenVAS build dependencies<\/h4>\n\n\n\n<p>Before you can compile OpenVAS 9, you need to check if any dependency is missing. This can be done by running the <strong>dpkg-checkbuilddeps<\/strong> command within the OpenVAS manager source directory.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>cd \/usr\/local\/src\/openvas\/openvas9-manager-7.0.3\nsudo dpkg-checkbuilddeps<\/code><\/pre>\n\n\n\n<p>If there is any dependency missing, you will see it. Hence, you need to install any missing dependency before you can proceed. If all is well, the command returns nothing.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Configure OpenVAS Source code to use PostgreSQL<\/h4>\n\n\n\n<p>To configure OpenVAS to use PostgreSQL instead of the default SQLite, edit the <strong>debian\/rules<\/strong> within the source code directory and make the adjustments as shown below;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>sudo vim debian\/rules<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>...\n# Add '-DBACKEND=POSTGRESQL' to the line below to enable support for PostgreSQL\noverride_dh_auto_configure:\n        dh_auto_configure -- -DLOCALSTATEDIR=\/var -DSYSCONFDIR=\/etc -DBACKEND=POSTGRESQL\n...<\/code><\/pre>\n\n\n\n<p>Once that is done, add PostgreSQL directory as part of OpenVAS install directories.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>sudo sh -c \"echo 'usr\/lib\/openvasmd\/pg' &gt;&gt; debian\/openvas9-manager.dirs\"\nsudo sh -c \"echo 'usr\/lib\/openvasmd\/pg' &gt;&gt; debian\/openvas9-manager.install\"<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Compile and Install OpenVAS 9 on Ubuntu 18.04<\/h4>\n\n\n\n<p>Run the command below to generate OpenVAS 9 manager DEB package from the source code.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>sudo dpkg-buildpackage -uc -us<\/code><\/pre>\n\n\n\n<p>If all is well, multiple DEB files are generated and stored under the <strong>\/usr\/local\/src\/openvas\/<\/strong>. Move all these binaries to debs directory created above.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>sudo mv \/usr\/local\/src\/openvas\/*.deb \/usr\/local\/src\/openvas\/debs\/<\/code><\/pre>\n\n\n\n<p>Install OpenVAS 9 manager. To avoid any would be dependency, use the APT command.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>sudo apt install \/usr\/local\/src\/openvas\/debs\/*.deb<\/code><\/pre>\n\n\n\n<p>During installation, you are prompted to enable redis unix socket. Enable it and proceed.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2019\/06\/redis-unix-socket-openvas.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1262\" height=\"314\" src=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2019\/06\/redis-unix-socket-openvas.png\" alt=\"install OpenVAS 9 with PostgreSQL in Ubuntu 18.04\" class=\"wp-image-3322\" title=\"\" srcset=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2019\/06\/redis-unix-socket-openvas.png 1262w, https:\/\/kifarunix.com\/wp-content\/uploads\/2019\/06\/redis-unix-socket-openvas-768x191.png 768w\" sizes=\"(max-width: 1262px) 100vw, 1262px\" \/><\/a><\/figure>\n\n\n\n<p>Next, you need to disable SQLite from overriding PostgreSQL when an update is run. This can be done by running the commands below;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>sudo apt-mark hold openvas9-manager<\/code><\/pre>\n\n\n\n<p>The build and installation of OpenVAS 9 manager is done . You can now update the network vulnerability tests database by syncing it with&nbsp;<a href=\"http:\/\/www.openvas.org\/openvas-nvt-feed.html\" target=\"_blank\" rel=\"noopener\">feeds<\/a>&nbsp;using the the following commands:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>greenbone-nvt-sync\ngreenbone-scapdata-sync\ngreenbone-certdata-sync<\/code><\/pre>\n\n\n\n<p>Once the update is done, restart the OpenVAS scanner, manager and security assistant.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>systemctl restart openvas-scanner\nsystemctl restart openvas-manager\nsystemctl restart openvas-gsa<\/code><\/pre>\n\n\n\n<p>Enable the services to run on system reboot.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>systemctl enable openvas-scanner\nsystemctl enable openvas-manager\nsystemctl enable openvas-gsa<\/code><\/pre>\n\n\n\n<p>Next, rebuild the NVTs cache so that the feeds synced above are loaded&nbsp; to the OpenVAS manager.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>openvasmd --rebuild --progress --verbose\nRebuilding NVT cache... done.<\/code><\/pre>\n\n\n\n<p>OpenVAS 9 should now be running. You can check it as shown below;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ps aux | grep openvas | grep -v grep\nroot     16686  0.0  0.1 102068  1380 ?        Ss   16:24   0:00 gpg-agent --homedir \/var\/lib\/openvas\/openvasmd\/gnupg --use-standard-socket --daemon\nroot     16726  0.1  0.3 146408  3584 ?        Ss   16:26   0:01 openvassd: Waiting for incoming connections\nroot     16747  0.0 14.2 348460 143340 ?       SL   16:26   0:00 openvasmd<\/code><\/pre>\n\n\n\n<p>To be able to generate pdf reports for the scan results, you need to install some additional packages.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>sudo apt install texlive-latex-extra --no-install-recommends\nsudo apt install texlive-fonts-recommended --no-install-recommends<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Accessing OpenVAS Web Interface<\/h4>\n\n\n\n<p>You should now be able to access OpenVAS web interface via the address, <strong>https:\/\/localhost:4000<\/strong>. Use &#8220;<strong>admin<\/strong>&#8221; as username and password for logins. However, if you are accessing OpenVAS 9 externally, you need to set the listen address to an interface IP as shown below.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>vim \/etc\/default\/openvas-gsa<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>...\n# To set listening address:\n# \n#LISTEN_ADDRESS=\"0.0.0.0\"\nLISTEN_ADDRESS=\"192.168.43.138\"\n...<\/code><\/pre>\n\n\n\n<p>After that, restart OpenVAS GSA by executing the command;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>systemctl restart openvas-gsa<\/code><\/pre>\n\n\n\n<p>Hence, login to web via <strong>https:\/\/&lt;server-IP&gt;:4000<\/strong>.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2019\/06\/openvas9-with-postresql-login.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1364\" height=\"569\" src=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2019\/06\/openvas9-with-postresql-login.png\" alt=\"install OpenVAS 9 with PostgreSQL in Ubuntu 18.04\" class=\"wp-image-3326\" title=\"\" srcset=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2019\/06\/openvas9-with-postresql-login.png 1364w, https:\/\/kifarunix.com\/wp-content\/uploads\/2019\/06\/openvas9-with-postresql-login-768x320.png 768w\" sizes=\"(max-width: 1364px) 100vw, 1364px\" \/><\/a><\/figure>\n\n\n\n<p>Login with &#8220;<strong>admin<\/strong>&#8221; as username and password for logins. However, you need to verify if this user is created by default by running the command below;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>openvasmd --get-users<\/code><\/pre>\n\n\n\n<p>If the user doesn&#8217;t exist, create an administrative user by running the command below;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>openvasmd --create-user openvasadmin<\/code><\/pre>\n\n\n\n<p>The command will automatically generate a password for the user created. You can use this credentials to login to OpenVAS 9 GSA web user interface.<\/p>\n\n\n\n<p>When you login, you can reset the password by navigating to <strong>Administration > Users > Actions > Edit User<\/strong>.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2019\/06\/reset-openvas-admin-passwd.png\"><img loading=\"lazy\" decoding=\"async\" width=\"801\" height=\"373\" src=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2019\/06\/reset-openvas-admin-passwd.png\" alt=\"Reset OpenVas 9 admin password\" class=\"wp-image-3330\" title=\"\" srcset=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2019\/06\/reset-openvas-admin-passwd.png 801w, https:\/\/kifarunix.com\/wp-content\/uploads\/2019\/06\/reset-openvas-admin-passwd-768x358.png 768w\" sizes=\"(max-width: 801px) 100vw, 801px\" \/><\/a><\/figure>\n\n\n\n<p>Click <strong>Save <\/strong>to save the new password.<\/p>\n\n\n\n<p>You have successfully installed OpenVAS 9 with support for PostgreSQL as the default database. You can now run the scans on your target end points. See the link below on how to run scans. Enjoy.<\/p>\n\n\n\n<p><a rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\" href=\"https:\/\/kifarunix.com\/how-to-add-and-scan-a-target-for-vulnerabilities-on-openvas\/\" target=\"_blank\">How to Add and Scan a Target for Vulnerabilities on OpenVAS Scanner<\/a><\/p>\n\n\n\n<p>Follow the links below for related content.<\/p>\n\n\n\n<p><a href=\"https:\/\/kifarunix.com\/how-to-install-configure-and-use-nessus-vulnerability-scanner-on-ubuntu-18-04\/\">How to Install and Configure Nessus Scanner on Ubuntu 18.04\/CentOS 7<\/a><br><a href=\"https:\/\/kifarunix.com\/install-use-wpscan-wordpress-vulnerability-scanner-ubuntu-18-04\/\">How to Install and Use WPScan WordPress Vulnerability Scanner Ubuntu 18.04<\/a><br><a href=\"https:\/\/kifarunix.com\/how-to-install-and-use-nikto-web-scanner-on-ubuntu-18-04\/\">How to Install and Use Nikto Web Scanner on Ubuntu 18.04<\/a><br><a href=\"https:\/\/kifarunix.com\/how-to-install-and-use-clamav-antivirus-on-ubuntu-18-04\/\">How to Install and Use ClamAV Antivirus on Ubuntu 18.04<\/a><br><a href=\"https:\/\/kifarunix.com\/how-to-perform-system-security-auditing-with-lynis-on-ubuntu-18-04\/\">How to Perform System Security Auditing with Lynis on Ubuntu 18.04<\/a><br><a href=\"https:\/\/kifarunix.com\/how-to-install-rkhunter-rootkit-hunter-on-ubuntu-18-04\/\">How to Install RKHunter (RootKit Hunter) On Ubuntu 18.04<\/a><br><a href=\"https:\/\/kifarunix.com\/how-to-install-sophos-antivirus-on-ubuntu-18-04\/\">How to Install Sophos AntiVirus on Ubuntu 18.04<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this guide, we are going to learn how to install OpenVAS 9 with PostgreSQL in Ubuntu 18.04. In our previous guide, we covered the<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_lock_modified_date":false,"footnotes":""},"categories":[370,34,150],"tags":[100,989,990,991,67],"class_list":["post-2712","post","type-post","status-publish","format-standard","hentry","category-openvas","category-security","category-vulnerability-scanners","tag-openvas","tag-openvas-9","tag-postgresql","tag-sqlite","tag-ubuntu-18-04","generate-columns","tablet-grid-50","mobile-grid-100","grid-parent","grid-50"],"_links":{"self":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/2712"}],"collection":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/comments?post=2712"}],"version-history":[{"count":3,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/2712\/revisions"}],"predecessor-version":[{"id":3331,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/2712\/revisions\/3331"}],"wp:attachment":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/media?parent=2712"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/categories?post=2712"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/tags?post=2712"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}