Reset user password via CLI¶
The reset-password.py script allows administrators to reset a user's password directly in the database using the command line.
This is useful when a user has forgotten their password and there is no administrator that can initiate the password reset flow for them.
MongoDB provider only
This script only works for users stored in the default MongoDB provider. It does not work for users from external providers such as LDAP or Active Directory.
The script is not included in the SeaCat Auth Docker image. To run it, you need to download the script and copy it into the running container.
Prerequisites¶
- Log on to your LogMan.io node where SeaCat Auth service is running (the nodes are listed in your
model.yamlfile).
Step 1: Download the script¶
Download the script from the GitHub repository:
curl -O https://raw.githubusercontent.com/TeskaLabs/seacat-auth/main/scripts/reset-password.py
Step 2: Locate the SeaCat Auth container¶
Find the container in the list of running containers:
docker ps | grep seacat-auth
The container name should be in the format seacat-auth-<number>, for example seacat-auth-1.
Step 3: Copy the script into the container¶
Copy the downloaded script into the located SeaCat Auth container:
docker cp reset-password.py seacat-auth-1:/tmp/reset-password.py
Step 4: Execute the script¶
Run the script inside the container using docker exec:
docker exec -it seacat-auth-1 python3 /tmp/reset-password.py
The script will:
- Connect to MongoDB using the configuration of SeaCat Auth service
- Prompt you for the username to reset
- Display the matching user details for confirmation
- Ask for the new password (entered twice for verification)
- Update the password hash in the database
Step 5: Clean up (optional)¶
Remove the script from the container when done:
docker exec seacat-auth-1 rm /tmp/reset-password.py
Example session¶
$ curl -O https://raw.githubusercontent.com/TeskaLabs/seacat-auth/main/scripts/reset-password.py
$ docker cp reset-password.py seacat-auth-1:/tmp/reset-password.py
$ docker exec -it seacat-auth-1 python3 /tmp/reset-password.py
Enter username to reset password for: jsmith
User found:
ID: 6478a2b3c4d5e6f7a8b9c0d1
Username: jsmith
Email: john.smith@example.com
Phone: N/A
Suspended: False
Is this the correct user? [y/N]: y
Enter new password:
Confirm new password:
Password successfully updated for user 'jsmith'.