Skip to content

Instantly share code, notes, and snippets.

@ryan-blunden
Last active April 20, 2023 18:52
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save ryan-blunden/01742140f4a1418067ce5b4f850055af to your computer and use it in GitHub Desktop.
Save ryan-blunden/01742140f4a1418067ce5b4f850055af 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