본문 바로가기
리눅스/Part3. Ch05. 사용자 관리

04. (실습) SSH 접속에 Multi-Factor Authentication 적용

by Engineer-Lee 2022. 12. 14.
반응형

SSH 접속에 MFA까지 적용?
-> 주로, Bastion 서버가 대상

 

보안 관련 권장 사항

- 모든 자원은 Private Subnet에 생성
예외) ELB, NAT Gateway
- AWS 내부의 있는 자원을 연결할 때도 외부로 라우팅 되지 않도록 구성

 

 

 

 

 

 

 

 

 

Bastion 서버 접근에 MFA까지 적용?

 

Bastion 서버 연결을 안전하게 구성

- 방법: Port 변경, Security Group 인바운드 룰, VPN, 관리용 VPC, MFA 등

 

 


Bastion 서버 접근을 강화해 보자

OTP적용을 통한 이중 인증 SSH 접근 구성해보기

- ssh 로 서버 접근 시 OTP 패스워드를 확인
- 실습 링크:
https://github.com/go4real/linux_campus/blob/main/Part3/Ch05_04/otp_setting.md
* 실습은 새로운 인스턴스 생성 후 진행
à ssh 설정 오류 시 서버 접속이 제한


[실습] Bastion Host에 MFA 설정하기 


0. 데모용 EC2 인스턴스 생성
 + Ubuntu 20.04 

1. google authenticator 패키지 설치

sudo apt update
sudo apt install -y libpam-google-authenticator


2. MFA 앱 설치
 + https://chrome.google.com/webstore/category/extensions


3. google authenticator 초기화 

google-authenticator


4. PAM(Pluggable Authentication Module) 정보 백업
sudo cp /etc/pam.d/sshd /etc/pam.d/sshd.bak


5. google authenticator 관련 인증 정보 추가
 + sudo vim /etc/pam.d/sshd

# Standard Un*x authentication.
#@include common-auth   # 주석처리

# Standard Un*x password updating.
@include common-password
auth required pam_google_authenticator.so 
auth required pam_permit.so


6. sshd 설정 정보 백업

sudo cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak


7. sshd 설정 정보 변경
 + sudo vim /etc/ssh/sshd_config

# Change to yes to enable challenge-response passwords (beware issues with
# some PAM modules and threads)
ChallengeResponseAuthentication yes

AuthenticationMethods publickey,password publickey,keyboard-interactive


8. ssh 서비스 재시작

sudo systemctl restart sshd.service


9. ssh 연결 후 MFA 정보 확인


10. 데모용 EC2 인스턴스 삭제

반응형