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 8ce77ee..38ee781 100644 --- a/docs/first-login.md +++ b/docs/first-login.md @@ -5,3 +5,5 @@ 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`! + +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 +```