NDC & PKI

[Day 3] 6. Nagios Setup

D
DITISS Admin
••6 min read

Pre-requisites:

  1. Configure Hostname:

    • Set the hostname as
      nag-server
      . To do the same follow these steps:
      1. open the
        /etc/hostname
        file and change the name written to
        nag-server
        .
      2. open the
        /etc/hosts
        file and replace the name
        debian
        with
        nag-server
        or create a new entry below that line as:
        shell
        127.0.1.1       nag-server
          ```
        
  2. Configure Static IP:

    • Set a static IP for the server.
  3. Network Connectivity:

    • Ensure the server can ping both the local server and the internet.
  4. Configure APT:

    • Update the APT sources list in
      /etc/apt/sources.list
      .
    • add
      deb [trusted=1] http://sunbeam.shuharilabs.com/sw/repo/deb12/ bookworm main
  5. Install sudo:

    • Install

      sudo
      by switching to the root user and running:

      bash
      apt install sudo
      
  6. Set Time Zone:

    • Set the time zone using the following command:

      bash
      sudo dpkg-reconfigure tzdata
      

      then select

      Asia
      and then
      Kolkata
      .


Install Nagios Core:

  1. Install Pre-requisites / Dependencies:

    • Install required packages using the following command:

      bash
      sudo apt-get install -y apache2 apache2-utils autoconf gcc libc6 libgd-dev make php python3 tree unzip wget libkrb5-dev openssl libssl-dev
      
  2. Download and Extract Nagios Source Code:

    • Download Nagios and extract it:

      shell
      wget http://192.168.0.52/sw/security_tools/nagios/nagios-4.5.0.tar.gz
      tar -zxf nagios-4.5.0.tar.gz
      cd nagios-4.5.0
      
  3. Configure Nagios:

    • Navigate to the

      nagios-4.5.0
      directory and configure Nagios:

      bash
      sudo ./configure --with-httpd-conf=/etc/apache2/sites-enabled/
      
  4. Compile and Install Nagios:

    • Run the following command to compile Nagios:

      bash
      sudo make all
      

Create Nagios User and Group:

  1. Create User and Group for Nagios:

    • Run the following command in the

      nagios-4.5.0
      directory:

      bash
      sudo make install-groups-users
      
  2. Add Apache User to Nagios Group:

    • Ensure that the Apache user can access Nagios:

      bash
      sudo usermod -aG nagios www-data
      
  3. Change Nagios User Password:

    • Set a password for the Nagios user:

      bash
      sudo passwd nagios
      
  4. Install Nagios Executable:

    • Run the following command to install the Nagios executable:

      bash
      sudo make install
      
    • The Nagios binary will be located in

      /usr/local/nagios/bin
      .

  5. Enable Nagios Service to Start Automatically:

    • Ensure Nagios starts automatically after the system boots:

      bash
      sudo make install-daemoninit
      
  6. Enable Command Mode for Nagios:

    • Allow Nagios to execute commands:

      bash
      sudo make install-commandmode
      
  7. Install Nagios Configuration Files:

    • If there is no

      /etc
      folder in Nagios, run the following command to install the configuration:

      bash
      sudo make install-config
      
  8. Install Web Configuration:

    • Install the web configuration for Nagios:

      bash
      sudo make install-webconf
      

Configure Apache for Nagios:

  1. Enable Apache Modules:

    • Enable the

      rewrite
      and
      cgi
      modules:

      bash
      sudo a2enmod rewrite
      sudo a2enmod cgi
      
  2. Set Up Authentication:

    • Set up password authentication for the Nagios web interface:

      bash
      sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
      
  3. Verify Configuration:

    • Verify the Nagios configuration:

      bash
      sudo /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
      

      here we are calling the

      nagios
      and asking it to check the
      nagios.conf
      file.


Enable and Start Services:

  1. Enable Apache and Nagios Services:

    • Enable and start both Apache and Nagios:

      bash
      sudo systemctl enable --now apache2 nagios
      
  2. Check the Status of Services:

    • Verify the status of Apache:

      bash
      sudo systemctl status apache2
      
    • Restart and verify the status of Nagios:

      bash
      sudo systemctl status nagios
      

Access Nagios Web Interface:

  • Open a browser on your host machine and visit the following URL to access the Nagios web interface:

    <your_ip>/nagios
    

Read Next

8/26/2026

[Day 3] 7. Installing the Nagios Plugins

### **1. Install Dependencies for Plugins** Run the following command to install the required dependencies for Nagios plugins: ```bash sudo apt...

8/26/2026

[Day 3] 8. PKI Lab (Encryption and Decryption)

#### **Prerequisite** - A **Windows Machine** (any edition except Windows Home). - Familiarity with the **Encrypting File System (EFS)** by Micros...