Is there a way I can allow Nagios users to change thier own passwords?
Currently using 4.x with no additional front ends or addons.
I found this but there are no actual instructions on how to install it?
https://exchange.nagios.org/directory/A ... te/details
Changing User Passwords
Re: Changing User Passwords
It should be not so hard to write your own script.
index.php to select the user and mailaddress:
Mailform.php to submit the form:
And the shell scrtip to do the change:
index.php to select the user and mailaddress:
Code: Select all
<head>
<title>Password recovery for Nagios</title>
</head>
<body>
<center>
<h1>Password recovery for Nagios<sup><font size=-2>4.0.X</font></sup> </h1>
</center>
<FORM METHOD="post" ACTION="mailform.php" onsubmit="return checkform(); return false;">
<table cellpadding=5 cellspacing=0 border=0>
<tr><td colspan=2><b>Which users password should be changed?</b></td></tr>
<tr><td width=80>Mailadres:</td><td><input type="text" name="mailadres" [email protected]></td></tr>
<tr><td width=80>Gebruikersnaam:</td><td>
</td></tr>
<tr><td width=80>Password:</td><td><input type="password" name="password"></td></tr>
</table>
<br><br>
<input type="submit" name="button" value="Verzenden">
</form>
</body>
</html>
Code: Select all
<?php
// read the variables...
$adres=$_POST["mailadres"];
$password=$_POST["password"];
if($adres=="[email protected]"){ $name="user1"; $mail="[email protected]"; change($mail,$name,$password);}
elseif($adres=="[email protected]"){ $name="user2"; $mail="[email protected]"; change($mail,$name,$password);}
else { echo "Something went wrong, mailaddress unknown. $adres"; }
function change($mail,$name,$password) {
if($password=="") {
$passwd=exec("openssl rand -base64 6");
} else {
$passwd=$password;
}
$pwd = shell_exec("/usr/local/bin/passwd-recovery.sh $name $passwd $mail");
echo $pwd;
}
?>
Code: Select all
#!/bin/bash
name=$1;
passwd=$2;
mailadres=$3;
echo "<h1> The new password for <font color=red> $name </font> is now changed! <!-- $passwd --></h1><br><br>"
echo "<br><br><br>"
sudo htpasswd -D /etc/nagios/htpasswd.users $name
sudo htpasswd -mb /etc/nagios/htpasswd.users $name $passwd
echo "<br><br><br>"
echo "<h1>A mail is sent to: <font color=red>$mailadres </font>, If you did not receive the mail, please contact your administrator<br><br><br></h1>"
# Email text/message
EMAILMESSAGE="The password for $name is changed"
# send an email using /bin/mail
echo $EMAILMESSAGE | /bin/mail -s "The new password for Nagios 4.0.X WEB environment" "$mailadres"
exit
Rob Hassing


Re: Changing User Passwords
Sorry this is way above my knowledge of Nagios - how do I go about installing this script?
Re: Changing User Passwords
Actually this has nothing to do with Nagios, this is standard Linux.
Rob Hassing


Re: Changing User Passwords
Something like this is just another web page, and as rhassing pointed out is not something that would be loaded up in a nagios config file.
It's simply a set of web pages and a bash script that will present users with a page to change passwords. You would host these files somewhere on your web server (making sure not to overwrite any Nagios files) and then view the web page directly.
It's simply a set of web pages and a bash script that will present users with a page to change passwords. You would host these files somewhere on your web server (making sure not to overwrite any Nagios files) and then view the web page directly.
Former Nagios employee