Forked from movd/create_docker_compose_basic_auth_string_for_traefik.sh
Created
February 24, 2022 20:59
-
-
Save kermitsxb/634938939f486e213be12bfa8a201a92 to your computer and use it in GitHub Desktop.
Generator to create basic authentication string for traefik (docker-compose.yml and .env)
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
#!/usr/bin/env bash | |
command -v docker >/dev/null 2>&1 || { echo >&2 "I require Docker but it's not installed. Aborting."; exit 1; } | |
echo "Basic auth for traefik >= v1.7" | |
read -p "User: " USER | |
read -p "Password: " PW | |
# Pull httpd:alpine image (small and includes httpasswd) | |
docker pull httpd:alpine >/dev/null 2>&1 | |
# Generate strings | |
echo "------- Your string for configuration file (YAML/TOML) --------" | |
string=$(docker run --rm -i -t httpd:alpine htpasswd -nbB $USER $PW) | |
echo $string | |
echo "------- Your string for docker-compose.yml --------" | |
# Escape string | |
echo "$string" | sed -e 's/\$/\$\$/g' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment