Skip to content

Instantly share code, notes, and snippets.

@filterfish
Last active January 16, 2016 14:11
Show Gist options
  • 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