ssh-keygen
OpenSSH 키 쌍 생성, 패스프레이즈 변경, fingerprint 확인, known_hosts 정리, SSH certificate/KRL 작업에 사용하는 도구다.
Summary
가장 흔한 용도는 사용자 SSH 키 생성이다. 일반 사용자 키는 보통 ed25519를 우선 고려하고, 구형 장비 호환이 필요할 때만 rsa를 검토한다.
dsa는 레거시로 취급하는 편이 안전하다. 기존 사용 기록은 보존하되, 새 키 생성 예제의 기본값으로 추천하지 않는다.
Usage
ssh-keygen [-q] [-b bits] [-t dsa | ecdsa | ed25519 | rsa] [-m format] [-N new_passphrase] [-C comment] [-f output_keyfile] ssh-keygen -p [-P old_passphrase] [-N new_passphrase] [-m format] [-f keyfile] ssh-keygen -i [-m key_format] [-f input_keyfile] ssh-keygen -e [-m key_format] [-f input_keyfile] ssh-keygen -y [-f input_keyfile] ssh-keygen -c [-P passphrase] [-C comment] [-f keyfile] ssh-keygen -l [-v] [-E fingerprint_hash] [-f input_keyfile] ssh-keygen -B [-f input_keyfile] ssh-keygen -D pkcs11 ssh-keygen -F hostname [-f known_hosts_file] [-l] ssh-keygen -H [-f known_hosts_file] ssh-keygen -R hostname [-f known_hosts_file] ssh-keygen -r hostname [-f input_keyfile] [-g] ssh-keygen -G output_file [-v] [-b bits] [-M memory] [-S start_point] ssh-keygen -T output_file -f input_file [-v] [-a rounds] [-J num_lines] [-j start_line] [-K checkpt] [-W generator] ssh-keygen -s ca_key -I certificate_identity [-h] [-U] [-D pkcs11_provider] [-n principals] [-O option] [-V validity_interval] [-z serial_number] file ... ssh-keygen -L [-f input_keyfile] ssh-keygen -A ssh-keygen -k -f krl_file [-u] [-s ca_public] [-z version_number] file ... ssh-keygen -Q -f krl_file file ...
ssh-keygen [<switches>…] ARGSssh-keygen -t type -f output_keyfile -C comment: 새 키 쌍 생성ssh-keygen -p [<switches>…] keyfile: 패스프레이즈 변경ssh-keygen -y -f input_keyfile: 개인 키에서 공개 키 추출ssh-keygen -l [<switches>…] -f input_keyfile: fingerprint 출력ssh-keygen -F hostname [-f known_hosts_file] [-l]:known_hosts검색ssh-keygen -R hostname [-f known_hosts_file]:known_hosts에서 항목 삭제
Options
Key generation
-q: 진행 메시지를 줄여 조용히 실행-b bits: 키 길이 지정-t dsa | ecdsa | ed25519 | rsa: 키 타입 선택-m format: 키/변환 포맷 지정-N new_passphrase: 새 패스프레이즈 지정-C comment: 키 comment 설정-f output_keyfile: 출력 키 파일 경로
Key maintenance
-p: 기존 키의 패스프레이즈 변경-P old_passphrase: 현재 패스프레이즈 입력-c: 키 comment 변경-i: 외부 포맷 키를 OpenSSH 형식으로 import-e: OpenSSH 키를 외부 포맷으로 export-y: 공개 키만 다시 출력
Inspection
-l: fingerprint 출력-v: ASCII randomart 등 자세한 정보 출력-E fingerprint_hash: fingerprint hash 알고리즘 지정-B: bubblebabble fingerprint 출력-L: certificate 내용 표시
known_hosts and DNS
-F hostname:known_hosts에서 호스트 검색-H:known_hosts파일의 호스트명을 hash 처리-R hostname:known_hosts에서 호스트 삭제-r hostname: DNSSSHFP레코드 출력-g:SSHFP생성 시 generic 형식 사용
Advanced / PKI
-D pkcs11: PKCS#11 provider 읽기-G output_file: moduli 후보 생성-T output_file -f input_file: moduli 후보 검증-a rounds: KDF / screening rounds 지정-J num_lines: 검증 line 수 지정-j start_line: 시작 line 지정-K checkpt: checkpoint 파일 지정-M memory: 메모리 사용량 지정-S start_point: 시작점 지정-W generator: generator 지정-s ca_key: SSH certificate 서명-I certificate_identity: certificate ID 지정-h: host certificate로 서명-U: agent 사용 허용-D pkcs11_provider: certificate 서명 시 provider 지정-n principals: 허용 principal 목록 지정-O option: certificate option 지정-V validity_interval: certificate 유효기간 지정-z serial_number: certificate / KRL serial 또는 version 지정-A: 기본 host key 일괄 생성-k -f krl_file file …: KRL(Key Revocation List) 생성-u: 기존 KRL 업데이트-s ca_public: KRL 생성 시 CA 공개 키 사용-Q -f krl_file file …: KRL로 revoke 여부 확인
Examples
# 일반 사용자용 새 키 생성 ssh-keygen -t ed25519 -C "[email protected]" # 파일명을 명시해 RSA 키 생성 ssh-keygen -t rsa -b 4096 -f ~/.ssh/id_rsa_work -C "work key" # 기존 개인 키의 패스프레이즈 변경 ssh-keygen -p -f ~/.ssh/id_ed25519 # 개인 키에서 공개 키 다시 추출 ssh-keygen -y -f ~/.ssh/id_ed25519 > ~/.ssh/id_ed25519.pub # fingerprint 확인 ssh-keygen -l -E sha256 -f ~/.ssh/id_ed25519.pub # known_hosts 에서 특정 호스트 제거 ssh-keygen -R example.com # DNS SSHFP 레코드 출력 ssh-keygen -r example.com -f ~/.ssh/id_ed25519.pub
Compatibility
- 최신 기본값으로는 보통
ed25519가 무난하다. - 구형 네트워크 장비나 오래된 서버 호환이 필요하면
rsa가 여전히 필요할 수 있다. dsa는 신규 생성 기본값으로 권장하지 않는다.
Help
See Also
History
- codex:: 2026-06-29 Reorganized page structure, preserved existing command coverage, and refreshed examples and compatibility notes.