From d1905ed9c6fda376dd9c637261716a4cd1694fc0 Mon Sep 17 00:00:00 2001 From: Shashwat Pratap Singh Date: Mon, 23 Nov 2026 11:50:23 +0530 Subject: [PATCH 1/2] docs: add admin password recovery with gotify user --- docs/first-login.md | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/docs/first-login.md b/docs/first-login.md index 8ce77ee..cb69fb4 100644 --- a/docs/first-login.md +++ b/docs/first-login.md @@ -5,3 +5,34 @@ After setting up gotify/server you can log in to the WebUI. On first launch an i Once logged in you can create your own user(s) and, if desired, delete the default account (after creating another administrator account). You can also remove any username/password overrides from your configuration, they are only used to create this initial account. If you keep the default account, be sure to change its password so it is not `admin`! + +## Reset a lost admin password + +If you lost the password of your admin account, you can recover it with the `gotify user` commands. +They use the same configuration as `gotify serve` (environment variables and config files), so run +them with the same configuration and from the same working directory as the server. + +```bash +# change the password, you'll be prompted for the new one +gotify user set-password admin + +# or create a new admin user +gotify user create --admin rescue + +# grant or revoke admin permissions +gotify user set-admin alice true +``` + +If you omit the password, it is prompted for. You can also pass it as the last argument, e.g. +`gotify user set-password admin newpassword`, but it may then show up in your shell history. + +In Docker, run the commands inside the container. Use `-it` so the password can be prompted for: + +```bash +docker exec -it gotify ./gotify-app user set-password admin +``` + +::: warning +With SQLite, the database may be locked while the server is running. If you get a `database is +locked` error, stop the server, run the command, and start the server again. +::: From 141b6f778862e876ae82703a7f4811e1c4f3701f Mon Sep 17 00:00:00 2001 From: Jannis Mattheis Date: Fri, 4 Dec 2026 20:28:41 +0100 Subject: [PATCH 2/2] fix: move to separate page --- .vitepress/config.ts | 1 + docs/first-login.md | 31 +--------------------------- docs/user-cli.md | 49 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+), 30 deletions(-) create mode 100644 docs/user-cli.md diff --git a/.vitepress/config.ts b/.vitepress/config.ts index d56214b..8af33c7 100644 --- a/.vitepress/config.ts +++ b/.vitepress/config.ts @@ -65,6 +65,7 @@ export default defineConfig({ text: 'Guides', items: [ {text: 'AI Agents (MCP)', link: '/docs/mcp'}, + {text: 'Manage users via CLI', link: '/docs/user-cli'}, {text: 'Migrate to 3.x', link: '/docs/migrate-to-3'}, {text: '(more) Push message examples', link: '/docs/more-pushmsg'}, {text: 'OpenID Connect', link: '/docs/oidc'}, diff --git a/docs/first-login.md b/docs/first-login.md index cb69fb4..38ee781 100644 --- a/docs/first-login.md +++ b/docs/first-login.md @@ -6,33 +6,4 @@ Once logged in you can create your own user(s) and, if desired, delete the defau If you keep the default account, be sure to change its password so it is not `admin`! -## Reset a lost admin password - -If you lost the password of your admin account, you can recover it with the `gotify user` commands. -They use the same configuration as `gotify serve` (environment variables and config files), so run -them with the same configuration and from the same working directory as the server. - -```bash -# change the password, you'll be prompted for the new one -gotify user set-password admin - -# or create a new admin user -gotify user create --admin rescue - -# grant or revoke admin permissions -gotify user set-admin alice true -``` - -If you omit the password, it is prompted for. You can also pass it as the last argument, e.g. -`gotify user set-password admin newpassword`, but it may then show up in your shell history. - -In Docker, run the commands inside the container. Use `-it` so the password can be prompted for: - -```bash -docker exec -it gotify ./gotify-app user set-password admin -``` - -::: warning -With SQLite, the database may be locked while the server is running. If you get a `database is -locked` error, stop the server, run the command, and start the server again. -::: +Lost the admin password? See [Manage users via CLI](/docs/user-cli). diff --git a/docs/user-cli.md b/docs/user-cli.md new file mode 100644 index 0000000..4a9b66e --- /dev/null +++ b/docs/user-cli.md @@ -0,0 +1,49 @@ +# Manage users via CLI + +The `gotify-server user` commands (available since 3.2.0) change users directly +in the database. Use them to recover access when you lost the admin password or +no admin account is left. + +::: warning +Stop the server before running the commands, Gotify may not work correctly when +users are changed while the server is running. +::: + +```bash +# change the password of a user +$ gotify-server user set-password admin + +# create a new user, --admin makes it an admin +$ gotify-server user create --admin rescue + +# grant or revoke admin permissions +$ gotify-server user set-admin alice true +``` + +Without a password argument, you are prompted for it. You can also pass it as +the last argument, e.g. `gotify-server user set-password admin newpassword`, +but it may then show up in your shell history. + +## Configuration + +The commands load the configuration as described in +[Configuration](/docs/config). Run them with the same configuration and in the +same working directory as the server. + +## Docker + +Run the command with the same image version, volumes, environment variables and +config file as your server. Otherwise it may use a different database or migrate +it to a newer version. + +```bash +# docker compose +$ docker compose stop +$ docker compose run --rm user set-password admin +$ docker compose start + +# docker +$ docker stop +$ docker run --rm -it -v /var/gotify/data:/app/data gotify/server: user set-password admin +$ docker start +```