Skip to content

Instantly share code, notes, and snippets.

@schams-net
Created November 20, 2021 22:55
Show Gist options
  • Save schams-net/a44343713993ad6a78bdafedae46e4a2 to your computer and use it in GitHub Desktop.
Save schams-net/a44343713993ad6a78bdafedae46e4a2 to your computer and use it in GitHub Desktop.
Set a new BE user password (Argon2-hashed)
#!/bin/bash
RANDOM_PASSWORD=$(tr -cd '[:alnum:]' < /dev/urandom | fold -w16 | head -n1)
ARGON2_PASSWORD=$(php -r "echo password_hash('${RANDOM_PASSWORD}', PASSWORD_ARGON2I, ['memory_cost' => 64000, 'time_cost' => 30, 'threads' => 4]);")
echo -e "Password:\t${RANDOM_PASSWORD}\nArgon2 Hash:\t${ARGON2_PASSWORD}"
mysql -e "UPDATE be_users SET password = '${ARGON2_PASSWORD}' WHERE uid = 1"
mysql -e "SELECT uid, username, password FROM be_users WHERE uid = 1"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment