From 6586e6e968366cd41a854a12f2965f6db8761784 Mon Sep 17 00:00:00 2001 From: Lucas Rattz <41240438+lucasrattz@users.noreply.github.com> Date: Sat, 31 May 2025 20:17:17 -0300 Subject: [PATCH] Tag versions, docker run version --- How_to_generate_an_bcrypt_hash.md | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/How_to_generate_an_bcrypt_hash.md b/How_to_generate_an_bcrypt_hash.md index 6693654b..e47f525f 100644 --- a/How_to_generate_an_bcrypt_hash.md +++ b/How_to_generate_an_bcrypt_hash.md @@ -7,19 +7,23 @@ Since version 14 of wg-easy, a password hashed with bcrypt is needed instead of The easiest way to generate a bcrypt password hash with wgpw is using docker and node: ```sh -docker run ghcr.io/wg-easy/wg-easy node -e 'const bcrypt = require("bcryptjs"); const hash = bcrypt.hashSync("YOUR_PASSWORD", 10); console.log(hash.replace(/\$/g, "$$$$"));' +docker run ghcr.io/wg-easy/wg-easy:14 node -e 'const bcrypt = require("bcryptjs"); const hash = bcrypt.hashSync("YOUR_PASSWORD", 10); console.log(hash.replace(/\$/g, "$$$$"));' ``` -The hashed password will get printed on your terminal. Copy it and use on the `PASSWORD_HASH` environment variable. +The hashed password will get printed on your terminal. Copy it and use on the `PASSWORD_HASH` environment variable in your docker compose. -If you are using `docker run` for running wg-easy, you must enclose the hash string in single quotes (`'...'`). +If you are using `docker run` instead of docker compose for running wg-easy, you must enclose the hash string in single quotes (`'...'`) and unescape the dollar signs. You can use this command instead: + +```sh +docker run --rm ghcr.io/wg-easy/wg-easy:14 node -e "const bcrypt = require('bcryptjs'); const hash = bcrypt.hashSync('YOUR_PASSWORD', 10); console.log('\'' + hash + '\'');" +``` ## Using Docker + wgpw `wg-password` (wgpw) is a script that generates bcrypt password hashes. You can use it with docker: ```sh -docker run ghcr.io/wg-easy/wg-easy wgpw YOUR_PASSWORD +docker run ghcr.io/wg-easy/wg-easy:14 wgpw YOUR_PASSWORD ``` You will see an output similar to this: