SharpSSH invalid privatekey

Karl picture Karl · Nov 19, 2012 · Viewed 10.9k times · Source

I use SharpSSH to connect to a stfp-server.

This for I need to add a privatekey-file like this:

sftp.AddIdentityFile(KeyFilePath);

But this throws an exception:

invaid privatekey: C:\KeyFile\privatekey_2.ppk

The file was created with puttygen and works with filezilla. The privatekey-type doesn't matter (SSH-1 RSA, SSH-2 RSA, SSH-2 DSA). Everytime the same result.

Do you know how to handle this problem?

Answer

Carlos Landeras picture Carlos Landeras · Nov 19, 2012

You have to convert your key to OpenSSH Format:

Use PuttyGen to generate and convert the key (Conversion -> export OpenSSH Key)