EC2접근 시 보안강화를 위해 KEY인증 + 암호 + OTP 인증을 적용할 수 있습니다.
ubuntu 서버 기준으로 설명드리며, Amazon Linux는 아래 url을 참고하시기 바랍니다.

< 목표 구성도 >

1. google-authenticator 설치 및 구성

ubuntu@ip-10-10-11-8:~$ sudo apt-get update
ubuntu@ip-10-10-11-8:~$ sudo apt-get install libpam-google-authenticator -y
ubuntu@ip-10-10-11-8:~$ google-authenticator
Do you want authentication tokens to be time-based (y/n) y

Do you want me to update your "/home/ubuntu/.google_authenticator" file? (y/n) y
Do you want to disallow multiple uses of the same authentication
token? This restricts you to one login about every 30s, but it increases
your chances to notice or even prevent man-in-the-middle attacks (y/n) y
By default, a new token is generated every 30 seconds by the mobile app.
In order to compensate for possible time-skew between the client and the server,
we allow an extra token before and after the current time. This allows for a
time skew of up to 30 seconds between authentication server and client. If you
experience problems with poor time synchronization, you can increase the window
from its default size of 3 permitted codes (one previous code, the current
code, the next code) to 17 permitted codes (the 8 previous codes, the current
code, and the 8 next codes). This will permit for a time skew of up to 4 minutes
between client and server.
Do you want to do so? (y/n) n
If the computer that you are logging into isn't hardened against brute-force
login attempts, you can enable rate-limiting for the authentication module.
By default, this limits attackers to no more than 3 login attempts every 30s.
Do you want to enable rate-limiting? (y/n) y

2. Google Pluggable 인증 모듈을 사용하도록 SSH 구성

ubuntu@ip-10-10-11-8:~$ sudo vi /etc/pam.d/sshd

auth required
auth required

ubuntu@ip-10-10-11-8:~$ sudo vi /etc/ssh/sshd_config

ChallengeResponseAuthentication yes
#ChallengeResponseAuthentication no

AuthenticationMethods publickey,keyboard-interactive

ubuntu@ip-10-10-11-8:~$ sudo service sshd restart

3. 접속 확인

[ubuntu20.04] 서버 2FA 적용

답글 남기기

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다