我有一个Ubuntu服务器,它有一个私有的、内部的、IP的和面向公共的IP。我只想在公共方面为SSH建立双因素认证。这个是可能的吗?我计划使用谷歌认证,但也对其他想法持开放态度。
发布于 2013-06-26 17:11:52
是的,你可以用pam_access.so来完成这个任务。这个食谱取自用于Google身份验证的维基:
一个有用的PAM配方是允许跳过两个因素的身份验证,当连接来自某些来源时。PAM已经支持这一点。例如,pam_access模块可以用于根据本地子网检查源:#跳过一次密码,如果从本地网络auth success=1 default=ignore pam_access.so访问文件=/etc/security/ access-local.conf auth需要pam_google_authenticator.so在本例中,则access-local.conf看起来:#只允许本地IP范围+:ALL : 10.0.0.0/24 +:ALL : local -:ALL :所有从10.0.0.0/24进行的登录尝试都不需要两个因素的身份验证。
发布于 2021-08-04 13:23:14
我的要求非常相似,但更具体地说,我想要1)拥有公共密钥和外部的googleAuth,以及2)从内部获得公共密钥或密码(如果我失去了所有的公钥,密码):
/etc/ssh/sshd_config:
AuthenticationMethods publickey,keyboard-interactive
Match address 192.168.2.0/24
PasswordAuthentication yes
AuthenticationMethods "password" "publickey"
Match all/etc/pan.d/sshd:
# Google Authenticator
auth [success=1 default=ignore] pam_access.so accessfile=/etc/security/access-local.conf
auth sufficient pam_google_authenticator.so
# Standard Un*x authentication.
auth [success=ignore default=4] pam_access.so accessfile=/etc/security/access-local.conf
@include common-auth/etc/安全/访问-local.conf
+ : ALL : 192.168.2.0/24
- : ALL : ALL除了以前的答案之外,我还必须跳过/etc/panam.d/common中的4条规则,从外部开始,我还将google配置为足够,而不是必需的。我是在Ubuntu20.04上这样做的,但是这个解决方案应该是相当通用的
https://serverfault.com/questions/518802
复制相似问题