Nagios 3.4.4 / Ubuntu Server / Permission denied to htpasswd

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
fugitive
Posts: 15
Joined: Fri Mar 08, 2013 12:49 pm

Nagios 3.4.4 / Ubuntu Server / Permission denied to htpasswd

Post 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.
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

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

Post by abrist »

What are the permissions on the htpasswd.users file itself?

Code: Select all

ls -la /usr/local/nagios/etc/htpasswd.users
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
fugitive
Posts: 15
Joined: Fri Mar 08, 2013 12:49 pm

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

Post by fugitive »

-rw-r----- 1 nagios nagcmd 50 Mar 8 08:27 /usr/local/nagios/etc/htpasswd.users
fugitive
Posts: 15
Joined: Fri Mar 08, 2013 12:49 pm

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

Post 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
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

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

Post by abrist »

Try:

Code: Select all

chmod o+r /usr/local/nagios/etc/htpasswd.users
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
fugitive
Posts: 15
Joined: Fri Mar 08, 2013 12:49 pm

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

Post 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?
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

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

Post 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?
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
fugitive
Posts: 15
Joined: Fri Mar 08, 2013 12:49 pm

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

Post 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.
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

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

Post 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).
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
sreinhardt
-fno-stack-protector
Posts: 4366
Joined: Mon Nov 19, 2012 12:10 pm

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

Post 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.
Nagios-Plugins maintainer exclusively, unless you have other C language bugs with open-source nagios projects, then I am happy to help! Please pm or use other communication to alert me to issues as I no longer track the forum.
Locked