3
Vote

Feature Request: Support PuTTY-User-Key-File-2: ssh-rsa aes256-cbc (private key)

description

PuTTY-User-Key-File-2: ssh-rsa
Encryption: aes256-cbc
Comment: imported-openssh-key
 
The IdentityFile constructor (.\SharpSSH\jsch\IdentityFile.cs) does not support PuTTY private key files.

comments

icnocop wrote Jun 13, 2009 at 8:48 PM

How can I manually convert a PuTTY private key file to one that works with SharpSSH2?

Thank you.

icnocop wrote Jun 15, 2009 at 10:37 AM

I also have a pem file that looks like
-----BEGIN RSA PRIVATE KEY-----
~15xx characters looks like base64
-----END RSA PRIVATE KEY-----

The key par for a secure Amazon EC2 ssh connection

How can I use it with SharpSSH2?

When I try:
            string host = "www.mydomain.com";
            string user = "root";

            Tamir.SharpSsh.SshExec exec = new Tamir.SharpSsh.SshExec(host, user);

            string currentDirectory = Path.GetDirectoryName(
                Assembly.GetExecutingAssembly().Location);

            exec.AddIdentityFile(
                Path.Combine(
                currentDirectory,
                "ec2_key_pair2.pem"));

            exec.Connect();
I get the following Exception:
System.Security.Cryptography.CryptographicException occurred
Message="Bad Data.\r\n"
Source="mscorlib"
StackTrace:
   at System.Security.Cryptography.CryptographicException.ThrowCryptogaphicException(Int32 hr)
   at System.Security.Cryptography.Utils._ImportKey(SafeProvHandle hCSP, Int32 keyNumber, CspProviderFlags flags, Object cspObject, SafeKeyHandle& hKey)
   at System.Security.Cryptography.RSACryptoServiceProvider.ImportParameters(RSAParameters parameters)
   at Tamir.SharpSsh.jsch.jce.SignatureRSA.sign() in C:\SharpSSH\SharpSSH\Crypto\Signature\SignatureRSA.cs:line 102
InnerException:

Any ideas?

Thank you.

icnocop wrote Jun 16, 2009 at 2:31 AM

The other open source implementation of an ssh client in c#
http://granados.sourceforge.net/

Seems to support my ssh private key file in the form
---- BEGIN SSH2 ENCRYPTED PRIVATE KEY ----
...
---- END SSH2 ENCRYPTED PRIVATE KEY ----

adevoinic wrote Oct 15, 2009 at 12:24 PM

Checkout the conversions menu from Putty. After you convert the private key it works.
Success,
A

wrote Mar 29, 2010 at 8:43 AM

wrote Nov 13, 2010 at 11:18 PM

wrote Feb 14, 2013 at 12:17 AM