maxuru ~ % cat grafana/change-the-admin-password
Change the Grafana admin password
/etc/grafana/grafana.ini[security]admin_user = grafana_adminadmin_password = $__env{GF_SECURITY_ADMIN_PASSWORD}sudo grafana-cli admin reset-admin-password "$(openssl rand -base64 24)"What the default is
Section titled “What the default is”Straight from Grafana’s defaults.ini:
admin_user = adminadmin_password = adminThe admin account is a Grafana Server Admin — the highest privilege level
there is. It manages every organisation, every user, and every data source,
which means it also holds the ability to read from and write to the systems
those data sources point at.
Grafana prompts for a change at first login. That prompt is the reason this is
widely assumed to be handled, and the reason it frequently is not: it can be
dismissed, and it only applies to interactive first logins. An instance
provisioned by configuration management, started from a container image, or
brought up as part of a stack nobody logged into individually keeps
admin/admin indefinitely.
Change the username too
Section titled “Change the username too”admin_user = admin is as predictable as the password, and a known username
halves the work for anyone attempting credentials. Renaming it does not stop a
determined attacker — it does remove you from the bucket that automated
credential stuffing is aimed at.
Brute-force protection is on by default
(disable_brute_force_login_protection = false, five attempts), so a slow
guessing attack is already constrained. That is a reason to relax about
throttling, not about the default password — protection against guessing does
not help when the credential does not need to be guessed.
Keep the password out of the file
Section titled “Keep the password out of the file”grafana.ini is readable by the grafana user and lands in configuration
management, backups and container images. Grafana supports environment
interpolation so the value need not be in the file:
admin_password = $__env{GF_SECURITY_ADMIN_PASSWORD}In containers the environment variable alone is enough — GF_SECURITY_ADMIN_PASSWORD
overrides the file with no grafana.ini change at all. Make sure it comes from
a secret store rather than a committed compose file, since
docker inspect prints the environment of a running container to anyone in the
docker group — which is root on the host.
Better: don’t use the admin account
Section titled “Better: don’t use the admin account”The shared admin login is a break-glass account. Day-to-day access should be
individual accounts, ideally from your identity provider (OAuth, SAML or LDAP),
so that access is revoked when someone leaves and actions are attributable.
Grafana can be told not to create the built-in admin at all when an external provider is in place:
[security]disable_initial_admin_creation = trueOnly do this once external authentication is confirmed working. Setting it on a fresh instance with no other login path produces a Grafana nobody can get into.
Related
Section titled “Related”- Rotate the Grafana secret key — the default that matters more than this one.
- Data source credential theft — what an admin session is actually worth.