목차
본문으로 바로가기

[OCI] DBCS, Compute, Exa User Passwd 로그인 설정

category Cloud/OCI 2025. 6. 1. 10:55

개요

  • OCI 리눅스 인스턴스는 기본적으로 SSH Key Pair을 사용합니다. Key 방식이 아닌 패스워드 방식으로 적용하기 위해서는 최소 1회 로그인 해야 합니다.

방법

사전 작업

  1. 사용자 추가
sudo useradd testuser
  1. 사용자 패스워드 변경
  • 패스워드 복잡성 설정은 /etc/security/pwquality.conf에서 확인 가능
cat /etc/security/pwquality.conf

예시 설정 항목:

  • 최소 길이: minlen=15
  • 동일 문자 반복 제한: maxrepeat=3
  • 최소 숫자: dcredit=-1
  • 최소 특수문자: ocredit=-1
  • 최소 대문자: ucredit=-1
  • 최소 소문자: lcredit=-1
  • 최소 문자 유형 수: minclass=4

패스워드 변경:

sudo passwd testuser

Compute Instance / ExaCS

  1. 계정 패스워드 설정
sudo passwd opc
  1. /etc/ssh/sshd_config 수정
sudo vi /etc/ssh/sshd_config
# 기존
PasswordAuthentication no
# 변경
PasswordAuthentication yes
  1. sshd 서비스 재시작 및 확인
sudo systemctl restart sshd
sudo systemctl status sshd
  1. 터미널 접속 테스트
ssh opc@<IP주소>

Oracle Linux 9.3 이상 (Match User 필요)

  1. /etc/ssh/sshd_config 수정
# 기존 설정 유지
PasswordAuthentication no

# 파일 마지막에 추가
Match User opc
    PasswordAuthentication yes
Match all
  1. 서비스 재시작 및 상태 확인
sudo systemctl restart sshd
sudo systemctl status sshd

DBCS 환경 설정

  1. 계정 패스워드 설정
sudo passwd opc
  1. /etc/ssh/sshd_config 수정
# grid, oracle 이외 유저는 명시적으로 추가 필요
AllowUsers opc testuser
  1. 서비스 재시작 및 상태 확인
sudo systemctl restart sshd
sudo systemctl status sshd
  1. SSH 접속 테스트
ssh opc@<IP주소>

ETC: DBCS에서 패스워드 인증 오류 발생 시

1. 패스워드 변경 시 오류

passwd: Authentication token manipulation error

2. 원인: PAM 설정 파일 순서 문제

  • 확인 파일:
    • /etc/pam.d/password-auth
    • /etc/pam.d/system-auth

3. 수정 예시

# 수정 전
password requisite pam_pwquality.so ...
password required  pam_deny.so
password sufficient pam_unix.so ...

# 수정 후
password requisite pam_pwquality.so ...
password sufficient pam_unix.so ...
password required  pam_deny.so

Cloud-init 기반 사용자 자동 추가 스크립트

OCI, AWS, Azure 등의 클라우드 인스턴스는 cloud-init을 통해 인스턴스 생성 시 사용자 및 SSH 설정을 자동화할 수 있습니다.

사용자 생성 + 패스워드 로그인 허용 예시

#cloud-config
users:
  - name: testuser
    gecos: "Test User"
    sudo: ALL=(ALL) NOPASSWD:ALL
    shell: /bin/bash
    lock_passwd: false
    plain_text_passwd: "TestPassword123!"
    ssh-authorized-keys:
      - ssh-rsa AAAAB3...your_ssh_key_here

ssh_pwauth: true

runcmd:
  - sed -i 's/^PasswordAuthentication no/PasswordAuthentication yes/' /etc/ssh/sshd_config
  - systemctl restart sshd

위 cloud-init 스크립트는 "testuser"라는 계정을 생성하고, SSH 패스워드 인증을 허용합니다.
plain_text_passwd는 보안상 비추천이며, 테스트 환경 또는 초기 설정 후 변경을 권장합니다.


참고 문서