nagiosのユーザIDとパスワードの変更方法は以前に説明を残していますが、nagiosを入れたばかりのタイミングで変更するにしても、設定が簡単ではなかった。
でも、変更しておかないと、セキュリティ上はあまり宜しくない。
今回は、ユーザIDを設定変更する方法をきちんと整理する。
まず、作業工程を整理する。
①ユーザIDとパスワードの設定を行う。
②nagiosの設定でユーザIDを設定し直す。
それでは開始します。
1)ユーザIDとパスワードの設定を行う。
まず最初にユーザIDとパスワードを設定し直します。
やり方は以前説明した方法と同じです。
以下のコマンドを実行してpasswdファイルを変更します。
# htpasswd -c /etc/nagios/passwd username
New password:
Re-type new password:
Adding password for user username
※usernameには適当なIDを指定します。
https://ドメイン/nagios/へ再接続して、設定したIDとパスワードでログインしてみます。
Servicesを選択すると・・・
「It appears as though you do not have permission to view information for any of the services you requested…」と表示されています。
その下の行には、CGIが動作していないことが記されています。
この問題を次の作業でクリアします。
2)nagiosの設定でユーザIDを設定し直す。
# cd /etc/nagios/
# grep nagiosadmin *
cgi.cfg:authorized_for_system_information=nagiosadmin
cgi.cfg:authorized_for_configuration_information=nagiosadmin
cgi.cfg:authorized_for_system_commands=nagiosadmin
cgi.cfg:authorized_for_all_services=nagiosadmin
cgi.cfg:authorized_for_all_hosts=nagiosadmin
cgi.cfg:authorized_for_all_service_commands=nagiosadmin
cgi.cfg:authorized_for_all_host_commands=nagiosadmin
#
cgi.cfgにnagiosadminというIDで設定がありますね。
これらを新たに設定したユーザIDに変更します。
変更はviなどで行ってください。
次に、/etc/nagios/objectsの中にもnagiosadminで設定がされている場所があります。
# grep nagiosadmin */*
objects/contacts.cfg: contact_name nagiosadmin ; Short name of user
objects/contacts.cfg: members nagiosadmin
objects/contacts.cfgの内容も同じように変更します。
最後に、以下のコマンドを実行して、nagiosを再起動します。
# service nagios restart
以上で設定は更新されました。
元通り監視が行われていればOKです。