So I was pretty dumb and I installed Stalwart and thought I took a note of the password they give you in the terminal – and didn’t. So then I had the choice of either wiping out my install and starting again, or learning a new skill.
The first thing I tried to do, which failed, was this:
sudo nano /var/lib/stalwart-mail/etc/config.toml
Then, I found the only thing which looked like an admin password, which was a very scary looking string besides the entry authentication.fallback-admin.secret = "scarylongstringhere"
Then I grabbed that thing, entered ‘admin’ as my user name and pasted that in as password on the Stalwart user login page…
EPIC FAIL!
Then I asked the nice community in the Stalwart Matrix group over at #stalwartmail:matrix.org
. Super great community, by the way!
They were probably asleep in Europe and my patience level is always too low to wait more than 10 minutes so…I began searching again.
Then, thankfully, I read this forum post and it sounded like this might be possible with a few more skills.
Good news. New skills are good. I was successful. And here is the exact process for anyone else who might find themselves in the same situation:
Hope this helps
- Choose a new admin password.
- Save that password in a good place so you don’t make the same mistake twice…
- Open a terminal – on the machine with your Stalwart server – and punch in this command:
openssl passwd -6
- It will ask you for a password. Enter the password you chose in step 1 above
- It will then ask you to re-enter the password. Obey. Do not resist. It is for your own good, my son…
- It will then reply back to you with a long scary ‘hashed’ version of the password you chose.
- Copy that hashed password to clipboard
- Edit the config.toml file of your Stalwart server. My path may be different from yours but if you followed the documentation exactly, like I did, it will be the same. Edit like this, and adjust path as necessary:
sudo nano /var/lib/stalwart-mail/etc/config.toml
- In that top entry called ‘authentication.fallback-admin.secret`, carefully erase the string, but only everything in between the double quotes (you need to keep the double quotes)
- Go back to your newly-created hashed version of your new password from step 7 above and paste that in between the double quotes where the old one was. Be careful not to leave any spaces.
- Hit control x to exit the file
- Yes to save changes
- Then restart docker (it seems I had to before it would begin to work) with this command:
sudo systemctl restart docker
- Then, start Stalwart-mail again because I guess it stops when you restart Docker:
sudo docker start stalwart-mail
- Go back to your admin page to try logging in with user
admin
and your newly created NON-hashed password (ie. do NOT try to log in with the long scary version like I did, it won’t work)
Hope this helps!