Created
January 30, 2022 16:41
-
-
Save ben-kenney/798435e18a3800cb82766231771ea350 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Small script that will use htpasswd to hash a password | |
# This is useful for Traefik, especially if you don't want to install apache2-utils on your system | |
# It can be run using docker: | |
# docker container run -ti --rm -v $PWD:/data -w /data ubuntu:bionic bash -c "bash htpasswd.sh" | |
# hashed password will be stored in the file log.timestamp to ensure unique name | |
timestamp=$(date +%s) | |
fname="log.${timestamp}" | |
apt-get update | |
apt-get install -y apache2-utils | |
#echo $(htpasswd -nb testuser password) | sed -e s/\\$/\\$\\$/g >> log | |
echo "" | |
echo "Please enter a username, then we'll ask for a password which will be hashed" | |
read username | |
htpasswd -n ${username} >> ${fname} | |
echo "username and hashed password stored in file ${fname}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment