nrpe 執行命令報錯NRPE: Unable to read output

在客戶端編寫的一個腳本check_ssh_auto.sh


#!/bin/bash


a=`/bin/cat /etc/ssh/sshd_config | grep PasswordAuthentication | grep -v "^#" | awk '{print $2}'`

if [ "$a" = "yes" ]; then

    echo "SSH authentication: WARNING Please amend the warning SSH authentication for key authentication;"

    $(exit 1)

  else

    echo "SSH authentication: OK;"

    $(exit 0)

  fi


客戶端執行正常


nagios服務器測試執行

/usr/local/nagios/libexec/check_nrpe -H 192.168.10.1 -c ssh_auth

提示NRPE: Unable to read output


解決方法

在客戶端修改文件

vi /etc/sudoers


注視這行

#Defaults    requiretty

在root    ALL=(ALL)       ALL下面添加一行

nagios ALL=(ALL) NOPASSWD:/usr/local/nagios/libexec/*


修改nrpe配置文件/usr/local/nagios/etc/nrpe.cfg


command[ssh_auth]=/usr/bin/sudo /usr/local/nagios/libexec/check_ssh_auth.sh


重啓nrpe


服務器端再次測試

SSH authentication: OK;

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章