Skip to content

Instantly share code, notes, and snippets.

@filterfish
Last active January 16, 2016 14:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save filterfish/9e1250d8811a3e73a727 to your computer and use it in GitHub Desktop.
Save filterfish/9e1250d8811a3e73a727 to your computer and use it in GitHub Desktop.
Simple script to reset a user's password
#!/bin/zsh
username=$1
password=$2
db=synapse-homeserver
[[ -z $username ]] || [[ -z $password ]] && { print "usage: $0 <username> <password>"; exit; }
password_hash=$(python -c "import bcrypt; print bcrypt.hashpw(\"$password\", bcrypt.gensalt())")
echo $password_hash
psql -c "update users set password_hash = '$password_hash' where name = '$username'" $db
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment