Featured resource
2025 Tech Upskilling Playbook
Tech Upskilling Playbook

Build future-ready tech teams and hit key business milestones with seven proven plays from industry leaders.

Check it out
  • Lab
    • Libraries: If you want this lab, consider one of these libraries.
    • Cloud
Google Cloud Platform icon
Labs

Using SSH to Check Services

You need to connect to and perform a check on a client machine from the Nagios server. Due to your university's firewall rules (port 5666 is not allowed for NRPE), you will need to use SSH. In this hands-on lab, we will configure an SSH check on a client and the Nagios server.

Google Cloud Platform icon
Lab platform
Lab Info
Level
Intermediate
Last updated
Sep 25, 2025
Duration
1h 15m

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.
Table of Contents
  1. Challenge

    Generate SSH Keys for the nagios User
    1. On the Nagios server, become the nagios user.
    sudo su nagios
    
    1. Generate SSH keys for the nagios user.
    ssh-keygen
    
  2. Challenge

    Copy the Public Key from the Nagios Server to the Client
    1. Run the following command from the Nagios server:
    vim /home/nagios/.ssh/id_rsa.pub
    
    1. Select the SSH key, and copy it to your clipboard.
    2. On the client, open the authorized_keys file.
    sudo vim /home/cloud_user/.ssh/authorized_keys
    
    1. Paste the SSH key at the end of the file, then save and exit.
  3. Challenge

    Test the SSH Connection
    1. From the Nagios server, run the following command:
    ssh cloud_user@CLIENT_IP
    
  4. Challenge

    Copy the check_disk Binaries from the Nagios Server to the Client
    1. Run the following command from the Nagios server:
    sudo -i scp /usr/local/nagios/libexec/check_disk cloud_user@CLIENT_IP:/home/cloud_user/
    
  5. Challenge

    Define an SSH Check Command Object on the Nagios Server
    1. From the Nagios server, change to the /usr/local/nagios/etc/objects/ directory.
    cd /usr/local/nagios/etc/objects/
    
    1. Open the commands.cfg file.
    sudo vim commands.cfg
    
    1. Add the following to the file:
    define command {
    
           command_name    ssh_check_disk
           command_line    /usr/local/nagios/libexec/check_by_ssh -H $HOSTADDRESS$ -i /home/nagios/.ssh/id_rsa -l cloud_user -C "/home/cloud_user/check_disk -w 10% -c 5% -p /"
    }
    
  6. Challenge

    Create the Host, Host Group, and Service Object Definitions
    1. Create a new file named linux-server.cfg in the /usr/local/nagios/etc/objects/ directory.
    sudo touch /usr/local/nagios/etc/objects/linux-server.cfg
    
    1. Open the file.
    sudo vim /usr/local/nagios/etc/objects/linux-server.cfg
    
    1. Add the following to the file:
    define host {
    
           use                     linux-server
           host_name               Linux Server
           alias                   linuxSrv
           address                 CLIENT_IP
     
     }
    
     define hostgroup {
    
           hostgroup_name          my-linux-servers
           alias                   Linux Servers
           members                 Linux Server
    
     }
    
     define service {
    
           use                     generic-service
           host_name               Linux Server
           service_description     Check DISK
           check_command           ssh_check_disk
    
     }
    
  7. Challenge

    Inform Nagios of the New File, Perform a Preflight Check, and Restart Nagios
    1. Run the following command:
    sudo vim /usr/local/nagios/etc/nagios.cfg
    
    1. Add the following to the file:
    Definitions for monitoring a network printer
    cfg_file=/usr/local/nagios/etc/objects/linux-server.cfg
    
    1. Save and exit the file.
    2. Run a preflight check.
    sudo /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
    
    1. Restart Nagios.
    sudo systemctl restart nagios
    
    1. Check the status of Nagios.
    sudo systemctl status nagios
    
  8. Challenge

    Log In to the Nagios Web Interface and Reschedule a Check for the Check DISK Service
    1. In a private browser tab, navigate to http://NAGIOS_SERVER_IP/nagios.
    2. Log in with the following credentials:
      • User Name: nagiosadmin
      • Password: BlaBla321
    3. Click Services > Check DISK.
    4. Under Service Commands, click Re-schedule the next check of this service.
    5. Next to Check Time, enter a time approximately 10-20 seconds from now (you can check the current time using the date command in your terminal window).
    6. Click Commit, then Done.
    7. Click Services in the left sidebar.
    8. Verify that there are no errors for the Check DISK service under Status Information.
About the author

Pluralsight Skills gives leaders confidence they have the skills needed to execute technology strategy. Technology teams can benchmark expertise across roles, speed up release cycles and build reliable, secure products. By leveraging our expert content, skill assessments and one-of-a-kind analytics, keep up with the pace of change, put the right people on the right projects and boost productivity. It's the most effective path to developing tech skills at scale.

Real skill practice before real-world application

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Learn by doing

Engage hands-on with the tools and technologies you’re learning. You pick the skill, we provide the credentials and environment.

Follow your guide

All labs have detailed instructions and objectives, guiding you through the learning process and ensuring you understand every step.

Turn time into mastery

On average, you retain 75% more of your learning if you take time to practice. Hands-on labs set you up for success to make those skills stick.

Get started with Pluralsight