nagios-cgi密码屏幕旁路

时间:2014-07-28 06:34:16

标签: bash ubuntu automation passwords

我正在尝试设置一个bash脚本来安装nagios3及其所有依赖项。我理解:

apt-get install -y nagios3

负责所有这些。

现在我担心的是绕过nagios3-cgi的设置屏幕 到目前为止我有这个:

#!/bin/bash

PASS="0"
REPASS="1"
while [ $PASS != $REPASS ]; do
    read -s -p "Password: " PASS; echo
    read -s -p "Retype: " REPASS; echo
done

debconf-set-selections <<< "postfix postfix/mailname string your.hostname.com"
debconf-set-selections <<< "postfix postfix/main_mailer_type string 'Internet Site'"
apt-get install -y postfix

apt-get install -y  nagios3

我能够绕过后缀配置屏幕:

debconf-set-selections <<< "postfix postfix/mailname string your.hostname.com"
debconf-set-selections <<< "postfix postfix/main_mailer_type string 'Internet Site'"

我怎么能用nagios3-cgi做同样的事情?

我尝试了这个,但它没有用:

mkdir /etc/nagios3
htpasswd -cb /etc/nagios3/htpasswd.users nagiosadmin $PASS

1 个答案:

答案 0 :(得分:1)

我解决了自己的问题。

首先我在vm上正常安装了nagios3 然后我用了

debconf-get-selections > file.txt
debconf-get-selections >> file.txt

这会将所有安装详细信息写入file.txt

然后在文件中搜索nagios3-cgi配置

我发现我需要的配置文件的名称是

nagios3-cgi nagios3-cgi/adminpassword

nagios3-cgi nagios3-cgi/adminpassword-retype

然后我做了与posfix安装相同的事情。 这是我最后的剧本。真的很简单。

PASS="0"
REPASS="1"


#Password loop
while [ $PASS != $REPASS ]; do
    read -s -p "Nagios Password: " PASS; echo
    read -s -p "Retype Nagios Password: " REPASS; echo
done

sudo debconf-set-selections <<< "postfix postfix/mailname string diggalabs.com"
sudo debconf-set-selections <<< "postfix postfix/main_mailer_type string 'Internet Site'"
sudo debconf-set-selections <<< "nagios3-cgi nagios3/adminpassword string $PASS"
sudo debconf-set-selections <<< "nagios3-cgi nagios3/adminpassword-repeat string $PASS"


sudo apt-get install -y nagios3