220510 Lab2: Install Zabbix server, monitoring for the host and install mailhog server - arashafazeli/bb-readme-tutorials GitHub Wiki

  • Please read tutrorial "Install Zabbix using virtual machines with Vagrant"

!! THIS README IS NOT TESTED YET !!

Goals for part 2:

  • Update the system to the latest packages available. Make also sure you have an editor you're familiar with installed in the VM.
  • Set up a firewall (suggestion: ufw or firewalld) and block all incoming traffic on all ports
  • Setup an ssh server listening on port 2222.
  • Make sure that it is only possible to login with an ssh key and not with a password.
  • Make sure only your user is allowed to log in via ssh. (use openssh and not dropbear). Open port 2222 in the firewall.
  • Setup Zabbix server. Make sure to open all the needed ports in the firewall.
  • Setup monitoring for the host from Part 1. Use the Linux template, and set up even a web scenario to make sure wordpress and the admin panel for wordpress are up and reachable.
  • Setup a MailHog server to receive mail from zabbix server. Setup the media type in Zabbix and the right actions and triggers so you get a mail for all alarms that come up in Zabbix.

Setting up VM

sudo apt upgrade && sudo apt update -y
sudo apt-get install openssh-server
sudo systemctl enable ssh
sudo systemctl start ssh

Setting up a firewall

sudo apt install ufw
sudo ufw status
sudo ufw allow 2222
sudo ufw enable

Change settings in sshd_config

sudo ufw default deny incoming
sudo vim /etc/ssh/sshd_config
uncomment row #port 22
change from 22 to 2222
close sshd_config

Setting up login with an ssh key

ssh-keygen on local computer
cat ~/.ssh/id_rsa.pub
copy and paste all info to the server's ~/.ssh/authorized_keys
sudo vim ~/.ssh/authorized_keys
sudo reboot

Install Zabbix repository

wget https://repo.zabbix.com/zabbix/6.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_6.0-1+ubuntu20.04_all.deb
sudo dpkg -i zabbix-release_6.0-1+ubuntu20.04_all.deb
sudo apt update 

Install Zabbix server, frontend, agent

sudo apt install zabbix-server-mysql zabbix-frontend-php zabbix-apache-conf zabbix-sql-scripts zabbix-agent 

Create initial database

mysql -uroot -p password
create database zabbix character set utf8mb4 collate utf8mb4_bin;
create user zabbix@localhost identified by 'password';
grant all privileges on zabbix.* to zabbix@localhost;
quit; 

On Zabbix server host import initial schema and data

zcat /usr/share/doc/zabbix-sql-scripts/mysql/server.sql.gz | mysql -uzabbix -p zabbix 

Configure zabbix_server.conf

DBPassword=password

Start Zabbix server and agent processes

systemctl restart zabbix-server zabbix-agent apache2
systemctl enable zabbix-server zabbix-agent apache2