
MFA 인증을 위해 Google 인증자를 성공적으로 설치한 Ubuntu 20.04.3 LTS가 있습니다. 이제 인증 단계에 대한 도움이 필요합니다. 내 목표는 다음과 같습니다.
사용자에게 SSH 키가 없는 경우 SSH 연결 시 사용자는 먼저 비밀번호를 입력한 다음 Google 확인 키를 입력하여 시스템에 액세스해야 합니다.
사용자에게 SSH 키가 있는 경우 비밀번호를 입력할 필요는 없지만 Google 확인 키를 입력해야 합니다.
이것이 가능합니까? 그렇다면 어떤 종류의 설정을 지정해야 합니까 /etc/ssh/sshd_config
?/etc/pam.d/sshd
내 기존 /etc/pam.d/sshd
구성 은 다음과 같습니다.
# Standard Un*x password updating.
@include common-password
# Standard Un*x authentication.
@include common-auth
# Standard Un*x authentication.
auth required pam_google_authenticator.so nullok user=root secret=/root/totp/${USER}
auth required pam_permit.so
그리고 여기 /etc/ssh/sshd_config
파일이 있습니다
ChallengeResponseAuthentication yes
UsePAM yes
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
PermitRootLogin yes
PasswordAuthentication no
AuthenticationMethods publickey,keyboard-interactive
답변1
모든 것이 올바르게 설치되었다고 가정합니다. 즉, 다음과 같이 설치되었습니다.
sudo apt-get install libpam-google-authenticator
그리고 코드를 받았어요
google-authenticator
그리고 홈 폴더에 코드가 있습니다
ls /home/$USER/.google_authenticator
그런 다음 /etc/pam.d/sshd에 다음 두 줄을 추가해야 합니다.
...
# Standard Un*x password updating.
@include common-password
auth required pam_google_authenticator.so
auth required pam_permit.so
...
또는 일부 사용자에게 MFA를 선택적으로 적용하려는 경우
...
# Standard Un*x password updating.
@include common-password
auth required pam_google_authenticator.so nullok
auth required pam_permit.so
...
/etc/ssh/sshd_config 파일에서 다음을 변경합니다.
ChallengeResponseAuthentication yes
그 다음에:
sudo systemctl restart sshd.service
테스트할 때 SSH 연결을 끊지 마십시오.새 것을 시작하세요. 구성이 잘못되면 계정이 잠길 수 있습니다.
답변2
KbdInteractiveAuthentication
in /etc/ssh/sshd_config
또한 매우 중요하며
우분투 22.04에서 테스트되었습니다.
# Change to yes to enable challenge-response passwords (beware issues with
# some PAM modules and threads)
# KbdInteractiveAuthentication no
KbdInteractiveAuthentication yes