Lesson 2.3: Passwords, resets and lockouts
"I cannot sign in" is the support call an administrator gets most. This lesson goes through every supported way to change or reset a password, what happens to the user's sessions afterwards, and how to unlock an account that was locked after too many failed sign-ins.
At a glance
| Course | Site administration |
| Module | Module 2: Users and groups |
| Duration | 45 minutes (15 presenting, 30 exercise) |
| Level | Intermediate |
| Audience | Site administrators and support staff |
| Prerequisites | Lesson 2.2: the users tess.trainee and sam.sample; a terminal in the installation root |
Learning objectives
After this lesson, learners can:
- change their own password on
user/password; - set a new password for another user from the user's edit form;
- explain how Forgot your password? works and when it cannot help;
- reset a password on the command line with
resetuserpassword.php; - unlock an account locked by failed sign-ins.
Trainer's notes
How to present it
Source: Change the administrator password and Reset a user password from the command line.
- Your own password (3 minutes). In admin4, the user menu (the button with your name in the header) > Change password. The page lists the requirements and ticks them off while you type; Generate a strong password makes one.
- Someone else's password (3 minutes). Open the user, Edit, type the new password twice in the User account field, Send for publishing. Better: let the user use Forgot your password? so that you never know their password.
- What follows a change (3 minutes). With
[PasswordSettings] EndOtherSessions=enabled(the default) the user's other sessions are signed out at their next request; withChangeNotificationMail=enabledthe user gets "Your password was changed", which never contains the password. The change is in the audit trail. - Forgot your password? (2 minutes). The link in the mail works once and for one hour
(
ForgotPasswordKeyLifetime=3600). It needs a real address and working mail, so it never works on a training site withexample.invalidaddresses. - Command line and lockouts (4 minutes).
bin/php/resetuserpassword.php(alsoexp:resetuserpassword) works when nobody can sign in. Failed sign-ins lock an account only when[UserSettings] MaxNumberOfFailedLoginis above 0; the shipped value is 0 (no lock).
Common questions
Why does a password given with -p worry you? It is visible in the process list and the shell history. Prefer
-g to generate one, which is printed once.
Can an administrator see a user's password? No. Passwords are stored as hashes; nobody can read them back.
The user says nobody changed their password, but they got the mail. Treat it as a possible attack: check the audit trail and change the password again.
Pitfalls
- Lockout of the trainer. If learners set
MaxNumberOfFailedLoginand then mistype the administrator password, they lock themselves out. Keep the exercise onsam.sampleand keep a second administrator session open. - Running the script as root. As the operating system root user it needs
--allow-root-user; otherwise use-aand-apwith an administrator's login, which puts that password in the history too.
Hands-on exercise
On your training installation, signed in as an administrator, with a terminal in the installation root:
Open the user menu with your name in the header and choose Change password. Read the listed requirements; press Generate a strong password, look at it, and leave the page without saving.
Open
tess.trainee, press Edit, type a new password twice in the User account field and press Send for publishing.In a terminal, generate a new password for
sam.sample:php bin/php/resetuserpassword.php --allow-root-user -u sam.sample -g -l 20(Run it without
--allow-root-userand with-a <your login> -ap '<your password>'if you are not root.)Sign in to the public site as
sam.samplewith the printed password, in a private window. Then sign out.Switch on locking for the lab only, and clear the INI cache:
php bin/php/console exp:ini set site.ini/UserSettings/MaxNumberOfFailedLogin 3 global php bin/php/ezcache.php --clear-tag=iniIn the private window, try to sign in as
sam.samplewith a wrong password four times. Then try the right one.As the administrator, open
sam.sampleand Configure user account settings. Read the number of failed attempts and press Reset.Sign in as
sam.samplewith the right password again.Switch locking off again:
php bin/php/console exp:ini rem site.ini/UserSettings/MaxNumberOfFailedLogin global php bin/php/ezcache.php --clear-tag=ini
Expected result
- Step 3 prints one generated password of 20 characters.
- Step 6: after more failed attempts than the setting allows, the right password is refused too; the account is locked.
- Step 7 shows the failed attempts; after Reset the sign-in of step 8 works.
- After step 9,
exp:ini where site.ini/UserSettings/MaxNumberOfFailedLoginshows the default 0 in effect. - The trainer checks the audit records later in the course, or asks a learner to show step 7.

Quiz
- How long does a Forgot your password? link work on a new installation? A. 10 minutes B. one hour C. one day D. until used
- What happens to a user's other sessions when an administrator changes the password?
- Why prefer
-gto-pwithresetuserpassword.php? - With the shipped settings, does an account lock after ten wrong passwords? Why?
- Name two places where an administrator can clear an account's failed sign-ins.
Answers
- B.
ForgotPasswordKeyLifetime=3600seconds (Forgot your password?). - They are signed out at their next request (
EndOtherSessions=enabled). - A password on the command line stays in the process list and the shell history.
- No.
MaxNumberOfFailedLoginis 0 as shipped, which means no lock. - Reset on Configure user account settings, and Unlock on Check user accounts (lesson 2.4).
Further reading
- Change the administrator password: every way, and what to do when locked out.
- Reset a user password from the command line: the script's options and errors.
- Changing your password: the rules and the mail.
- Sessions: ending every session after a suspected compromise.
Related pages
- Module 2: Users and groups
- Site administration: course overview
- Trainers: start here
- Free documentation: this page is free to copy, translate and improve under the GNU FDL 1.3.
Become an Exponential Partner
Partners share their information, provide funding, contribute back and develop the products with us, and that is how Exponential grows. A partner website and dashboard are planned for mid-2027: please become a partner today to speed up our growth rate and land new features faster.