This project is read-only.

Invalid Private Key File Exception

May 4, 2012 at 4:23 AM
Here is the exception I am getting:
Renci.SshNet.Common.SshException: Invalid private key file. at Renci.SshNet.PrivateKeyFile.Open(Stream privateKey, String passPhrase)
And the offending code:
server = ""
user = "bill";
pword = "temppw";
privateKeyFile = "C:/Users/VM/AppData/Roaming/SSH/UserKeys/privkey";
passphrase = "privkeypk";

      connectionInfo = new ConnectionInfo(server, 22, user,
                       new PasswordAuthenticationMethod(user, pword),
                       new PrivateKeyAuthenticationMethod(user, new PrivateKeyFile(File.OpenRead(privateKeyFile), passphrase)));

catch (Exception e)
  return e.ToString();
It appears the private key file I have to use is a SSH2 Encrypted file.
Subject: Subject
Comment: "2048-bit rsa, User@MachineName, Fri Jan 13 2012 16:22:33"
P2/56wAAA/ etc....
So my questions are:
1) Does my code look correct?
2) Can we use a SSH2 Encrypted file for this? Do the Subject and Comment lines throw off the regex check?
May 4, 2012 at 1:29 PM


Someone else already reported it, I think, and as of now I do not support SSH2 Encrypted key, I was planing to take a look at it very soon and see how I can add support for this.


My problem during development time was that I didnt have any server to test this key on I skipped it at a time.