Webserver such as Nginx / Lighttpd accepets passwords using encoded method i.e. function crypt(3) is needs. You can create the password file with the htpasswd program from Apache. Sometime Apache is not installed use the following perl script to create password.
How do I use crypt.pl?
Download script
Set permissions:
chmod +x crypt.pl
./crypt.pl mySecrete
Sample Output:
$1$mySecret$TQgDKW6xpDmEUyxm5ZDxv/
Now you can create htpasswd file for lighttpd or nginx:
user:$1$mySecret$TQgDKW6xpDmEUyxm5ZDxv/
Perl script to replace htpasswd
#!/usr/bin/perl use strict; my $passWord=$ARGV[0]; print crypt($passWord,$passWord)."\n";
- RSS feed or Weekly email newsletter
- Share on Twitter • Facebook • 5 comments... add one ↓
Category | List of Unix and Linux commands |
---|---|
File Management | cat |
Firewall | Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04 |
Network Utilities | dig • host • ip • nmap |
OpenVPN | CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04 |
Package Manager | apk • apt |
Processes Management | bg • chroot • cron • disown • fg • jobs • killall • kill • pidof • pstree • pwdx • time |
Searching | grep • whereis • which |
User Information | groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w |
WireGuard VPN | Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04 |
Thanks, this article and the anon comment inspired me to take it a step further:
This is now super easy to use and it will always append the record to the file. Enjoy!
Thanks for sharing updated version :)
Thanks, this article and the anon comment inspired me to take it a step further:
This is now super easy to use and it will always append the record to the file. Enjoy!
I use this script:
#!/usr/bin/perl
use strict;
chomp(my $username=$ARGV[0]);
chomp(my $password=$ARGV[1]);
print $username.":".crypt($password,$username)."\n";
In this script $password – main string for password generation, and $username – salt.
You can use it like that:
./htpasswd.pl user password > .htpasswd
cat .htpasswd
user:usjRS48E8ZADM
Thank you very much for this one. Worked perfectly.