LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 08-16-2012, 11:34 AM   #1
earthw0rmjim
Member
 
Registered: Sep 2011
Distribution: Debian testing
Posts: 62

Rep: Reputation: 12
What's the safest place for a .htpasswd file?


Hey!

I'm running an apache webserver for my rtorrent webui, password protected via .htaccess, but i don't really know what's the safest place for .htpasswd.
It's in my home directory atm.
Where should i put it?

Thanks in advance!
 
Old 08-16-2012, 09:40 PM   #2
dkm999
Member
 
Registered: Nov 2006
Location: Seattle, WA
Distribution: Fedora
Posts: 407

Rep: Reputation: 35
Much more important than where you put is is the protections you assign to it. The best way I can think of is to make sure that you have a group defined that has only the web server in it, and then assign the file a protection mode (chmod) of 0640. This allows the owner (presumably you) to read and write the .htpasswd file, and allows the web server to read it, and no one else to do anything to it.
 
1 members found this post helpful.
Old 08-16-2012, 09:45 PM   #3
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,691
Blog Entries: 4

Rep: Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947
In general, just make sure that the file is not in any place that is reachable by a URL ... and be sure that Apache does not accept ".." relative directory addresses in any of those URLs.
 
1 members found this post helpful.
Old 08-17-2012, 07:48 AM   #4
earthw0rmjim
Member
 
Registered: Sep 2011
Distribution: Debian testing
Posts: 62

Original Poster
Rep: Reputation: 12
Thanks!
 
Old 08-22-2012, 07:57 PM   #5
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,369

Rep: Reputation: 2753Reputation: 2753Reputation: 2753Reputation: 2753Reputation: 2753Reputation: 2753Reputation: 2753Reputation: 2753Reputation: 2753Reputation: 2753Reputation: 2753
Generally, .htpasswd would be outside the Document area, typically in the same dir as httpd.conf or similar.
.htaccess (a different thing entirely) is best not used and instead put the directives inside the relevant Direcorty tags inside httpd.conf
Quote:
However, in general, use of .htaccess files should be avoided when possible. Any configuration that you would consider putting in a .htaccess file, can just as effectively be made in a <Directory> section in your main server configuration file.
https://httpd.apache.org/docs/curren.../htaccess.html
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Safest place to put database connection file charu Linux - Newbie 2 12-08-2010 12:56 PM
What is the safest fs type for unwatched 24/7 file storage device bdimych Linux - Hardware 4 05-05-2007 10:36 AM
htpasswd password file fw12 Linux - Newbie 5 07-16-2006 02:26 PM
Apache Cannot Open .htpasswd File alerola Linux - Security 4 02-11-2006 01:59 AM
input file to htpasswd igcsteve Linux - Newbie 4 06-05-2003 12:54 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 12:34 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration