C.W.K.
Stream
Lesson 07 of 14 · published

SSH 인증서

~18 min · ssh-ca, certificates, principal, expiration

Level 0Pinger
0 XP0/101 lessons0/12 achievements
0/150 XP to next level150 XP to go0% complete

Raw 키 너머 — 서명된 인증서

SSH 인증서 가 Certificate Authority (CA) 가 user 와 host 키 서명, 정체성 ("principal"), 범위, 만료 날짜 임베드. 모든 서버의 모든 ~/.ssh/authorized_keys 에 public key 배포 대신 모든 서버가 CA 의 public key 신뢰 — 그리고 CA-서명 인증서 가진 어느 user 든 로그인 가능.

authorized_keys 보다 잘 확장하는 이유

  • 만료 — 인증서 자동 만료, 수동 rotation 불필요. 30 일 cert 발급, 30 일 후 서버가 신뢰 멈춤, 끝.
  • cert 의 정체성 — "이 cert 는 principal you_username 거" — 서버가 허용 user 와 매칭.
  • 단일 신뢰 지점 — 서버당 N user 키 vs 모든 서버에 한 CA public key.
  • KRL 통한 revocation — Key Revocation List 가 만료 전 specific cert 무효화 가능.

Code

CA 셋업과 user 키 서명·bash
# Generate the CA key pair (do this ONCE, protect the CA private key like gold)
ssh-keygen -t ed25519 -f ca_key -C 'Fleet CA'

# Sign a user's public key
ssh-keygen -s ca_key \
    -I 'you_username@office-2026' \
    -n you_username \
    -V +52w \
    ~/.ssh/id_ed25519.pub

# This produces: ~/.ssh/id_ed25519-cert.pub
# -s  CA private key (signing)
# -I  identity / cert serial (shows in logs)
# -n  principals (which usernames this cert can log in as)
# -V  validity window (+52w = expires in 52 weeks)
모든 서버에서 CA 신뢰·bash
# Copy the CA PUBLIC key to each server (NOT the private key — that stays on the CA host)
scp ca_key.pub server:/tmp/

# On the server
sudo mv /tmp/ca_key.pub /etc/ssh/ca_key.pub
sudo chown root:root /etc/ssh/ca_key.pub
sudo chmod 644 /etc/ssh/ca_key.pub

# Tell sshd to trust certificates signed by it
echo 'TrustedUserCAKeys /etc/ssh/ca_key.pub' | \
    sudo tee -a /etc/ssh/sshd_config
sudo sshd -t
sudo systemctl restart sshd

# Verify a cert
ssh-keygen -L -f ~/.ssh/id_ed25519-cert.pub

External links

Exercise

별도 머신 (일상 노트북 X) 에 SSH CA 셋업. 노트북의 ~/.ssh/id_ed25519.pub-V +1d (1 일 유효) 로 서명. 한 테스트 서버에 CA 신뢰. SSH — authorized_keys 에 키 listed 안 돼도 동작해야. 한 시간 기다리고 cert 에 ssh-keygen -L -f 돌려 유효 window 봐. 내일 재시도 — 실패 (cert 만료). 그게 자동 rotation 속성 동작.

Progress

Progress is local-only — sign in to sync across devices.
이 페이지에서 버그를 발견하셨거나 피드백이 있으세요?문제 신고

댓글 0

🔔 답글 알림 (로그인 필요)
로그인댓글을 남기려면 로그인해 주세요.

아직 댓글이 없어요. 첫 댓글을 남겨보세요.