ssh2 icon indicating copy to clipboard operation
ssh2 copied to clipboard

Private key errors

Open amoussard opened this issue 12 years ago • 5 comments

Hi everyone,

I try to implement ssh connection in my package for atom.io, with private key and I have some problems...

  • It's possible to have only the private key file and not the passphrase ? Because without it, I encountered an error which says that I have not...
  • With it, I have an other error message Unable to parse private key while generating public key (expected sequence). I've seen in the library sources but it seems to be the condition privKey[0] === 0x30 which fails. Any idea ? My private key is not well formated ?

Thank you in advance for your answers :)

amoussard avatar Jun 02 '14 02:06 amoussard

You only need a passphrase if your private key is encrypted. Is it possible you could create a new private key using the same parameters that also exhibits the problem that you could then post somewhere so that I could reproduce it?

mscdex avatar Jun 02 '14 02:06 mscdex

Also, having a passphrase usually saved in the clear like that is not ideal (unless maybe you prompt for it first). Using an ssh key agent is better for encrypted private keys.

mscdex avatar Jun 02 '14 02:06 mscdex

I saw the same issue. Reading in the key as a buffer rather than utf8 or ascii fixed the problem, though I am still seeing authentication errors that I need to track down - those may well be my problem.

damoore avatar Nov 19 '14 16:11 damoore

@damoore Can you provide an example key file that works when passing as a Buffer but not a string? It should work either way.

mscdex avatar Dec 07 '14 16:12 mscdex

I discovered that my ultimate problem was that I was passing in too many parameters. i.e. if I was connecting using a password, then I should not pass in keys and a passphrase. I think even passing them in as undefined caused trouble, but I did not go back and check this. Once I changed my code to pass in just the parameters I was using, everything worked. I am reading my keys now as utf8, which means I get a string rather than a buffer from readFile, so strings work.

damoore avatar Dec 08 '14 14:12 damoore