TritonDataCenter / node-sshpk

Parse, convert, fingerprint and use SSH keys in pure node.js
MIT License
189 stars 50 forks source link

OpenSSH -> PKCS1 conversion incompatible with ssh-keygen #71

Open Eugeny opened 4 years ago

Eugeny commented 4 years ago

Private key:

-----BEGIN OPENSSH PRIVATE KEY-----
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAABFwAAAAdzc2gtcn
NhAAAAAwEAAQAAAQEAuvq/+aVmHUmAI2h7zUD3ECwQUSLE8RUooADY//GB79NxLcPK1Yst
HL8TFyxDNOwGn8T7vLxgW6sKMKychwk4j19mLmzuOwWh2GR+SMcoTK7v45OA/ltwdbHfE/
UasUPUKboy7xy6YW+l4o/QcmnBYGpgxBFCa1PMLVyZ2a72xJRUVkzFhSNeIvqUGe8dzbt8
tqx6G8b1pU97uDvsDObZ3ZgrPGrCzGjPrWefa1Ch8R50YpLzGI/lmp2RYMPjdEdQDbQOu/
mVf5JPxJVLZHHpFCNcOV7AbwwoshiCTPTaJYpb5dkWhltaeXTHed2KyfJDbU61ycYmwJhs
gWx76AnPzwAAA9CSbRSakm0UmgAAAAdzc2gtcnNhAAABAQC6+r/5pWYdSYAjaHvNQPcQLB
BRIsTxFSigANj/8YHv03Etw8rViy0cvxMXLEM07AafxPu8vGBbqwowrJyHCTiPX2YubO47
BaHYZH5IxyhMru/jk4D+W3B1sd8T9RqxQ9QpujLvHLphb6Xij9ByacFgamDEEUJrU8wtXJ
nZrvbElFRWTMWFI14i+pQZ7x3Nu3y2rHobxvWlT3u4O+wM5tndmCs8asLMaM+tZ59rUKHx
HnRikvMYj+WanZFgw+N0R1ANtA67+ZV/kk/ElUtkcekUI1w5XsBvDCiyGIJM9Nolilvl2R
aGW1p5dMd53YrJ8kNtTrXJxibAmGyBbHvoCc/PAAAAAwEAAQAAAQEAqHRoqN3e1dv2WfA0
OYOiEyvft3l/vUO2yhB5cH2A9zSj7vtKroEpL5Dl/iaelftfLGon8q40keHS2G9qxi4Eiw
cD5Ce3qe01FuPS8nabVBr3fSzTNlXjR+XseOqGFdZqOv3KDarwMACKj0fKIIou8lJkw8BY
+qEQfn3DDl+Xaxo8/PeO/5rOj8woK+L6lD8mLbHtPYcKI+0AjZYuUKhBOq+UvVLjQR05jF
HlhBhW9YJeHMF1VGKIjMxgyLH1AaRfqAtF5j+3Zmh+oXe6jwBJ5p+cLPK1Y/HVDIqOKwTv
8Fj/QJaE6KvKKHCZLZV37J8NnDcWaPK1CMh0uTnitTfZQQAAAIBt1e3SKAT7vWKDPeShAx
dqn1/dkMruqFQGPMf+rbfTPQ4LDXKLb+4ecIQhBlEXoT+Jyuut2qPq65MJ3Otgk8cCW822
bmkWw7Ql1KtEBKgY0paYdz6tgZGKh4mVZEuVOjik4+h4YkamNu73GPE4KftzPnMeVYcton
/DYd0ONW865AAAAIEA5dwYf1WDpayFGgoeJxbuXakJPjBDbqXGSMAAxLaqgzBOKuybjfny
cdUddTzjaECdnXoQUorSqorjiemAUvdhtyQFSpp+cSYzlEwSF2h2Wk0E+KoY2VPEwBZGK4
9iGCd+A7JUkYRvmBgtCLmNjYlPuKI/72nzdE70CDS/a5cCRQcAAACBANA+SCHN1hTa3PH9
CZhjjCBnAXIi9UgQn1yDIvpaqhOvfPUasH1H+fiW+nc6R/548qnJGpy2fu48HugSBV1y/O
9z2+bK95aUBkdMgMrSZi22uRf5+NZyHmNcXYWhELUIFfRMd2+7LQI8ZaefoHRJJ59mXHo9
BzP7IYhHaOfyJvT5AAAAGGV1Z2VuZUBFdWdlbmVzLU1CUC5sb2NhbAEC
-----END OPENSSH PRIVATE KEY-----

After being converted with ssh-keygen:

    0:d=0  hl=4 l=1188 cons: SEQUENCE          
    4:d=1  hl=2 l=   1 prim: INTEGER           :00
    7:d=1  hl=4 l= 257 prim: INTEGER           :BAFABFF9A5661D498023687BCD40F7102C105122C4F11528A000D8FFF181EFD3712DC3CAD58B2D1CBF13172C4334EC069FC4FBBCBC605BAB0A30AC9C8709388F5F662E6CEE3B05A1D8647E48C7284CAEEFE39380FE5B7075B1DF13F51AB143D429BA32EF1CBA616FA5E28FD07269C1606A60C411426B53CC2D5C99D9AEF6C49454564CC585235E22FA9419EF1DCDBB7CB6AC7A1BC6F5A54F7BB83BEC0CE6D9DD982B3C6AC2CC68CFAD679F6B50A1F11E746292F3188FE59A9D9160C3E37447500DB40EBBF9957F924FC4954B6471E914235C395EC06F0C28B218824CF4DA258A5BE5D916865B5A7974C779DD8AC9F2436D4EB5C9C626C0986C816C7BE809CFCF
  268:d=1  hl=2 l=   3 prim: INTEGER           :010001
  273:d=1  hl=4 l= 257 prim: INTEGER           :A87468A8DDDED5DBF659F0343983A2132BDFB7797FBD43B6CA1079707D80F734A3EEFB4AAE81292F90E5FE269E95FB5F2C6A27F2AE3491E1D2D86F6AC62E048B0703E427B7A9ED3516E3D2F2769B541AF77D2CD33655E347E5EC78EA8615D66A3AFDCA0DAAF030008A8F47CA208A2EF25264C3C058FAA1107E7DC30E5F976B1A3CFCF78EFF9ACE8FCC282BE2FA943F262DB1ED3D870A23ED008D962E50A8413AAF94BD52E3411D398C51E5841856F5825E1CC1755462888CCC60C8B1F501A45FA80B45E63FB766687EA177BA8F0049E69F9C2CF2B563F1D50C8A8E2B04EFF058FF409684E8ABCA2870992D9577EC9F0D9C371668F2B508C874B939E2B537D941
  534:d=1  hl=3 l= 129 prim: INTEGER           :E5DC187F5583A5AC851A0A1E2716EE5DA9093E30436EA5C648C000C4B6AA83304E2AEC9B8DF9F271D51D753CE368409D9D7A10528AD2AA8AE389E98052F761B724054A9A7E712633944C121768765A4D04F8AA18D953C4C016462B8F6218277E03B25491846F98182D08B98D8D894FB8A23FEF69F3744EF40834BF6B97024507
  666:d=1  hl=3 l= 129 prim: INTEGER           :D03E4821CDD614DADCF1FD0998638C2067017222F548109F5C8322FA5AAA13AF7CF51AB07D47F9F896FA773A47FE78F2A9C91A9CB67EEE3C1EE812055D72FCEF73DBE6CAF7969406474C80CAD2662DB6B917F9F8D6721E635C5D85A110B50815F44C776FBB2D023C65A79FA07449279F665C7A3D0733FB21884768E7F226F4F9
  798:d=1  hl=3 l= 128 prim: INTEGER           :43223E516A6371CEEA6D098976F73E95425A7DBC50E58F2B537228874BA68F7C5B483424D699AAD2CE60B52E1C69057E4351345537508218E08E1611B1A9A8F37964C63E4B31B6EB97A384212C146D19539B60EAB306C14F2CF23FA4B80CBFF411165396D0AC5B2AAC7480E533F267C35038062FD6B8209B2B8E645E0313D99F
  929:d=1  hl=3 l= 129 prim: INTEGER           :9B645E5F1B420CFDE4B18EA882568652078B44A861700D375DC95D68840F35F155C570CD122F8B90BCD8D9EF5B99C09713AB45787B95EC2060CFBBE2D500E14DAD9F0271A29F7285DCDE719CE7B3E798DA35D20AA5BB3281E282C71C9163054D9CA712D9054B68C7B8F384622F64077522E50F324B15B6E826D162AEF23BAFC1
 1061:d=1  hl=3 l= 128 prim: INTEGER           :6DD5EDD22804FBBD62833DE4A103176A9F5FDD90CAEEA854063CC7FEADB7D33D0E0B0D728B6FEE1E708421065117A13F89CAEBADDAA3EAEB9309DCEB6093C7025BCDB66E6916C3B425D4AB4404A818D29698773EAD81918A878995644B953A38A4E3E8786246A636EEF718F13829FB733E731E55872DA27FC361DD0E356F3AE4

After being converted by node-sshpk:

    0:d=0  hl=4 l= 931 cons: SEQUENCE          
    4:d=1  hl=2 l=   1 prim: INTEGER           :00
    7:d=1  hl=4 l= 257 prim: INTEGER           :BAFABFF9A5661D498023687BCD40F7102C105122C4F11528A000D8FFF181EFD3712DC3CAD58B2D1CBF13172C4334EC069FC4FBBCBC605BAB0A30AC9C8709388F5F662E6CEE3B05A1D8647E48C7284CAEEFE39380FE5B7075B1DF13F51AB143D429BA32EF1CBA616FA5E28FD07269C1606A60C411426B53CC2D5C99D9AEF6C49454564CC585235E22FA9419EF1DCDBB7CB6AC7A1BC6F5A54F7BB83BEC0CE6D9DD982B3C6AC2CC68CFAD679F6B50A1F11E746292F3188FE59A9D9160C3E37447500DB40EBBF9957F924FC4954B6471E914235C395EC06F0C28B218824CF4DA258A5BE5D916865B5A7974C779DD8AC9F2436D4EB5C9C626C0986C816C7BE809CFCF
  268:d=1  hl=2 l=   3 prim: INTEGER           :010001
  273:d=1  hl=4 l= 257 prim: INTEGER           :A87468A8DDDED5DBF659F0343983A2132BDFB7797FBD43B6CA1079707D80F734A3EEFB4AAE81292F90E5FE269E95FB5F2C6A27F2AE3491E1D2D86F6AC62E048B0703E427B7A9ED3516E3D2F2769B541AF77D2CD33655E347E5EC78EA8615D66A3AFDCA0DAAF030008A8F47CA208A2EF25264C3C058FAA1107E7DC30E5F976B1A3CFCF78EFF9ACE8FCC282BE2FA943F262DB1ED3D870A23ED008D962E50A8413AAF94BD52E3411D398C51E5841856F5825E1CC1755462888CCC60C8B1F501A45FA80B45E63FB766687EA177BA8F0049E69F9C2CF2B563F1D50C8A8E2B04EFF058FF409684E8ABCA2870992D9577EC9F0D9C371668F2B508C874B939E2B537D941
  534:d=1  hl=3 l= 129 prim: INTEGER           :E5DC187F5583A5AC851A0A1E2716EE5DA9093E30436EA5C648C000C4B6AA83304E2AEC9B8DF9F271D51D753CE368409D9D7A10528AD2AA8AE389E98052F761B724054A9A7E712633944C121768765A4D04F8AA18D953C4C016462B8F6218277E03B25491846F98182D08B98D8D894FB8A23FEF69F3744EF40834BF6B97024507
  666:d=1  hl=3 l= 129 prim: INTEGER           :D03E4821CDD614DADCF1FD0998638C2067017222F548109F5C8322FA5AAA13AF7CF51AB07D47F9F896FA773A47FE78F2A9C91A9CB67EEE3C1EE812055D72FCEF73DBE6CAF7969406474C80CAD2662DB6B917F9F8D6721E635C5D85A110B50815F44C776FBB2D023C65A79FA07449279F665C7A3D0733FB21884768E7F226F4F9
  798:d=1  hl=2 l=   1 prim: INTEGER           :00
  801:d=1  hl=2 l=   1 prim: INTEGER           :00
  804:d=1  hl=3 l= 128 prim: INTEGER           :6DD5EDD22804FBBD62833DE4A103176A9F5FDD90CAEEA854063CC7FEADB7D33D0E0B0D728B6FEE1E708421065117A13F89CAEBADDAA3EAEB9309DCEB6093C7025BCDB66E6916C3B425D4AB4404A818D29698773EAD81918A878995644B953A38A4E3E8786246A636EEF718F13829FB733E731E55872DA27FC361DD0E356F3AE4

I'm not entirely sure what the fields 798 and 801 are, but them being empty makes the key incompatible with node-ssh2