Set up two-factor authentication
Two-factor authentication (2FA) asks users for a one-time password (OTP) after their password. A stolen password alone is then not enough to log in.
Prerequisites
- The System Manager role.
- For SMS: working SMS settings.
- For Email: a working outgoing email account.
Turn on two-factor authentication
- Open System Settings and open the Login tab.
- In Two Factor Authentication, select Enable Two Factor Auth.
- In Two Factor Authentication method, select one:
- OTP App: users get codes from an authenticator app, such as Google Authenticator.
- SMS: users get the code by text message.
- Email: users get the code by email.
- For OTP App, set Expiry time of QR Code Image Page in seconds (240 or more) and the OTP Issuer Name that users see in their app.
- For SMS, check the OTP SMS Template.
- Save.
Choose the roles that need two-factor authentication
Two-factor authentication applies to the users whose roles have Two Factor Authentication selected.
- Open the Role list and open a role.
- Select or clear Two Factor Authentication.
- Save.
To require it for every user, select it on the role All. To require it for some users only, clear it on All and select it on the roles that need it, for example Accounts Manager.
Two-factor authentication does not apply to website users or to API logins.
What the user does at the first login
With OTP App, the first time a user logs in after setup:
- ERPNext emails the user a link to a QR code.
- The user opens the link and scans the QR code with an authenticator app.
- The app shows a new code every few seconds. The user enters the current code to log in.
With SMS or Email, the user receives a code at each login.
Troubleshooting
The code is rejected
Codes from an authenticator app depend on the time of the device. Set the phone to automatic time, so that it matches the server time.
A user changed their phone
Open the user and select Reset OTP Secret. At the next login, the user gets a new QR code.