Part of NetOrk/netork#1793. LinuxDriver mixes in napalm-device-types' LocalAccountsMixin (NAPALM/napalm-device-types, branch feat/local-accounts), which needs to be merged first. Until then CI pre-installs device-types main and stays red.
Lock: usermod -L -e 1 <name>. A locked account is an expired one, because PAM's account check then refuses a key login too. A ! in front of the password (usermod -L alone) stops only the password.
Open again: usermod -e '' [-p <hash>|-U] <name>. This lifts the expiry and gives the old password back. An account that never had a password stays key-only, since usermod -U would refuse it.
Lock state: getent shadow <name> as root. Only the expiry field is looked at.
Part of NetOrk/netork#1793. `LinuxDriver` mixes in napalm-device-types' `LocalAccountsMixin` (NAPALM/napalm-device-types, branch `feat/local-accounts`), which needs to be merged first. Until then CI pre-installs device-types `main` and stays red.
## Commands
- Create: `useradd -m -s /bin/bash [-p <hash>] <name>`.
- Lock: `usermod -L -e 1 <name>`. A locked account is an **expired** one, because PAM's account check then refuses a key login too. A `!` in front of the password (`usermod -L` alone) stops only the password.
- Open again: `usermod -e '' [-p <hash>|-U] <name>`. This lifts the expiry and gives the old password back. An account that never had a password stays key-only, since `usermod -U` would refuse it.
- Lock state: `getent shadow <name>` as root. Only the expiry field is looked at.
- Leave a group: `gpasswd -d <name> <group>`. Admin groups: `sudo`, `wheel`, `admin`.
## Verified
Debian 13 and Rocky Linux 9 containers with sshd and sudo:
- add with sudo: key login works, and `sudo` takes the person's password
- lock: key login is refused (ssh 255), the keys are gone, sudo is gone
- reopen without sudo: key login works, sudo is refused
- a cloud-init style rule in `90-cloud-init-users` is reported
- an account in `sudo` or `wheel` (as cloud-init makes it) leaves the group
OpenMediaVault and QNAP inherit `LinuxDriver`. OMV builds its own variant on it (NAPALM/napalm-openmediavault#12: `setUser`, `_ssh`, OMV's key store), and QNAP opts out (NAPALM/napalm-qnap-qts#15).
LinuxDriver mixes in napalm-device-types' LocalAccountsMixin with
useradd -m -s /bin/bash, usermod and gpasswd -d. A locked account is an
expired one (usermod -L -e 1): PAM refuses it a key login too, where a
"!" in front of the password stops only the password. Opening it again
lifts the expiry and gives the old password back.
Checked on Debian 13 and Rocky Linux 9 containers with sshd and sudo:
key login works after adding, is refused after locking and works again
after reopening; the sudo rule takes effect with the person's password;
membership of sudo/wheel goes when sudo is not wanted.
expect_for and STATUS_ECHO_RE say when netmiko's interactive shell has
finished printing a command's output, next to PROMPT_RE they build on.
Moving them out keeps linux.py within its line count now that it mixes in
the personal accounts; the baseline goes down to 2265.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Part of NetOrk/netork#1793.
LinuxDrivermixes in napalm-device-types'LocalAccountsMixin(NAPALM/napalm-device-types, branchfeat/local-accounts), which needs to be merged first. Until then CI pre-installs device-typesmainand stays red.Commands
useradd -m -s /bin/bash [-p <hash>] <name>.usermod -L -e 1 <name>. A locked account is an expired one, because PAM's account check then refuses a key login too. A!in front of the password (usermod -Lalone) stops only the password.usermod -e '' [-p <hash>|-U] <name>. This lifts the expiry and gives the old password back. An account that never had a password stays key-only, sinceusermod -Uwould refuse it.getent shadow <name>as root. Only the expiry field is looked at.gpasswd -d <name> <group>. Admin groups:sudo,wheel,admin.Verified
Debian 13 and Rocky Linux 9 containers with sshd and sudo:
sudotakes the person's password90-cloud-init-usersis reportedsudoorwheel(as cloud-init makes it) leaves the groupOpenMediaVault and QNAP inherit
LinuxDriver. OMV builds its own variant on it (NAPALM/napalm-openmediavault#12:setUser,_ssh, OMV's key store), and QNAP opts out (NAPALM/napalm-qnap-qts#15).