본문 바로가기

Cloud/Oracle Cloud Infrastructure (OCI)

OCI 리눅스 인스턴스 SSH 접속에 패스워드 인증으로 변경하는 방법

아래 MOS 문서를 참조했습니다.

How To Connect To An OCI or OCI-Classic Linux Instance Using SSH Password Authentication Instead Of SSH Keys. (Doc ID 2408800.1)

 

OCI 리눅스 인스턴스로의 SSH 접속은 디폴트로 SSH Key Pair 인증방식을 사용합니다. 패스워드 인증으로 변경하는 방법을 살펴보겠습니다.

패스워드 인증으로 변경하기 위해서, Private Key로 한번은 로그인이 되어야 합니다. 우선 OCI 디폴트 유저인 opc 유저로 로그인을 해서 패스워드를 변경합니다. 여기서는 opc 유저에 대한 인증 방식을 변경하고 있지만, 유저를 새로 만들어서 패스워드 인증방식을 사용할 수도 있습니다.

[opc@inst-dbee ~]$ sudo passwd opc
Changing password for user opc.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.

 

/etc/ssh/sshd_config 파일을 열어서 "no"로 세팅되어 있는 PasswordAuthentication 값을 "yes"로 변경합니다.

# To disable tunneled clear text passwords, change to no here!
#PasswordAuthentication yes
#PermitEmptyPasswords no
PasswordAuthentication yes

 

"/sbin/sshd -t" 명령으로 SSHD 설정 파일 변경에 따른 에러는 없는지 체크한 다음, SSHD 서비스를 Restart합니다.

[opc@inst-dbee ~]$ sudo /sbin/sshd -t
[opc@inst-dbee ~]$ sudo systemctl restart sshd
[opc@inst-dbee ~]$ sudo systemctl status sshd
● sshd.service - OpenSSH server daemon
   Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; vendor preset: enabled)
   Active: active (running) since Fri 2021-09-10 02:39:03 GMT; 11s ago
     Docs: man:sshd(8)
           man:sshd_config(5)
 Main PID: 7181 (sshd)
   Memory: 1.3M
   CGroup: /system.slice/sshd.service
           └─7181 /usr/sbin/sshd -D

...

 

새로운 ssh 터미널을 열어서 다시 로그인을 하면, 패스워드 인증으로 접속할 수 있게 됩니다.