Requirements
- NervesHub 2.5.4 or later.
SECRETS_ENCRYPTION_KEYset on the instance. The key encrypts each user’s authenticator secret. Without it, two-factor authentication is not offered and no organization can require it. See Feature prerequisites.
Turn it on for your account
1
Open your account page
Open your account page. Under Two-factor authentication, click Set up.
2
Start setup
Click Set up two-factor authentication. If you have not signed in within the last 10 minutes, NervesHub asks you to confirm your identity first.
3
Add NervesHub to your authenticator app
Scan the QR code with your app. If you cannot scan it, type the key shown beside it into the app by hand.
4
Confirm with a code
Type the six-digit code the app shows and click Turn on. You have 10 minutes from starting setup to finish.
5
Save your recovery codes
NervesHub shows ten recovery codes. Use Copy or Download to keep them somewhere safe, such as a password manager, then click I’ve saved them. They are not shown again.
Sign in with a code
After your password or Google sign-in, NervesHub asks for an Authentication code. Type the six-digit code from your app and click Verify.- Each code works once.
- A code from the 30 seconds before or after the current one is accepted, for clocks that drift.
- You get five tries every ten minutes.
Recovery codes
Each of the ten recovery codes signs you in once without your app. At the sign-in step, click Use a recovery code instead and type one in. Your account’s Two-factor authentication page shows how many codes you have left. To replace them, click Manage on your account page, enter a code from the app or a recovery code under New recovery codes, and click Make new codes. The old codes stop working.Turn it off
On your account’s Two-factor authentication page, enter a code from the app or a recovery code under Turn off two-factor authentication and click Turn off. If an organization you belong to requires two-factor authentication, you cannot reach that organization until you turn it back on. Your account and your other organizations work as before.Require it for an organization
You need the built-in Admin role, and two-factor authentication on for your own account.1
Open the organization's settings
Open your organization and select the Settings tab.
2
Turn the requirement on
Under Two-factor authentication, tick Require two-factor authentication for every member. The page lists the members who do not have it on yet and would be turned away.
3
Save
Click Save.
- NervesHub emails every other member. Members without two-factor authentication are asked to set it up.
- A member without it is sent to their Two-factor authentication page when they open the organization.
- Until they turn it on, the organization’s API, remote consoles, local shells, device event streams and Slack actions refuse them.
- Pages and consoles they have open in the organization close.
Effect on the API and CLI
- Password sign-in to the API is refused.
POST /api/users/authanswers401for an account with two-factor authentication on. That is the endpointnh user authuses, so it fails too. Sign in through the browser withnh user login, or use an access token. See API authentication. - Organization requirement. API requests for an organization that requires two-factor authentication answer
403for a member who does not have it on. The message names the organization and says to turn it on.

