netbirdio / netbird

Connect your devices into a secure WireGuard®-based overlay network with SSO, MFA and granular access controls.
https://netbird.io
BSD 3-Clause "New" or "Revised" License
11.15k stars 513 forks source link

Improve documentation - how to retrieve the admin password #1927

Open gecube opened 6 months ago

gecube commented 6 months ago

Good day!

I have a great idea how to improve the documentation. I faced the issue that admin password was lost when installing Netbird + Zitadel self-hosted. Unfortunately, I did not find any way to retrieve it or at least to make a recovery and set up the new one. Sounds weird. I will very appreciate if somebody can describe the procedure and then we could put it to official documentation of Netbird. For me the reinstallation from scratch will work, but it is not the case for everybody, particularly if you already did a lot of settings.

eoksum commented 1 month ago

I'm unfortunately encountering the same issue now. I unfortunately cannot find a way to recover the admin account password now. Unfortunately I've done some settings that I don't want to lose.

mlsmaycon commented 1 month ago

@eoksum the post-install password is stored in the .env file, but after your login that password gets changed. So is very unlikely to be useful.

I am not sure how to reset Zitadel's password, they probably rely on reset password link and SMTP which can be configured via environment variables in Zitadel. You might need to update Zitadel's database to configure the correct email address for the admin account once you have SMTP working.

gecube commented 1 month ago

@eoksum please let me know if you will find some solution.

eoksum commented 1 month ago

@eoksum the post-install password is stored in the .env file, but after your login that password gets changed. So is very unlikely to be useful.

I am not sure how to reset Zitadel's password, they probably rely on reset password link and SMTP which can be configured via environment variables in Zitadel. You might need to update Zitadel's database to configure the correct email address for the admin account once you have SMTP working.

Dear @mlsmaycon thank you for your response. I couldn't get shell from Zitadel's container because it doesn't seem to have neither sh nor bash in it. Can you please provide documentation on how can I access Zitadel's database?

Best regards.

mlsmaycon commented 1 month ago

It depends on which database you are using. If you used the quick start script, you are probably using the postgres database which can be accessed with:

docker compose exec -ti zdb bash

The credentials will be in either zdb.env or zitadel.env files.

I recommend you to reach out to Zitadel's community:

eoksum commented 1 month ago

Dear @mlsmaycon the Docker command you've provided worked and I was able to get into the PostgreSQL database with psql command and db credentials I obtained from /root/zitadel.env file however unfortunately I couldn't locate neither config table, nor users table.

Here goes the commands that I've executed to get access into PostgreSQL database but came out empty handed. Perhaps it might help someone.

` root@netbird:\~# docker compose exec -ti zdb bash WARN[0000] /root/docker-compose.yml: the attribute version is obsolete, it will be ignored, please remove it to avoid potential confusion 100bc4bbd776:/# 100bc4bbd776:\~# psql -h zdb -U root -d zitadel Password for user root: psql (16.4) Type "help" for help.

zitadel-# \c zitadel You are now connected to database "zitadel" as user "root".

zitadel-# \dt *.* List of relations Schema | Name | Type | Owner
--------------------+-----------------------------------+-------------+--------- adminapi | current_sequences | table | zitadel adminapi | failed_events | table | zitadel adminapi | locks | table | zitadel adminapi | styling | table | zitadel adminapi | styling2 | table | zitadel auth | auth_requests | table | zitadel auth | current_sequences | table | zitadel auth | failed_events | table | zitadel auth | idp_configs | table | zitadel auth | idp_configs2 | table | zitadel auth | idp_providers | table | zitadel auth | idp_providers2 | table | zitadel auth | locks | table | zitadel auth | org_project_mapping | table | zitadel auth | org_project_mapping2 | table | zitadel auth | refresh_tokens | table | zitadel auth | tokens | table | zitadel auth | user_external_idps | table | zitadel auth | user_external_idps2 | table | zitadel auth | user_sessions | table | zitadel auth | users | table | zitadel auth | users2 | table | zitadel auth | users3 | table | zitadel eventstore | events2 | table | zitadel eventstore | unique_constraints | table | zitadel information_schema | sql_features | table | root information_schema | sql_implementation_info | table | root information_schema | sql_parts | table | root information_schema | sql_sizing | table | root logstore | access | table | zitadel logstore | execution | table | zitadel pg_catalog | pg_aggregate | table | root pg_catalog | pg_am | table | root pg_catalog | pg_amop | table | root pg_catalog | pg_amproc | table | root pg_catalog | pg_attrdef | table | root pg_catalog | pg_attribute | table | root pg_catalog | pg_auth_members | table | root


REDACTED SOME COMMANDS, users and users2 was empty tables. I've seen some users in users3 table but I did not see any field for hashed passwords. I've also checked tokens, idp_config(s) and styling tables however I did not see any field for SMTP configuration or hashed passwords.


zitadel=# exit 100bc4bbd776:\~# exit exit root@netbird:\~# `