Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mahmoud-samy/a4d49380bd560331c71274d3523d6d8f to your computer and use it in GitHub Desktop.
Save mahmoud-samy/a4d49380bd560331c71274d3523d6d8f to your computer and use it in GitHub Desktop.
Instructions for resetting the Sourcegraph admin password

Presuming you have access to the Sourcegraph Docker container and the container name is sourcegraph:

  1. Get the id for the admin account (should be 1 in most cases):
docker container exec sourcegraph psql -U postgres sourcegraph -c 'SELECT id, username, passwd FROM users'
  1. Set the $ID variable:
ID='VALUE'
  1. Go to https://bcrypt-generator.com/ and generate a hash with Rounds set to 10.

  2. Set the $HASH variable (surround with single quotes):

HASH='VALUE'
  1. Execute the SQL query to update the users database table with the new password:
docker container exec sourcegraph psql -U postgres sourcegraph -c "UPDATE users SET passwd_reset_code=NULL, passwd_reset_time=NULL, passwd='${HASH}' WHERE id=${ID};"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment