1. Google OTP authenticator 설치
1-1. yum update
sudo yum update
1-2. google-authenticator 설치
sudo yum install google-authenticator -y
1-3 Google authenticator 어플리케이션 설치
- 모바일 app
2. Linux 사용자 생성
2-1. 사용자 및 홈디렉토리 생성
sudo useradd -m [username]
-m 옵션이 사용자 홈 디렉토리 생성 옵션
2-2. 생성된 사용자 비밀번호 설정
sudo passwd [username]
2-3. 사용자 sudo 권한 부여
# sudoers 파일 확인
ls -al /etc/sudoers
# sudoers 파일 권한 변경
chmod +w /etc/sudoers
# root 아래에 사용자 추가
root ALL=(ALL) ALL
[username] ALL=(ALL) ALL
# sudoers 파일 w 권한 원상복구
chmod -w /etc/sudoers
3. Google OTP 생성
3-1. google authenticator 실행
google-authenticator
- 실행 시 나오는 QR코드를 어플로 스캔하면 등록된다.
3-2. 세부 옵션 설정
4. PAM 모듈 수정
4-1. /etc/pam.d/sshd 수정
sudo vim /etc/pam.d/sshd
4-2. auth 항목에 아래 옵션 추가
auth required pam_google_authenticator.so nullok
5. sshd_config 옵션 수정
5-1.
sudo vi /etc/ssh/sshd_config
# 위 파일에서 아래 옵션 수정 (no --> yes)
ChallengeResponseAuthentication yes
5-2. sshd 재시작
sudo systemctl restart sshd
6. 보안그룹 수정
6-1 접속하고자 하는 외부 컴퓨터의 IP 확인
hostname -I
6-2. 인스턴스 보안그룹 인바운드 규칙에 해당 IP 추가
7. ssh 접속
7-1. Verification code 에 otp 토큰 입력
'Linux' 카테고리의 다른 글
[Linux] CentOS에서 Quantum Espresso 컴파일 에러 해결 (0) | 2024.04.17 |
---|---|
터미널(bash script)에서 slack으로 메세지 전송하기 (0) | 2023.10.06 |