Join our Newsletter — 33% off our NHI Course
Home› Guides› Unix and Linux Privileged Access Guide: Root, Bridging…
Guide Endpoint Security

Unix and Linux Privileged Access Guide: Root, Bridging to AD and Session Control

PDF for newsletter subscribers · free to read online

← All guides
By NHI Mgmt Group, edited by Lalit Choda Updated 27 October 2026 14 min read
On this page

On Unix and Linux, privilege is concentrated in one account, root, and reached through a tangle of shared passwords, sudo rules and SSH keys that most privileged access programmes never fully map. PAM programmes are often designed around Windows and Active Directory, then extended to Linux by vaulting the root password and stopping there. That leaves the real access paths (personal and automation SSH keys, broad sudo rules, local accounts outside the directory) ungoverned. This guide sets out how to govern root, how to bridge Linux and Unix hosts to Active Directory, how to design sudo and SSH access so privilege is scoped and attributable, how to record and review privileged sessions, and how to measure progress. It is for identity, PAM and Linux platform teams. The general programme is covered in the Privileged Access Management Guide; this page goes deeper on the Unix specifics.

Key takeaways

  • Govern the paths, not just the password: root is reached through su, sudo, SSH keys, certificates and automation, and each path needs an owner and a control.
  • Bridge identities to the directory with SSSD and realmd (or an equivalent bridging product) so people log in as named accounts and leavers lose access everywhere at once.
  • Scope sudo to commands, require authentication, and send sudo event and I/O logs to a central log server; a rule that allows an editor or shell is a rule that allows root.
  • Replace static SSH keys with short-lived certificates or vault-brokered access where you can, and inventory every authorized_keys file where you cannot.
  • Automation is the largest privileged population: configuration management, backup and monitoring accounts usually hold unrestricted root keys and should be scoped and rotated first.

How Unix privilege differs from Windows

AspectWindows and Active DirectoryUnix and LinuxConsequence for PAM
Privileged identityMany groups and rights (Domain Admins, local Administrators, user rights)UID 0 bypasses discretionary access checks; delegation through sudo, capabilities and group membershipLeast privilege lives in sudo rules and service design rather than built-in roles
AccountsMostly in the directoryLocal /etc/passwd accounts plus optional directory accountsLocal accounts escape joiner, mover and leaver processes
Remote accessRDP, WinRM, KerberosSSH with passwords, keys, certificates or Kerberos (GSSAPI)SSH keys are credentials the directory does not see
Credential storageLSASS, credential manager/etc/shadow, ~/.ssh, keytabs, configuration filesDiscovery must scan files, not just directory objects
Native loggingSecurity event logauth or secure log, journald, auditd, sudo logsLogging must be configured and forwarded deliberately

The result is that Linux privileged access is distributed and file-based. Discovery is the first job: list every account with UID 0, every member of wheel or sudo groups, every sudoers rule (including /etc/sudoers.d/ and any LDAP or SSSD-delivered rules), every authorized_keys file and every keytab. The Privileged Account Discovery and Onboarding Guide covers the process.

Governing root

  • No interactive root logins: set PermitRootLogin no in sshd_config. OpenSSH's default is prohibit-password, which still allows root with a key, so the default is not enough. Where a tool genuinely needs root over SSH, use forced-commands-only with a key restricted to one command.
  • Unique root password per host, vaulted: the root password is for console and single-user recovery. Store it in a vault with check-out, rotate it after use, and never share one root password across a fleet. See the Linux PAM Guide for the authentication stack that protects it.
  • Restrict su: limit su to the wheel group through PAM (pam_wheel), or remove its use entirely in favour of sudo, which logs who ran what.
  • Only one UID 0: alert on any additional account with UID 0, a classic persistence technique. ATT&CK tracks account changes under T1098 Account Manipulation and local account abuse under T1078.003.
  • Break-glass procedure: document how to reach root when the directory, vault or network is down, test it, and alert whenever it is used.

Bridging Unix and Linux to Active Directory

Directory bridging lets people sign in to Linux hosts with their AD account, so access follows the identity lifecycle. On modern Linux the common open source route is realmd for enrolment and SSSD for identity, authentication and access control; commercial bridging products add central policy and support for older Unix platforms.

FunctionSSSD and realmd settingNotes
Join the domainrealm discover, realm join AD.EXAMPLE.COMCreates the host's computer account and keytab; can target a specific OU or use a one-time password
Identity and authenticationid_provider = adKerberos authentication against domain controllers; automatic ID mapping by default, or POSIX attributes from AD
Who may log inaccess_provider = simple (via realm permit), ad (GPO-based) or ad_access_filterRestrict each host or host group to named AD groups; never leave access open to all domain users
Privilegesudo rules in sudoers files, or delivered centrally through LDAP or SSSDGrant sudo to AD groups, not individuals
Offline behaviourSSSD credential cacheCached logins keep working if domain controllers are unreachable; cache lifetime is a security decision
  • Separate admin identities: map Linux privilege to dedicated AD admin accounts (for example a separate admin account per engineer), not to everyday accounts used for email and browsing.
  • Protect the host keytab: the keytab created by the join lets the host authenticate as its computer account. It must be readable only by root. See the Linux Service Accounts and Keytab Management Guide.
  • Know the dependency: bridging moves the trust anchor to Active Directory. If AD is compromised, so are bridged hosts, so keep break-glass local access independent of AD.

The SSSD and Linux Active Directory Integration Guide covers configuration in detail.

Designing sudo for least privilege

sudo is the main privilege delegation tool on Linux, and the sudoers policy language is powerful enough to be dangerous. Key options from the sudoers manual:

Option or tagDefaultUse
authenticate / NOPASSWDAuthentication requiredKeep authentication on for people; use NOPASSWD only for tightly scoped automation commands
timestamp_timeout5 minutesShorten for high-risk hosts; set to 0 to require a password every time
env_reset, secure_pathenv_reset onRun commands in a minimal environment with a controlled PATH
NOEXEC tagOffStops permitted programs such as pagers and editors spawning further commands (needs OS support)
INTERCEPT tagOffChecks and logs programs started by the permitted command (sudo 1.9.8 and later)
sudoeditBuilt inLets users edit specific files without running an editor as root
Command digests (sha256:)NoneRuns a command only if its hash matches, so a replaced binary is refused
log_input, log_outputOffRecord keystrokes and terminal output of sudo sessions
log_serversNoneSend event and I/O logs to a central sudo_logsrvd server (sudo 1.9 and later)
  • Use command aliases per role: define Cmnd_Alias sets for each job (restart a service, read logs, manage packages) and grant those to AD groups.
  • Avoid escape-prone commands: rules allowing vi, less, find, interpreters, tar or wildcards in arguments usually give a full root shell. ATT&CK tracks abuse of sudo under T1548.003 Sudo and Sudo Caching.
  • Review "ALL" rules: ALL=(ALL) ALL is equivalent to root. Keep it to a small admin group, with authentication and logging.
  • Manage sudoers centrally: deploy rules through configuration management or central LDAP/SSSD delivery, validate with visudo -c, and treat changes as privileged changes.

The sudo and sudoers Security Guide covers rule review techniques.

SSH access: keys, certificates and brokered sessions

ApproachHow it worksStrengthsWeaknessesBest fit
Static public keysKeys listed in ~/.ssh/authorized_keysSimple, universalNever expire, copied freely, invisible to the directorySmall estates with strict inventory
Central key lookupAuthorizedKeysCommand fetches keys from a directoryKeys follow the identity lifecycleStill long-lived keys; lookup service is criticalDirectory-integrated estates
SSH certificatesHosts trust a CA via TrustedUserCAKeys; users get short-lived signed certificatesExpiry built in, principals map to roles, no per-host key distributionCA key is a crown jewel; needs issuance toolingMedium and large estates
PAM proxy or brokerUsers connect through a gateway that injects vaulted credentials and records sessionsRecording, approvals, no credential exposure to usersSingle point of failure; latency; tool costRegulated environments, third-party access
Kerberos (GSSAPI)Domain tickets via GSSAPIAuthenticationNo keys on disk, AD lifecycleDepends on AD and DNS; less common for automationAD-bridged estates
  • Certificates in practice: sign with ssh-keygen -s ca_key -I key_id -n principals -V +8h user_key.pub. The -I key identifier is logged by sshd whenever the certificate is used, which gives attribution. Restrict with -O source-address= and -O no-port-forwarding, and with hardware-backed keys (ed25519-sk) add verify-required. Use AuthorizedPrincipalsFile to map principals such as db-admin to accounts.
  • Revocation: distribute a Key Revocation List (ssh-keygen -k) through RevokedKeys. Note that if that file is unreadable, sshd refuses public key authentication for all users, so deploy it carefully.
  • Restrict who can log in: use AllowGroups and Match blocks, set PasswordAuthentication no (the OpenSSH default is yes), and use AuthenticationMethods publickey,keyboard-interactive where a second factor is required.
  • Protect private keys at the source: keys on developer laptops are a target. In the PyTorch torchtriton supply chain attack a malicious package copied SSH keys from ~/.ssh along with other secrets. Short-lived certificates and hardware-backed keys limit what a stolen file is worth. See the SSH Key Management Guide.

Session control and recording

  • sudo I/O logging: log_input and log_output record what was typed and displayed during sudo sessions, replayable with sudoreplay. Send them to sudo_logsrvd with log_servers so a root user on the host cannot delete them; sudo_logsrvd stores I/O logs under /var/log/sudo-io by default, supports TLS and can relay to another server.
  • Whole-session recording: terminal session recorders (for example tlog on RHEL) or a PAM proxy capture full SSH sessions, not just sudo commands. Use them for third-party access and for the highest-risk systems, and tell users that sessions are recorded.
  • auditd for root activity: an execve rule for effective UID 0 records every root command regardless of how root was reached. See the Linux Logging and auditd for Defenders Guide.
  • Just-in-time elevation: grant sudo group membership or certificate principals for a time window after approval, rather than standing membership. Short certificate validity (hours) is the simplest JIT mechanism on Linux.

The Privileged Session Management Guide compares recording approaches.

Automation and service accounts

Configuration management (Ansible, Puppet, Chef, Salt), backup agents, monitoring, deployment pipelines and vulnerability scanners all need privileged access to Linux, and they usually have more of it than any person.

  • One identity per tool: separate accounts for each tool and environment, never a shared "automation" account with the same key everywhere.
  • Scoped sudo with NOPASSWD only where needed: limit automation accounts to the commands they run, with command digests where practical.
  • Restricted keys: prefix automation keys in authorized_keys with from="10.0.5.0/24", command= and no-port-forwarding, or issue short-lived certificates from the pipeline at run time.
  • Vault and rotate: keep automation private keys and passwords in a secrets manager, rotate them on a schedule and on staff departure, and alert on use from unexpected sources.
  • Treat the control node as tier zero: a configuration management server that can run root commands on every host is as sensitive as a domain controller.

Detection and measurement

SignalSourceATT&CK
New entries in any authorized_keys fileFile integrity monitoring, auditd watchT1098.004
sudo use by accounts not in an approved group, or outside change windowssudo event logs, sudo_logsrvdT1548.003
Root or service account SSH logins from new sourcessshd logsT1021.004
New UID 0 account or changes to /etc/sudoers.d/auditd, file integrity monitoringT1098
Reads of /etc/shadow by unexpected processesauditdT1003.008
Changes to PAM configuration in /etc/pam.d/File integrity monitoringT1556.003

Metrics: percentage of Linux hosts bridged to the directory with group-restricted login; number of sudo rules granting ALL outside the admin group (target zero); number of static keys in authorized_keys without a recorded owner (target zero); percentage of privileged SSH access using certificates or a broker; percentage of root passwords unique and vaulted; and time to remove a leaver's access from all Linux hosts.

Rolling it out

  1. Discover: collect accounts, sudoers, keys and keytabs from every host with a read-only script or your PAM tool's discovery.
  2. Quick wins: disable root SSH login, vault and randomise root passwords, remove leavers' keys.
  3. Bridge: join hosts to the directory in rings (non-production, then production), restricting login to named groups.
  4. Rewrite sudo: convert ad hoc rules to role-based command aliases granted to directory groups; run the new policy alongside the old one on a pilot group first, and keep the previous sudoers in configuration management for rollback.
  5. Centralise logs: forward sudo, sshd and auditd logs and set up sudo_logsrvd.
  6. Move to certificates or a broker: start with administrators, then automation; remove static keys once certificate access is proven.

A small team with a few dozen servers can get far with SSSD, a curated sudoers set and certificates from a simple CA. Large estates with legacy Unix (AIX, Solaris, HP-UX) and third-party access usually need a commercial bridging or PAM product for coverage and session recording.

Common failure patterns

  • Vault the root password and declare victory: nobody uses the root password; they use keys and sudo, which remain unmanaged.
  • One automation key everywhere: a single private key with root on every host, stored on a build server and several laptops.
  • sudo rules that are really root: editor, pager, interpreter or wildcard rules that give a shell.
  • Directory bridging with open access: hosts joined to AD without access rules, so every domain user can log in.
  • Local logs only: sudo and auth logs kept on the host, where an attacker with root deletes them.
  • Leavers keep keys: the AD account is disabled but the person's key remains in authorized_keys on dozens of hosts.

Framework mapping

ControlNIST SP 800-53 Rev. 5NIST CSF 2.0CIS Controls v8.1ISO/IEC 27001:2022 Annex A
Privileged account inventory and lifecycleAC-2PR.AA-015.1, 5.4A.5.16, A.5.18
Least privilege through sudoAC-6, AC-6(5)PR.AA-056.8A.8.2
Strong authentication for adminsIA-2, IA-5PR.AA-016.5A.8.5
Session logging and recordingAU-2, AU-12DE.CM-018.2A.8.15

Practitioner checklist

  • Discover every UID 0 account, sudoers rule, authorized_keys file and keytab across the estate.
  • Set PermitRootLogin no and PasswordAuthentication no, and restrict SSH with AllowGroups.
  • Give each host a unique, vaulted root password and test the break-glass procedure.
  • Bridge hosts to the directory and restrict login on each host to named groups.
  • Rewrite sudo as role-based command aliases granted to directory groups, with authentication and no shell-escape commands.
  • Send sudo event and I/O logs to sudo_logsrvd and forward sshd and auditd logs to the SIEM.
  • Issue short-lived SSH certificates for administrators and automation, and maintain a revocation list.
  • Give each automation tool its own restricted identity, stored in a vault and rotated.
  • Alert on authorized_keys changes, new UID 0 accounts and sudoers changes.

Standards and references

Related NHI Mgmt Group resources: Privileged Access Management Guide · sudo and sudoers Security Guide · SSH Key Management Guide · SSSD and Linux Active Directory Integration Guide

PDF for subscribers

Take this guide with you

Every section, table and checklist in one PDF, with links to the sources and related guides. Subscribe to our weekly NHI & AI Identity Journal and we’ll email you a download link.

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

NHIMG Editorial Note
Researched and written by the NHI Mgmt Group editorial team using AI tools, under the editorial direction of Lalit Choda. Facts are drawn from the sources listed on this page and checked by our automated quality process. Last updated 27 October 2026. Spotted an error? Use our contact page.
NHI Mgmt Group, the independent authority on Non-Human Identity, IAM and Agentic AI security. nhimg.org

PDF Downloads for Newsletter Subscribers

Get the guide

Enter your details and we’ll email you a download link.

The full guide is free to read online. The PDF is a thank you for subscribing.

Fill in all fields marked * and tick the PDF box to continue.