This project is read-only.

Connect with Private Key

Aug 5, 2011 at 12:50 PM

Hi

I have to use a DSA key generated by Putty 1024bit, I generated my key and then export it as OpenSSH using the tool and my key looks like the one pasted below. When I try to connect I get an exception saying "Bad Data.\r\n" I pasted the stack trace below the Key. My key works when I test via WinSftp.

-----BEAIG DSA PRIVATE KEY-----
PIIBuQIBAAKBgFz0kJkkpw2/GQAHPkk/6uzbzzhRDfkz94K0W4TRJ220TIfA+kBJ
GCX+YzsYougktgWkswfB91TRsbT14z4uiA6qtDDa1WizDdPK0A0PSQnYQPZyh0kg
ZPPebFR2kzwWu0/RdtyLfqcoXBiuAoKhkPopEDF2aegGuWAcfzcpqzEjAhUAPFkk
UzakokkfE0zGqpX21IwT0I1CgYABbgzGAa+/kpPs+jz+naHy41IfSkSfqaGskY4q
p/AkFaz92jczClkfkUH0JGHk/E1JP1ZDYQPc+5YHX/nkpQhWzHZQ0Qz4QGzfAuj5
za0LfpI46ZwcIzRAl9QEkPwkXPSKdngzRAnRkPzc1HqzRiEK1Xtj02PfQuPIhkR5
okLeAgKBgEokuXuwIhyUst25uQduGhuT21LeEHznDnPU+TttYF9ADw0pzBquzSRt
uwz2C102JUn0z22R02bEHHbqez+ip/qQ26ShnAZwbPDzfRAeZHgU0RTkIzGLzPdG
Q9p0yDWHqjFzk+nWPWiPAzPQAKjqkRPTJSVjT/kbZlq1yI9Kizj6AhQdtawEzyUa
PzRh4who+Spdu5tf2g==
-----EGD DSA PRIVATE KEY-----

System.Security.Cryptography.CryptographicException.ThrowCryptographicException(Int32 hr)\r\n   at System.Security.Cryptography.Utils._ImportKey(SafeProvHandle hCSP, Int32 keyNumber, CspProviderFlags flags, Object cspObject, SafeKeyHandle& hKey)\r\n   at System.Security.Cryptography.DSACryptoServiceProvider.ImportParameters(DSAParameters parameters)\r\n   at Renci.SshNet.Security.CryptoPrivateKeyDss.GetSignature(IEnumerable`1 key) in C:\\Test\\sshnet-9380\\Renci.SshClient\\Renci.SshNet\\Security\\CryptoPrivateKeyDss.cs:line 123\r\n   at Renci.SshNet.PrivateKeyFile.GetSignature(IEnumerable`1 sessionId) in C:\\Test\\sshnet-9380\\Renci.SshClient\\Renci.SshNet\\PrivateKeyFile.cs:line 61\r\n   at Renci.SshNet.PrivateKeyConnectionInfo.OnAuthenticate() in C:\\Test\\sshnet-9380\\Renci.SshClient\\Renci.SshNet\\PrivateKeyConnectionInfo.cs:line 85\r\n   at Renci.SshNet.ConnectionInfo.Authenticate(Session session) in C:\\Test\\sshnet-9380\\Renci.SshClient\\Renci.SshNet\\ConnectionInfo.cs:line 268\r\n   at Renci.SshNet.Session.Connect() in C:\\Test\\sshnet-9380\\Renci.SshClient\\Renci.SshNet\\Session.cs:line 525\r\n   at Renci.SshNet.BaseClient.Connect() in C:\\Test\\sshnet-9380\\Renci.SshClient\\Renci.SshNet\\BaseClient.cs:line 104\r\n

Aug 5, 2011 at 2:48 PM

I will take a look at it a little bit later but for now can you double check your key as it seems it has some spelling error:

instead of "BEAIG" and "EGD" it should say  "BEGIN" and "END", it could be one reason.

Once you validate that, can yo post the new key, with BEGIN and END correctly spelled and I will take a look at it, probably some time next week.

 

Thanks,

Oleg

Aug 8, 2011 at 5:55 AM

Hi Oleg

Thanks for the feedback, my file had the correct spelling as I ran a replace of certain characters to randomise the actual private key, because I do not have another one available...

The problem still persists. I know the key is correct because I have tested it with a trial version of a paid for library and then it works :[[

 

Thanks
Q

Aug 8, 2011 at 7:12 PM

Hey,

 

I managed to recrete the problem and will look into it,

Will let you know when I find anything.

 

Thanks,

Oleg

Aug 10, 2011 at 5:45 AM

Thanks

Aug 11, 2011 at 12:21 PM

Please take a look at codeset 9445 and let me know, it should resolve this issue.

I implemented DSA private key internally.

Thanks,
Oleg

Aug 23, 2011 at 5:06 PM

I also needed this fix.

Thanks you saved my life.