OS: CentOS 6.5 SSH v5.3
Goal:
root access is allowed with PubKeyAuthentication from several hosts.
users of "group1" are allowed to login with whatever they provide: PubKey, Password, GSSAPI, KerberosPassword; but they are only allowed to arrive from one certain IP: 192.168.1.10
Status: root access is already defined via multiple from=""
-entries in ~/.ssh/authorized_keys
, and works as expected.
Problem: users of group1 can arrive from 192.168.1.10 OR from elsewhere; or are locked out completely (with earlier tested configurations).
I tried several variations, but to no avail.
/etc/pam.d/sshd
effectively looks like:
auth sufficient pam_unix.so nullok try_first_pass
auth requisite pam_succeed_if.so uid >= 500 quiet
Currently I have in sshd_config
:
PermitRootLogin without-password
PasswordAuthentication no
KerberosAuthentication no
GSSAPIAuthentication no
UsePAM yes
AllowGroups root group1
Match Group [email protected]
KerberosAuthentication yes
PasswordAuthentication yes
GSSAPIAuthentication yes
PubKeyAuthentication yes
Match Group root
PubKeyAuthentication yes
Any proposals?
I found a working solution. sshd debug mode (
/usr/sbin/sshd -ddd
) indicated the missing link:As you can see the login matched the correct block; but due to
UsePAM yes
PAM obviously overruled the "no"-entries in theMatch Address *
block; see manual:The final config looks like:
Only after having added
KbdInteractiveAuthentication no
the PAM password feature was disabled for this block, and users coming from anywhere are now successfully denied.