OPENSSH-RSA κ°μΈν€λ₯Ό RSA κ°μΈν€λ‘ λ³κ²½νκΈ°
OpenSSL λΌμ΄λΈλ¬λ¦¬λ₯Ό ν΅ν΄ SSH μ μμ μν ν€ νμ΄λ₯Ό λ°κΈνλ κ²½μ°μ κΈ°λ³Έμ μΌλ‘ RSA νμμ ν€ νμ΄κ° μμ±λμ΄λ μ€μ λ‘λ OPENSSH PRIVATE KEYλ‘ μ μ₯λκ² λλ€. RSA PRIVATE KEYλ‘ μ μ₯λκΈ° μν΄μλ -m μ΅μ μΌλ‘ PEMμ μ§μ ν΄μΌ νλ€.
# ----- OPENSSH PRIVATE KEY -----
ssh-keygen -t rsa -b 2048 -C "mambo" -N ""
# ----- RSA PRIVATE KEY -----
ssh-keygen -t rsa -b 2048 -m PEM -C "mambo" -N ""
μΌλ³Έ κ³ κ°μΌλ‘λΆν° μ체μ μΌλ‘ ꡬμΆν μλ²μ μ μνκΈ° μν κ³μ κ³Ό κ°μΈν€ PEM νμΌμ λ°μ보λ OPENSSH νμμΌλ‘ μ μ₯λμ΄μμμ νμΈνμλ€. κ·Έλ¬λ, SecureCRTλ₯Ό μ¬μ©ν΄μ μλ²μ μ²μμΌλ‘ μ°κ²°νλ €κ³ νμλ ν€ νμμ΄ μ¬λ°λ₯΄μ§ μλ€λ μ€λ₯κ° λ°μνλ©° μ μμ μ€ν¨νμλ€.
-----BEGIN RSA PRIVATE KEY-----
[KEY CONTENT]
-----END RSA PRIVATE KEY-----
OPENSSH PRIVATE KEYλ‘ μ μ₯λμ΄μλ κ²μ RSA PRIVATE KEYλ‘ λ³κ²½νκ³ μλν΄λ³΄λ μ μμ μΌλ‘ μ°κ²°μ΄ λμμΌλ©° μμΈν μμΈμ λͺ¨λ₯΄κ² μΌλ 2FA μΈμ¦μ μ€μ νκ³ λμλ OPENSSH PRIVATE KEYλ‘ μ μ₯λμ΄μλ PEM νμΌλ‘λ μ°κ²°μ΄ μ μμ μΌλ‘ μ°κ²°μ ν μ μλ μν©μ΄ λμλ€.
OpenSSH κ°μΈν€λ₯Ό RSA κ°μΈν€λ‘ λ³ν
μ무νΌ, RSA PEM νμμΌλ‘ λ€μ λ§λ€μ΄λ¬λΌκ³ μμ²νκΈ°μλ μκ°μ΄ λ§μ΄ μμλ μ μμΌλ―λ‘ OPENSSH νμμΌλ‘ λμ΄μλ RSA κ°μΈν€λ₯Ό RSA PEM νμμΌλ‘ λ³νν΄λ³΄λλ‘ νμ.
ssh-keygen -t rsa -b 2048 -C "mambo" -N "" -f openssh.pem
# cat ~/.ssh/id_rsa
-----BEGIN OPENSSH PRIVATE KEY-----
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAABFwAAAAdzc2gtcn
NhAAAAAwEAAQAAAQEAw4o9aOfBCkCzsuz3hMJT/v058pMki16Ft56tim4r5mJRbBd0EQPJ
3gm1FiJmp0fqrnJo+H3o4hBH0LlCbeXiXHloPnTi1JZTSzWat1ItcBG+xezx8BdmtKqdTy
PWfYL9ujLse5AAXkvVHhYHJ7koV72X9whH94Tci4zAEHRypKbuz+9lj5P94u1n/nYAt2PT
JmdP/Y+62qFiSGhKEh/Jed5TVvIrabOi+qcHQ0VmcXkTGiOTXLTmHMbce26dqsGRRb4YPf
1alXECX28b8QpbarlXHPeGJyQ5d8dxEhsOz60LDoUEy/ytn0gIrP0+Ro2aS9N73JVdTXKu
FFQRyHMP0QAAA8DEFEvUxBRL1AAAAAdzc2gtcnNhAAABAQDDij1o58EKQLOy7PeEwlP+/T
nykySLXoW3nq2KbivmYlFsF3QRA8neCbUWImanR+qucmj4fejiEEfQuUJt5eJceWg+dOLU
llNLNZq3Ui1wEb7F7PHwF2a0qp1PI9Z9gv26Mux7kABeS9UeFgcnuShXvZf3CEf3hNyLjM
AQdHKkpu7P72WPk/3i7Wf+dgC3Y9MmZ0/9j7raoWJIaEoSH8l53lNW8itps6L6pwdDRWZx
eRMaI5NctOYcxtx7bp2qwZFFvhg9/VqVcQJfbxvx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ήμ΄λ€μ μ€ννμ¬ λ³νλλμ§ νμΈν΄λ³΄λ©΄ λλ€.
# [1] OpenSSH
sudo ssh-keygen -p -m PEM -f openssh.pem
# [2] OpenSSL
openssl rsa -in openssh.pem -outform pem > openssh-rsa.pem
# [3] Putty
puttygen openssh.pem -O private-openssh -o openssh-rsa.pem
[1] OpenSSH
ssh-keygen -p -m PEM -f openssh.pem
Failed to load key openssh.pem: invalid format
첫λ²μ§Έ OpenSSH λͺ λ Ήμ΄λ₯Ό μ΄μ©νλ λ°©λ²μ κ°μ νκ²½μ μ€νν μ°λΆν¬ 리λ μ€μμλ μ μμ μΌλ‘ λ³νλ λ°λ©΄μ μλμ° ν°λ―Έλμμλ μ μ μλ νμμ΄λΌλ μ€λ₯ λ©μμ§μ ν¨κ» μ€ν¨νμλ€.
[2] OpenSSL π₯
openssl rsa -in openssh.pem -outform pem > openssh-rsa.pem
unable to load Private Key
140038194394432:error:0909006C:PEM routines:get_name:no start line:../crypto/pem/pem_lib.c:745:Expecting: ANY PRIVATE KEY
λλ²μ§Έ OpenSSL λΌμ΄λΈλ¬λ¦¬λ₯Ό μ΄μ©νλ λ°©λ²μ ChatGTPμμ μλ €μ€ κ²μΈλ° OpenSSHλ OpenSSL λΌμ΄λΈλ¬λ¦¬λ₯Ό νμ©νκΈ°λ νλ OpenSSH νλ‘κ·Έλ¨μμ μΈμνλ νμμ΄λ―λ‘ λ³ννλ κ³Όμ μμ μ€λ₯κ° λ°μνμλ€.
[3] Putty π
# [Mac] brew install putty
# [Ubuntu] apt install putty-tools
puttygen openssh.pem -O private-openssh -o openssh-rsa.pem
μΈλ²μ§Έ λ°©λ²μ PuTTYgenμ μ΄μ©νλ κ²μΌλ‘ μλμ° νκ²½μμλ 컀맨λλΌμΈ μ΅μ μ μΈμνμ§ λͺ»ν κ΄κ³λ‘ PuTTYgen(PuTTY Key Generator)μ μ€νν ν Conversions λ©λ΄μ Import Keyλ‘ λΆλ¬μ¨ ν Export OpenSSH Keyλ‘ μ μ₯νλ©΄ RSA PRIVATE KEYλ‘ λ³νν μ μμμΌλ©° μ°λΆν¬ 리λ μ€μμλ 컀맨λλΌμΈμΌλ‘ λ³λ€λ₯Έ λ¬Έμ μμ΄ λ³νν μ μλ€.
κ°μΈμ μΌλ‘λ μ€λλ λ΄μ©μ΄μ§λ§ νλ² νκ³ λμλ λμ΄μ λ€λ£¨μ§ μλ μ 보μ΄κΈ°μ μμ΄λ²λ¦΄ κ² κ°μ κΈ°λ‘μΌλ‘ λ¨κΈ°κ³ μ 곡μ νλ€.