Personal administrators and two-factor authentication; lost phone

At John Smith Ltd three people work on the appliance: Laura White, the IT administrator; Paul Black, the technician who looks after the network; and Jack Green, a technician who leaves the company…

Situation

At John Smith Ltd three people work on the appliance: Laura White, the IT administrator; Paul Black, the technician who looks after the network; and Jack Green, a technician who leaves the company at the end of the month. So far all three signed in as root, with the same password.

That way nobody knows who did what, and when Jack leaves everybody’s password has to change. In this scenario you give each of them a personal account, with their own second factor; you disable the account of the one who leaves; and you see how to get back in when someone loses their phone.

What you need

  • Access to the console as root (or as another administrator), from a PC on the office LAN: https://192.168.10.1/.
  • For each person: their full name, and a smartphone with a TOTP app (Atlas Caveau, EDON Atlas’s password manager, which also generates TOTP codes; Google Authenticator, Microsoft Authenticator, FreeOTP, 1Password…).
  • For the extreme case of the lost phone: a shell on the appliance, that is a keyboard and screen connected to it, or SSH from the LAN.

Steps

Creating the personal accounts

  1. Open System → Users. The list has the columns “Account name”, “Full name”, “uid”, “console”, “2FA” and “State”. At first there is only root.

  2. Press “Add user” (the “+” button on the right of the list’s bar). “Users / New user” opens.

  3. Fill in the fields:

    • “Account name”: lwhite (lowercase letters and digits; the only symbols allowed are the minus sign and the underscore: no dots);
    • “Full name”: Laura White;
    • “Password” and “Repeat password”: at least 8 characters, with an uppercase letter, a lowercase letter and a symbol.
  4. Press “Create user” at the bottom right. “Account saved” appears.

  5. Repeat steps 2–4 for pblack (Paul Black) and for jgreen (Jack Green): until the end of the month he too signs in with an account of his own.

Every account created from this page is an administrator: it joins the sudo group, has /bin/bash as its shell and can use the console and SSH. There are no “read-only” accounts: the console runs as root, so whoever gets in can do everything. The list’s “console” column says so (“Enabled”).

The form of a new userThe form of a new user
The form of a new user

For the technician The accounts are the system’s (/etc/passwd, /etc/shadow, /etc/group): Argos keeps no list of its own. root and the members of the sudo group with a usable password can sign in to the console. The password never goes on the command line: chpasswd receives it on stdin. The same operation from the shell is argos system users add <name>.

The second factor, each for themselves

Only the account itself can enable its own factor: whoever holds the secret holds the factor, and an administrator who scanned a colleague’s QR code would keep the colleague’s factor. That is why each person does it from their own login.

  1. Laura signs out (“Sign out”, at the bottom of the sidebar) and signs back in as lwhite.
  2. In System → Users she selects her own account. Under the data there is the “Two-factor authentication” panel, marked “off”, and the line “Asked at the console login from: wan” (plus the other zones that ask for it).
  3. She presses “Enable”, scans the QR code with the app, types the six digits in “Code from the app” and presses “Confirm”. “Two-factor authentication enabled” appears.
The enrollment QR codeThe enrollment QR code
The enrollment QR code
  1. Paul does the same with pblack. If Laura selects pblack, the panel has no “Enable” button and says “Only the account itself can enable it, once signed in: whoever holds the secret holds the factor.”.
  2. Optional: if you want the code in the office too, open System → Management access, switch on “Console 2FA” in the LAN row and press “Save”. It holds from the save, without applying the firewall. If your account does not have the factor yet, the save is refused; if you have it but another account does not, a warning tells you.
  3. Keep the root password in a safe place (a password vault, a sealed envelope) and stop using it every day. root is a system account: on this page only its password can be changed; it cannot be disabled.

Disabling the one who leaves the company

  1. In System → Users select jgreen.
  2. Switch on “Account disabled” and press “Save user”. The effect is immediate, with no “Apply”: the password is locked and the account expired, so no login to the console, no SSH, not even with a key. His open sessions on the console end within a few seconds, and a shell opened from System → Shell is closed within 15 seconds. His home directory and his files stay.
A disabled accountA disabled account
A disabled account
  1. When you no longer need anything from his files, select jgreen again, press “Delete user” (the bin in the detail’s bar) and confirm. His home directory and his local mailbox go too.

Warning Disabling an account does not close an SSH session already open: it blocks new logins. This is why deleting it can fail: the system command refuses to delete an account that still has processes running, and the console shows its message after “The account could not be saved”. Disable first, then end the session from a shell as root (for example loginctl terminate-user jgreen, a standard systemd command), then delete.

Lost phone: a colleague removes the factor

Paul has lost his phone and can no longer sign in from the wan.

  1. Laura opens System → Users and selects pblack. The “Two-factor authentication” panel says “on”.
  2. She presses “Remove” and confirms the question “Remove the second factor of pblack? From the zones that ask for one, its logins are refused until it enrolls again.”. “Second factor removed” appears.
  3. Paul signs in from the office LAN, where the code is not asked for (unless you switched on “Console 2FA” on the LAN in step 10), with his password alone. Then he enrolls the factor again with the new phone, as in steps 7–8.

If Paul still has the old phone and is only changing device, nothing needs removing: with his account he presses “Replace the app”. The current factor stays valid until the new one is confirmed.

Nobody can remove their own factor from a zone that asks for it: the console answers “You are connected from a zone that asks for a code: removing yours would refuse your next login from here. Remove it from a zone that does not ask, or with argos-mfa-reset.”.

Lost phone and nobody can sign in: argos-mfa-reset

If the only administrator has lost their phone and every zone they could sign in from asks for the code, the way back is a shell on the appliance: keyboard and screen connected, or SSH from the LAN (SSH does not ask for the second factor).

  1. Log in as root and check who has a second factor:

    argos-mfa-reset --list
  2. Remove the one of the account that lost it:

    argos-mfa-reset pblack

    It takes effect at once, even with the console running. From then on the account signs in with its password alone from the zones that do not ask for the code, and from those that ask it is refused until it enrolls the factor again from System → Users.

For the technician The secrets are in /etc/edon/passwd.pam (0600), edon-core’s per-user archive, in the record mfa.otp: an account enrolled here is enrolled for every EDON component that reads that file. The same reset from the shell is argos system users mfa remove pblack --yes. An account that has to enroll its factor while every zone asks for it can come in through an SSH tunnel to the application’s local port (ssh -L 3000:127.0.0.1:3000 root@192.168.10.1, then http://localhost:3000/ in the browser): a local request never asks for the code.

Verification

  • In System → Users the list shows lwhite and pblack with “console” and “2FA” on “Enabled” and the “State” “Enabled”; jgreen stays in the sudo group (“console” “Enabled”) but has the “State” “disabled”, and cannot sign in until you enable him again; he stays in the list until you delete him.
The list of usersThe list of users
The list of users
  • From the wan (a phone on the mobile network, if the console answers there: see Managing the console from outside) the login of lwhite asks for the “Verification code”.
  • An attempt with jgreen answers “Invalid credentials”.
  • In Events and diagnostics → System type argos-auth in the filter and press “Filter”: the failed logins appear with the account and the address (failed login for user "jgreen" from 192.168.10.142), as do the refusals for a missing factor. The actions Argos records with the account (starting and stopping a service from the Status page, deleting tracked connections, opening a shell) now carry the person’s name instead of root.

If something goes wrong

  • “A user or group with this name already exists”. Choose another name: the names of the system accounts and groups are already taken.
  • “Needs an uppercase and a lowercase letter and a symbol from @#*+_=|?^$%&()-[]{}<>!,.: …”. The password does not follow the rule: at least 8 characters, an uppercase letter, a lowercase letter, one of the symbols listed, and no other character besides letters, digits and those symbols.
  • “You cannot disable the account you are signed in with” / “You cannot delete the account you are signed in with”. Do it from another account.
  • “This is the last account that can sign in to the console: the appliance would lock everyone out”. Argos never leaves the appliance without a usable account: create another administrator first.
  • “Only the account itself can enroll its second factor”. You tried to enable it for a colleague: they must do it themselves, from their own login.
  • “Wrong code: check the app’s clock, then try the next code”. During the enrollment the code does not match. After five wrong codes the enrollment expires (“Too much time went by: start the enrollment again”): press “Enable” again.
  • A newly created account cannot sign in from the wan. It does not have the factor yet, and from a zone that asks for it it is refused as if its password were wrong. It must sign in the first time from the LAN (or through the SSH tunnel of the box above) and enroll it.
  • You have forgotten the root password. Another administrator changes it: in System → Users they select root, type the new one in “Password” and “Repeat password” and press “Save user”. See also Recovering access.
LET’S TALK INFRASTRUCTURE

Control starts with a conversation.

Tell us about your infrastructure. Let’s start with what you actually need.

Talk to an engineer