1
0
mirror of https://github.com/kremalicious/blog.git synced 2024-06-30 21:52:05 +02:00
blog/content/posts/2008-02-26-how-to-quickly-generate-encrypted-logins-on-a-mac-for-htaccess-protected-sites.md

37 lines
1.9 KiB
Markdown
Raw Normal View History

2013-11-18 23:54:59 +01:00
---
2018-07-19 02:22:01 +02:00
type: post
2013-12-09 23:29:19 +01:00
2013-11-18 23:54:59 +01:00
title: How to quickly generate encrypted .htpasswd passwords
2013-12-09 23:29:19 +01:00
author: Matthias Kretschmann
date: 2008-02-26 23:24:17+00:00
2018-07-19 02:22:01 +02:00
2018-08-30 22:50:09 +02:00
category:
2018-07-19 02:22:01 +02:00
2013-11-18 23:54:59 +01:00
tags:
2018-08-30 22:50:09 +02:00
- design
2018-07-19 02:22:01 +02:00
- tutorial
- macos
2016-04-16 22:22:02 +02:00
2017-11-14 18:12:44 +01:00
coinhive: true
2016-04-16 22:22:02 +02:00
redirect_from:
- /2008/02/how-to-quickly-generate-encrypted-logins-on-a-mac-for-htaccess-protected-sites/
2013-11-18 23:54:59 +01:00
---
2014-10-11 19:41:19 +02:00
As you may know you can easily password protect your website or parts of it using an htaccess file with special instructions on an [Apache](http://www.apache.org/)-based server. For using this method you just have to put a file named `.htaccess` (which includes the instructions for the webserver) and a file named `.htpasswd` (which includes the login-accounts) in the directory you want to have password protected. But you have to encrypt the passwords of the login data for yourself, which is a quick task on a Mac.
2013-11-18 23:54:59 +01:00
2014-10-11 19:41:19 +02:00
I won't go into detail what exactly is needed in your `.htaccess`, since it often depends on your hosting provider which instructions are allowed. If you are new to all this stuff and want to password protect your website or parts of it, have a look in the part [Password Protection](http://www.javascriptkit.com/howto/htaccess3.shtml) of the [Comprehensive guide to .htaccess written by Feyd](http://www.javascriptkit.com/howto/htaccess.shtml).
2013-11-18 23:54:59 +01:00
2013-12-09 23:29:19 +01:00
The login data, in detail just the password is stored encrypted in the .htpasswd-file but you have to encrypt it before writing it in this file. On a Mac you can benefit from the underlying [Unix](http://www.apple.com/macosx/technology/unix.html)-technology for quickly generating your login accounts using the commandline utility `htpasswd`.
2013-11-18 23:54:59 +01:00
Just open Terminal application and type in the following code and replace username and password with your desired data:
2018-09-29 02:54:31 +02:00
```bash
2013-12-09 23:29:19 +01:00
htpasswd -nb username password
```
2013-11-18 23:54:59 +01:00
2013-12-09 23:29:19 +01:00
and press enter. Terminal should output a new line containing your login data with an encrypted password. Just paste it in your `.htpasswd`-file and you're done.
2013-11-18 23:54:59 +01:00
2015-08-02 22:28:58 +02:00
It's that easy.