| Summary: | Unable to perform host-based authentication as root if "IgnoreRhosts" is set to "yes" on server configuration | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Product: | Portable OpenSSH | Reporter: | Anderson Medeiros Gomes <amg1127> | ||||||||||||||
| Component: | sshd | Assignee: | Assigned to nobody <unassigned-bugs> | ||||||||||||||
| Status: | CLOSED FIXED | ||||||||||||||||
| Severity: | normal | CC: | ahmedsayeed1982, amg1127, djm, dtucker | ||||||||||||||
| Priority: | P5 | ||||||||||||||||
| Version: | 8.2p1 | ||||||||||||||||
| Hardware: | amd64 | ||||||||||||||||
| OS: | Linux | ||||||||||||||||
| Bug Depends on: | |||||||||||||||||
| Bug Blocks: | 3117 | ||||||||||||||||
| Attachments: |
|
||||||||||||||||
|
Description
Anderson Medeiros Gomes
2020-04-14 17:25:36 AEST
Created attachment 3377 [details]
/etc/ssh/ssh_config
According to my source code analysis, two code blocks written in file "/src/usr.bin/ssh/auth-rhosts.c" ( https://cvsweb.openbsd.org/cgi-bin/cvsweb/~checkout~/src/usr.bin/ssh/auth-rhosts.c?rev=1.51 ) are explicitly preventing root user from authenticating itself via host-based method. This code block, which starts at line 226 and is declared inside function "auth_rhosts2", prevents parsing of "/etc/ssh/shosts.equiv" if "root" is the user being authenticated: -------------------------------- /* * If not logging in as superuser, try /etc/hosts.equiv and * shosts.equiv. */ if (pw->pw_uid == 0) debug3("%s: root user, ignoring system hosts files", __func__); else { if (check_rhosts_file(_PATH_RHOSTS_EQUIV, hostname, ipaddr, client_user, pw->pw_name)) { auth_debug_add("Accepted for %.100s [%.100s] by " "/etc/hosts.equiv.", hostname, ipaddr); return 1; } if (check_rhosts_file(_PATH_SSH_HOSTS_EQUIV, hostname, ipaddr, client_user, pw->pw_name)) { auth_debug_add("Accepted for %.100s [%.100s] by " "%.100s.", hostname, ipaddr, _PATH_SSH_HOSTS_EQUIV); return 1; } } -------------------------------- And this code block, starting at line 293, prevents parsing of "/root/.shosts" file if "IgnoreRhost yes" is set in "/etc/ssh/sshd_config". As a result, host-based authentication as root will fail even if a systems administrator creates in "/root/.shosts" a symbolic link targeting to "/etc/ssh/shosts.equiv" as a workaround. -------------------------------- /* * Check if we have been configured to ignore .rhosts * and .shosts files. */ if (options.ignore_rhosts) { auth_debug_add("Server has been configured to " "ignore %.100s.", rhosts_files[rhosts_file_index]); continue; } -------------------------------- Created attachment 3378 [details]
OpenSSH server log
Created attachment 3379 [details]
OpenSSH client log
Created attachment 3380 [details]
allow IgnoreRhosts to appear in a Match block
I don't think we want to change the current behaviour of refusing root for /etc/hosts.equiv as that is likely to be surprising, so I think the easiest way around this is to allow IgnoreRhosts to appear in a Match block. Then you'll be able to do something like:
IgnoreRhosts yes
HostbasedAuthentication yes
Match user root
IgnoreRhosts no
to enable .shosts just for root
Created attachment 3381 [details]
IgnoreRhosts=shosts-only
While I'm in there, fix something else that has annoyed me for a while: make IgnoreRhosts a tri-state option to allow admins to ban .rhosts but permit .shosts (which AFAIK isn't shared with terrible IP-trusting crypto-free horrors from the ancient world)
Ok. The proposed solution sounds good to me. Thanks, Damien. Although sole host-based authentication for superuser is a bad security practice, I think that OpenSSH should be sufficiently flexible to allow such configuration and fit specific needs. I know that my request sounds weird. Please, could the documentation be patched to in order to clarify that refusing host-based root login is intentional? I propose something like this: ------------------------------------------- ----------- man(5) sshd_config ------------ HostbasedAuthentication Specifies whether rhosts or /etc/hosts.equiv authentication together with successful public key client host authentication is allowed (host-based authentication). /etc/hosts.equiv is always ignored for host-based superuser authentication. The default is no. These have been committed, along with a note in ssh(1) mentioning that [s]hosts.equiv does not apply to root. They will be in the OpenSSH 8.3 release. Thanks! close bugs that were resolved in OpenSSH 8.5 release cycle [spam removed] |