creating simple authentication for a folder on my server

They have: 11 posts

Joined: Jul 2005

Hi,

I'm wondering is there any simple way to password protect a folder on my server- maybe a command i can use in putty (I don't have much experience with putty however so is there another way). It only has to be simple with only one user name and password,

Cheers

They have: 6 posts

Joined: Nov 2005

Actually, access is restricted by directory so all files in the same directory will be protected.

The file .htaccess.
This file should be in the directory which contains the documents to restrict access to. The contents of this file specify the name of the password file.

For example if you were user jdoe with web documents in the local directory "/home/jdoe/public_html/goodstuff" that you wanted to restrict access to, your .htaccess might look like:

AuthUserFile /home/jdoe/public_html/goodstuff/.htpasswd
AuthName jdoe_goodstuff
AuthType Basic

require valid-user

Note that .htaccess will not work if there are extra spaces after AuthUserFile.

The file .htpasswd.
This file contains the passwords of the users.

To create the .htpasswd file log in to this server using telnet, change directory to the directory you want to restrict access to, and type:

htpasswd -c .htpasswd someuser

for the first user (where someuser is the username). You will then be prompted twice for the user's password. The -c option causes the .htpasswd file to be created. For each additional user type:

htpasswd .htpasswd someuser

NOTE: There is no correspondence between the usernames and passwords used for accounts on this server and usernames and passwords in any specific .htpasswd file. A user doesn't need to have an account on this system in order to be validated for access to files protected by HTTP-based authentication.

timjpriebe's picture

He has: 2,667 posts

Joined: Dec 2004

Do you have some sort of control panel software on your server? Normally there's either a "password protect" option in there, or you may have to go through your control panel's file manager and protect it through there.

Forgive me, I'm not familiar with putty, except the silly kind. Smiling

They have: 96 posts

Joined: Jul 2005

I agree with Tim. I have a control panel with my hosting company and it takes 30 seconds to password protect any of my folders. You can also download PHP or CGI scripts for setting up Password.

If you need a script. Heres one at http://www.maaking.com/index.php?loadpage=scripts look for Users Login System (BETA).

Its free.

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.