ssh-keygen -y 오류: 로드 실패

ssh-keygen -y 오류: 로드 실패

RSA키 쌍의 정확성을 확인하고 싶습니다 . 내가 아는 한, 다음 명령을 사용하여 개인 키에서 공개 키를 만든 다음 두 공개 키가 같은지 비교할 수 있습니다.

ssh-keygen -y -f <PRIVATE-KEY>

문제는 위 명령을 사용할 때 키를 로드하지 못하는 이유는 무엇입니까?

여기에 이미지 설명을 입력하세요.

RSA 키 쌍의 정확성을 확인하는 다른 방법이 있습니까?


참고로:

root@bt:~# ssh-keygen -y -v -f /root/Desktop/PROIVA 
debug1: PEM_read_PrivateKey failed
debug1: read PEM private key done: type <unknown>
Enter passphrase: 
debug1: PEM_read_PrivateKey failed
debug1: read PEM private key done: type <unknown>
load failed
root@bt:~# file /root/Desktop/PROIVA 
/root/Desktop/PROIVA: data
root@bt:~# 

root@bt:~# openssl rsa -in /root/Desktop/PROIVA -inform der -noout -text
unable to load Private Key
1819:error:0D094065:asn1 encoding routines:d2i_ASN1_SET:bad class:a_set.c:190:
1819:error:0D0680A8:asn1 encoding routines:ASN1_CHECK_TLEN:wrong tag:tasn_dec.c:1316:
1819:error:0D07803A:asn1 encoding routines:ASN1_ITEM_EX_D2I:nested asn1 error:tasn_dec.c:380:Type=RSA
1819:error:0D09A00D:asn1 encoding routines:d2i_PrivateKey:ASN1 lib:d2i_pr.c:99:
root@bt:~# 
root@bt:~# 
root@bt:~# openssl rsa -in /root/Desktop/PROIVA -inform DER -out /root/Desktop/PROIVA.pem -outform PEM
unable to load Private Key
1820:error:0D094065:asn1 encoding routines:d2i_ASN1_SET:bad class:a_set.c:190:
1820:error:0D0680A8:asn1 encoding routines:ASN1_CHECK_TLEN:wrong tag:tasn_dec.c:1316:
1820:error:0D07803A:asn1 encoding routines:ASN1_ITEM_EX_D2I:nested asn1 error:tasn_dec.c:380:Type=RSA
1820:error:0D09A00D:asn1 encoding routines:d2i_PrivateKey:ASN1 lib:d2i_pr.c:99:
root@bt:~# 
root@bt:~# 

그러나 다음 명령을 사용하면 Proiva.der데스크탑에 생성됩니다.

root@bt:~# openssl base64 -in /root/Desktop/PROIVA -out /root/Desktop/Proiva.der
root@bt:~# 

root@bt:~# openssl rsa -in /root/Desktop/Proiva.der -inform der -noout -text
unable to load Private Key
1826:error:0D094065:asn1 encoding routines:d2i_ASN1_SET:bad class:a_set.c:190:
1826:error:0D0680A8:asn1 encoding routines:ASN1_CHECK_TLEN:wrong tag:tasn_dec.c:1316:
1826:error:0D07803A:asn1 encoding routines:ASN1_ITEM_EX_D2I:nested asn1 error:tasn_dec.c:380:Type=RSA
1826:error:0D09A00D:asn1 encoding routines:d2i_PrivateKey:ASN1 lib:d2i_pr.c:99:
root@bt:~# 

내 공개/개인 파일에 대한 Base64 보기는 다음과 같습니다.

사적인:

m37jkNportKxhOtP84bKXPY5JR16dzt2ZgdnGNrx7Q9u31jkn2lUPxDwdjlTzU8sIWUxHP4inC56
sxlbv9oeQQxhzF0CxclBuiR1kkfzRVMoEiXmacbozqM4+oh/+Bd1+jok25BQPnXkOq5tu/SIclkv
9zL20p+YsqL0esPUJvcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAASN5x6F8svVvzGBu70a4MeMTqeX128LoJhMRDUx2
Z0uWgc0jEsXr2fSpgLL4UU4+Cet0ksfykyLe18+UsYIL2WrSvEIQRspgq3u5sYGSyn4tWs701V76
cOR/j//O1rCPp/ose/2L+muW28D8wMwq2jIZog7HKMGzgj1KiLuNhICBzXfh3UqoiOArZWVY48Vm
/ZAp9+YhsiAKQ8Z0mpL9mxCmdD24HxGiGJ7uZW4a8X4bRPj0SZYlCbiL3X8Glq3ImcG8xSo7+PaX
CcuTQAeER/EtIdnTkES5/ge1YEg3OjTAG6zeVmV3L/901G0g5bWK3ynJBB+gWuskNnD7K7+SVg8M
n0K2z3FPB0ZjMjiltWjARuztF6wWPzWiODzNih4eOoWfOnNnJTQqAwluHbd2AmM2d3y6UIjx8e5V
qwoCk6ZxrPAZu/Ke8Vev2bYO0Obm5UWZUv1EaeTw+uaQFMafwZi+25f43UgAY3NhcCyOgHh/bqhO
cwDMR9wicMX0rmQtRwmMjZSf0OE0r1NE058hACna/y1zKu5+lEw2pHi1i6SuiE/FebJ4yCTd7BqN
NDbDk5C6aE/J9R9X57as5YcFXwM=

사람들:

m37jkNportKxhOtP84bKXPY5JR16dzt2ZgdnGNrx7Q9u31jkn2lUPxDwdjlTzU8sIWUxHP4inC56
sxlbv9oeQQxhzF0CxclBuiR1kkfzRVMoEiXmacbozqM4+oh/+Bd1+jok25BQPnXkOq5tu/SIclkv
9zL20p+YsqL0esPUJvcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAQ==

다음을 통해 위 파일의 base64 보기를 생성했습니다.이것온라인 도구.

답변1

파일이 DER바이너리 형식인 것 같습니다. 먼저 파일을 형식 등으로 변환해야 합니다 PEM.

파일이 DER바이너리 형식인지 확인하려면 다음을 실행하세요.

openssl rsa -in /root/Desktop/PROIVA -inform der -noout -text

다음과 같은 결과가 반환되면 실제로 DER잘 구성된 것입니다.

Private-Key: (1024 bit)
modulus:
    00:a9:07:0c:59:20:6f:48:c0:34:59:c1:10:17:f5:
................................
..............................

다음 명령을 실행하십시오.

 openssl rsa -in /root/Desktop/PROIVA -inform DER -out /root/Desktop/PROIVA.pem -outform PEM

이제 PROVIA파일이 형식으로 변환되었습니다 PEM.

마침내 도망쳤다.

ssh-keygen -y -v -f /root/Desktop/PROIVA.pem

관련 정보