hosts.equiv trust

/etc/hosts.equiv grants passwordless r-command access for trusted hosts to all non-root users at once, a broader trust than per-user .rhosts. A permissive entry, a trusted host an attacker controls or can spoof, or write access to the file (post-elevation) gives passwordless access as any non-root account on the system.

1 min di letturaaggiornato il 7 ott 2026florianamette1 contributore
Chiedi al tuo assistente (MCP)Modifica su GitHub

/etc/hosts.equiv is the system-wide trust file used by rsh and rlogin. The effect depends on both fields. A host-only entry permits remote users to access like-named local accounts without a password. Adding a username permits that remote user to access non-root local accounts, while wildcard forms such as a bare + or host + broaden trust further. Abuse therefore depends on the exact rule: an attacker may control or spoof a listed host, match a trusted username, exploit a wildcard, or gain enough local privilege to modify the file. Root is excluded from hosts.equiv processing and instead relies on root's own .rhosts policy.

bash
# read it to see which hosts are trusted and how broadly
cat /etc/hosts.equiv 2>/dev/null
# a host-only rule normally requires the remote and local usernames to match
rlogin -l <matching-user> <target>
rsh -l <matching-user> <target> id
# if writable after local elevation, this is a deliberately maximal rule
echo '+' >> /etc/hosts.equiv      # any host; behavior may also depend on PAM policy

Exploitation notes#

  • Do not treat every entry as equivalent: host requires like-named accounts, whereas host user, host +, and a bare + have progressively broader consequences.
  • Root is not covered by hosts.equiv; passwordless root requires /.rhosts, so note the distinction when targeting the root account.
  • The file is root-owned, so writing it is a post-elevation/persistence step; the initial vector is usually an already-permissive file plus a trusted or spoofable source host.
  • The file governs rsh and rlogin; it is not an authentication source for password-based rexec.

References#