internet.com

 


hm-v6-139x61.gif

Database Journal: The Knowledge Center for Database Professionals

find a web host with:
CGI Access
DB Support
NT Servers
UNIX Servers
Telnet Access

advanced search
jobs

Get FREE Development Info via your Email!

The Webdeveloper channel
FlashKit
GIF.com
HiermenusCentral
webdeveloper Jobs
Java Boutique
JavaScript.com
JavaScript Source
ScriptSearch
StreamingMedia World
WDJ
WDVL
WebDeveloper.com
WebReference.com
XMLFiles.com

internet.com
Internet News
Internet Investing
Internet Technology
Windows Internet Tech.
Linux/Open Source
Web Developer
ECommerce/Marketing
ISP Resources
ASP Resources
Wireless Internet
Downloads
Internet Resources
Internet Lists
International
EarthWeb
Career Resources

Search internet.com
Advertise
Corporate Info
Newsletters
E-mail Offers

internet.commerce
Be a Commerce Partner










S E C U R I T Y
WebDeveloper.com

Protecting Your Pages
(Part 2)

By Nathan Poole

Setting up htpasswd

The htpasswd program is a little more complicated to setup than Allow/Deny. It does require a little more work, a little more typing, and most of all, a little more concentration.

To get started you'll need to open a telnet session to your server (in Windows 9x you can go Start -> Run then type telnet your_host.com).

Once logged in, you'll need to create a directory (syntax: mkdir directory_name) which you would like to protect from non-authorized users (that is, a directory accessible by members only).

You'll need to create an .htaccess file (syntax: vi .htaccess) and open it for writing (hit your "I" key) and print the following:

AuthUserFile /your/path/to/your/directory/.htpasswd
AuthGroupFile /dev/null
AuthName ByPassword
AuthType Basic


require user myfriend

Note Where it is written "/your/path/to/your/directory/" you'll need to insert the path of your htpasswd file. You can see which directory you're in by typing pwd at the prompt. You'll then need to hit your ESC key and type :x.

Now you should be back at the UNIX shell prompt and you'll need to type /usr/local/bin/htpasswd -c .htpasswd myfriend (assuming myfriend is the user you're wanting to create). If the above results in a response of "not found" type "whereis htpasswd" and use the output in place of the previous directory shown. It will ask you for a password once, and then again. Try loading the directory and you should be promted with a dialog box.

Conclusion

In this tutorial you have learnt how to protect directories using user authentication. These skills can be applied to many situations and add a little more security to your Web site. You have also been exposed to a few UNIX commands that are vital to programming such features on the World Wide Web. If you're looking to create other users using htpasswd, you just need to type /path/to/htpasswd username, replacing username with the required login.

[ Click here to go back to the start of the article ]

This article first appeared January 15, 1999.

Fast Jump to Anywhere on WebDeveloper.com®:


Contact the WebDeveloper.com® staff

Last modified: 20

 


Browse by Category
[ Site Map ]

ActiveX / VBscript
Animated GIF Archive
Browsers
CGI / Perl
Database Connectivity
Design / Graphics
E-Commerce
HTML-Advanced: DHTML, CSS
HTML / Site Authoring Tools
Intranet/Groupware
Java
JavaScript
Multimedia: Audio / Video / Streaming Technologies
Opinions
Refresh Daily: Editorial Column
Security
Servers & Server Tools
Site Design / Graphics
Site Management / Marketing / Log File Analysis
Tutorials
VRML / 3D
XML


internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs