1、openssh的 key auth不是通过pam实现的,绕过了Pam auth堆栈。所以,不能通过pam编排的范式实现。
2、通过配置sshd_config,来实现相同的需求
2.1、通过PermitRootLogin禁止root通过密码认证
openssh7.0-
PermitRootLogin without-password
openssh7.0+
PermitRootLogin prohibit-password
2.2、开启秘钥认证,配置密钥到/root/.ssh/authorized_keys,而其他用户不进行配置
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
2.3、开启密码认证,普通用户走该认证方式。
PasswordAuthentication yes
自OpenSSH7.0,默认UsePAM是禁用的。