나는 떠난 동료로부터 시스템을 물려받았습니다. 그는 사용자 root
와 를 제외하고 시스템에 2단계 인증을 설정했습니다 ftpupload
.
그러나 SSH 액세스 권한이 있지만 2단계 인증이 필요하지 않은 특정 사용자가 있습니다. 이 사용자는 사용자 이름과 비밀번호만으로 로그인할 수 있습니다!
나는 그룹의 모든 사용자가 disable2fa
2단계 인증을 요구하도록 설정한 것을 확인했습니다. 이 그룹에는 다음 사용자만 표시됩니다.
$ getent group disable2fa
disable2fa:x:2003:root,publicftpupload
PAM 파일( )을 확인한 sudo nano /etc/pam.d/sshd
결과 다음이 표시됩니다.
# PAM configuration for the Secure Shell service
# Standard Un*x authentication.
@include common-auth
# Disallow non-root logins when /etc/nologin exists.
account required pam_nologin.so
# Uncomment and edit /etc/security/access.conf if you need to set complex
# access limits that are hard to express in sshd_config.
# account required pam_access.so
# Standard Un*x authorization.
@include common-account
# SELinux needs to be the first session rule. This ensures that any
# lingering context has been cleared. Without this it is possible that a
# module could execute code in the wrong domain.
session [success=ok ignore=ignore module_unknown=ignore default=bad] pam_selinux.so close
# Set the loginuid process attribute.
session required pam_loginuid.so
# Create a new session keyring.
session optional pam_keyinit.so force revoke
# Standard Un*x session setup and teardown.
@include common-session
# Print the message of the day upon successful login.
# This includes a dynamically generated part from /run/motd.dynamic
# and a static (admin-editable) part from /etc/motd.
session optional pam_motd.so motd=/run/motd.dynamic
session optional pam_motd.so noupdate
# Print the status of the user's mailbox upon successful login.
session optional pam_mail.so standard noenv # [1]
# Set up user limits from /etc/security/limits.conf.
session required pam_limits.so
# Read environment variables from /etc/environment and
# /etc/security/pam_env.conf.
session required pam_env.so # [1]
# In Debian 4.0 (etch), locale-related environment variables were moved to
# /etc/default/locale, so read that as well.
session required pam_env.so user_readenv=1 envfile=/etc/default/locale
# SELinux needs to intervene at login time to ensure that the process starts
# in the proper default security context. Only sessions which are intended
# to run in the user's context should be run after this.
session [success=ok ignore=ignore module_unknown=ignore default=bad] pam_selinux.so open
# Standard Un*x password updating.
@include common-password
auth [success=done default=ignore] pam_succeed_if.so user ingroup disable2fa
auth required pam_google_authenticator.so nullok
또 확인해야 할 곳이 있나요? 누구든지 도와줄 수 있나요? 감사해요!
답변1
이것이 바로 이 줄의 역할입니다:
auth [success=done default=ignore] pam_succeed_if.so user ingroup disable2fa
에서man pam.d
:
ok
this tells PAM that the administrator thinks this return code should contribute
directly to the return code of the full stack of modules. In other words, if the
former state of the stack would lead to a return of PAM_SUCCESS, the module's return
code will override this value. Note, if the former state of the stack holds some value
that is indicative of a modules failure, this 'ok' value will not be used to override
that value.
done
equivalent to ok with the side effect of terminating the module stack and PAM
immediately returning to the application.
본질적으로 success=done
이 모듈이 성공하면 더 이상 확인할 필요가 없으므로 pam_google_authenticator.so
이 모듈이 성공하면 후속 모듈을 건너뛰고 이 모듈은 다음 사항만 확인한다는 의미입니다.사용자는 그룹이다disable2fa
:
user ingroup group
User is in given group.
답변2
PAM 구성 파일에서 "user ingroup disable2fa" 줄을 구성 해제하고 다음 문서에 설명된 설정으로 바꿀 수 있습니다.
이렇게 하면 Google Authenticator 토큰(~/.google_authenticator 파일)을 구성한 사용자에게만 인증 코드를 요청하게 됩니다. 문서에서 nullok 인수를 찾을 때까지 "user ingroup" 설정은 나에게 물음표였습니다.
그것은 매력처럼 작동합니다!