본문 바로가기

리눅스

[리눅스] Google OTP를 설치하는 방법

728x90

Google OTP를 설치하는 방법

google-authenticator 패키지 설치

$ yum install -y google-authenticator

Google Authenticator 인증 파일 생성(QR Code 생성)

$ google-authenticator -s ~/.ssh/google_authenticator

Do you want authentication tokens to be time-based (y/n) y

Do you want me to update your "/home/ec2-user/.ssh/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

ssh 서버의 설정 파일(sshd_config 편집)

$ vim /etc/ssh/sshd_config
...
PermitEmptyPasswords no
PasswordAuthentication no
ChallengeResponseAuthentication yes
UsePAM yes
AuthenticationMethods publickey,password publickey,keyboard-interactive

SSH 인증을 위한 PAM 모듈 설정(sshd 편집)

$ vim /etc/pam.d/sshd
#%PAM-1.0
auth       required     pam_sepermit.so
#auth       substack     password-auth
auth       include      postlogin
### Google Authenticator(Google OTP) ###
auth       required     pam_google_authenticator.so secret=/home/${USER}/.ssh/google_authenticator nullok
...

sshd 데몬(서비스) 재기동

$ systemctl restart sshd

SecureCRT 설정

Connection > SSH2 > Authentication

- Keyboard Interactive

- PublicKey

SecureCRT SSH 접속

OTP 코드 입력

728x90