Skip to content

Instantly share code, notes, and snippets.

@mgraupner
Last active September 28, 2021 10:22
Show Gist options
  • Save mgraupner/e061079e96669b7b4ff2d1e64619f15a to your computer and use it in GitHub Desktop.
Save mgraupner/e061079e96669b7b4ff2d1e64619f15a to your computer and use it in GitHub Desktop.
Create a Caddy 2 server HTTP Basic Authentication password
As there are no clear instructions on the Caddy Homepage on how to create a password
(without their own caddy tool, which might not be available) in the needed format,
I compiled a short list on how to do it the right way:
Replace password with your own password!
Create a BCrypt encrypted password in 10 rounds
htpasswd -bnBC 10 "" password
->
:$2y$10$ow7UC86yXaSoZSr0mcGxeOYK9DfqsnKnA9RoKR.nxUUXVbXqOibgm
Remove the ":" and replace the "$2y" with "$2a"
->
$2a$10$ow7UC86yXaSoZSr0mcGxeOYK9DfqsnKnA9RoKR.nxUUXVbXqOibgm
base64 encode the encrypted password and remove all newlines
printf '$2a$10$ow7UC86yXaSoZSr0mcGxeOYK9DfqsnKnA9RoKR.nxUUXVbXqOibgm' | base64 | tr -d '\n'
->
JDJhJDEwJG93N1VDODZ5WGFTb1pTcjBtY0d4ZU9ZSzlEZnFzbktuQTlSb0tSLm54VVVYVmJYcU9pYmdt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment