On occasion, a primary SmarterMail administrator may need to reset their own login credentials or the login credentials for a secondary administrator account that manages the entire SmarterMail installation. This is useful if the primary administrator has lost their password or if the login credentials have fallen into the wrong hands.
NOTE: If you use a hosted SmarterMail and need to reset your Domain Administrator or user password, please contact your hosting provider directly. These steps are for resetting a system administrator's account credentials and require access to the server where SmarterMail is installed.
Follow these steps to reset an administrator's password back to the default configuration:
- Stop the SmarterMail service
- Make a backup copy of the administrators.json file
- Edit the file (for the admin user you are working with) with your editor of choice and replace the >password_hash line with the following password hash. (Note that you should not simply delete the existing password hash without replacing it with the following. Otherwise, the administrator will not be able to log in.)
- Save and exit the editor.
- Restart the SmarterMail service.
After completing this process, the administrator account you modified will be able to log in to SmarterMail using their username and the default password "admin" (without the quotes). That administrator should immediately go to Settings > Administrators and change their password to something more secure.
Using JQ instead of NANO
Here is a way to do this without having to use nano. This uses jq to parse the file and replace the password.
Install jq.
sudo apt install jq
Set up the variables needed.
file="/etc/smartermail/administrators.json"
backup="${file}.BACKUP.$(date +'%Y-%m-%d_%H-%M-%S')"tmp=$(sudo mktemp /etc/smartermail/administrators.json.tmp.XXXXXX)
tmp_pass='1000:7Zf5bDhx+pB+3pSt9bFzbnnn9uiZi25P:+esCLUvFa/lw8c1+UMk+guGeHFfQ7Asc'
Back up your administrators.json file.
sudo cp -a "$file" "$backup"
Stop the service
sudo systemctl stop smartermail
Write to the temp file
sudo jq --arg p "$tmp_pass" '(.administrators[] | select(.username == "admin") | .password_hash) = $p' "$file"
Copy the permissions of the file over to the temporary file.
sudo chown --reference="$file" "$tmp" && sudo chmod --reference="$file" "$tmp"
Override the original file
sudo mv "$tmp" "$file"
Start the service backup
sudo systemctl start smartermail
If you encounter an error, you can check the status of the service
sudo systemctl status smartermail --no-pager
Check the logs as well
sudo journalctl -u smartermail.service -r --since="1 day ago"
You can also restore the file if needed.
sudo systemctl start smartermail
sudo cp -a "$backup" "$file"
sudo systemctl start smartermail