Page 1 of 2

Nagios 3.4.4 / Ubuntu Server / Permission denied to htpasswd

Posted: Fri Mar 08, 2013 1:02 pm
by fugitive
I compiled form source and everything checked out fine though I can not get past the login.

apache error.log has...

Permission denied: Could not open password file: /usr/local/nagios/etc/htpasswd.users

/usr/local/nagios folder permissions

drwxr-xr-x 12 root root 4096 Mar 7 09:23 nagios.

Not sure the correct way to resolve this issue.

Any help would be much appreciated.

Re: Nagios 3.4.4 / Ubuntu Server / Permission denied to htpa

Posted: Fri Mar 08, 2013 1:15 pm
by abrist
What are the permissions on the htpasswd.users file itself?

Code: Select all

ls -la /usr/local/nagios/etc/htpasswd.users

Re: Nagios 3.4.4 / Ubuntu Server / Permission denied to htpa

Posted: Fri Mar 08, 2013 1:28 pm
by fugitive
-rw-r----- 1 nagios nagcmd 50 Mar 8 08:27 /usr/local/nagios/etc/htpasswd.users

Re: Nagios 3.4.4 / Ubuntu Server / Permission denied to htpa

Posted: Fri Mar 08, 2013 1:42 pm
by fugitive
root@IT7:/etc/apache2# ls -la /usr/local/nagios/etc/htpasswd.users
-rw-r----- 1 nagios nagcmd 50 Mar 8 08:27 /usr/local/nagios/etc/htpasswd.users

Re: Nagios 3.4.4 / Ubuntu Server / Permission denied to htpa

Posted: Fri Mar 08, 2013 2:25 pm
by abrist
Try:

Code: Select all

chmod o+r /usr/local/nagios/etc/htpasswd.users

Re: Nagios 3.4.4 / Ubuntu Server / Permission denied to htpa

Posted: Fri Mar 08, 2013 2:45 pm
by fugitive
Thank you so much that solved my issue.

I'm new to nagios and linux. Can you tell me what that command did to fix the issue?

Re: Nagios 3.4.4 / Ubuntu Server / Permission denied to htpa

Posted: Fri Mar 08, 2013 3:01 pm
by abrist
chmod changes permissions on files/directories. The htpasswd.users file is owned by user "nagios" and group "nagcmd". But apache needs to be able to read the file as well, as it is used to authenticate your web interface user in nagios' web frontend. Originally, your file had read/write access for user "root", read access for user "nagios", and no permissions for anything else. You can tell this by the line:

Code: Select all

-rw-r-----
Where:

Code: Select all

-111222333
111 is "root" permissions, 222 is "user", and 333 is "other". Each of these triplets are "rwx" where "r" is read, "w" is write, and "x" is execute.
Apache needs to be able to read the file to authenticate your user login against it. So the "other" portion of the file permissions needs to have read access. To break down the command:

Code: Select all

chmod o+r /usr/local/nagios/etc/htpasswd.users
"o+r" essentially gives anybody that does not own the file, "other" or "o", read or "r" access. That is why "chmod o+r" gives "others" permission to read the file.
After running the command, your file permission should resemble:

Code: Select all

-rw-r--r-- 1 root root 50 Dec  3 13:40 /usr/local/nagios/etc/htpasswd.users
Notice the additional "r" in the "others" triplet?

For more information: http://linux.about.com/od/commands/l/blcmdl1_chmod.htm

Does this help?

Re: Nagios 3.4.4 / Ubuntu Server / Permission denied to htpa

Posted: Fri Mar 08, 2013 3:13 pm
by fugitive
I admit I needed to read your explanation a few times but it has sunk in.

I was looking at adding www-data user to the nagios group thinking that would resolve the issue but was not sure about this move and knew it probably wasn't the correct way to fix this.

Re: Nagios 3.4.4 / Ubuntu Server / Permission denied to htpa

Posted: Fri Mar 08, 2013 3:25 pm
by abrist
No problem. You will find many conventions like this one that are nearly "universal* among posix based unix/linux systems. That is one of the advantages of *nix as once you become comfortable with one distribution's command line interface (bash most of the time), most of your knowledge is transferable over to another *nix versions. (technically, you are becoming apt at using GNU utilities, but that is a contextual war for recognition that has been fought by the GNU guys for ages).

Re: Nagios 3.4.4 / Ubuntu Server / Permission denied to htpa

Posted: Fri Mar 08, 2013 3:27 pm
by sreinhardt
Actually in this case it would not have resolved the issue, as the owner(nagios) and owning group(nagcmd) would not be the same as the nagios group. However if you were to add the www-data user to nagcmd, it would have resolved it. But as you thought, not an ideal solution without knowing what else that may give the www-data user permissions to.