Subject: "Invalid key format" exception while loading  RSA private putty key
Date: 2018-03-07 14:48:29
From: amolj
Source: invalid-key-format-exception-loading-rsa-private-putty-key
----------------------------------------------------------------------

Hi,

I am trying to load the private key files using the code mentioned in the following page   

[http://doc.componentpro.com/ComponentPro-Sftp/loading-keys][1]

My code is as follows 

        public static void ReadPrivateKey(byte[] key, string passPhrase)
        {
                    try
                    {
                        using (Stream stream = new MemoryStream(key))
                        {
                            var privateKeyObject = new SecureShellPrivateKey(stream,passPhrase);
                            ...
                        }
                    }
                    catch (Exception ex)
                    {
                        throw ex
                    }
          }

Above code works fine for DSA private putty key file. but it fails for RSA Private Putty key file (SSH PRIVATE KEY FILE FORMAT 1.1) generated through puttygen.

It throws exception "Invalid key format".

I would like to upload the RSA Private putty key file but I don't know how to do it.

Thanks,
Amol
 
**Update 1:** 

I tried the rsa putty key 
[http://doc.componentpro.com/ComponentPro-Sftp/private-key-formats][2]

and it does not throw the exception. example key contains can be readable (ASCII format ) but mine is not readable. 
  
**Update 2:** looks like an RSA private putty key with SSH-1 format (SSH PRIVATE KEY FILE FORMAT 1.1) is not supported. Can anybody confirm?


  [1]: http://doc.componentpro.com/ComponentPro-Sftp/loading-keys
  [2]: http://doc.componentpro.com/ComponentPro-Sftp/private-key-formats

----------------------------------------------------------------------

Note: This question has been asked on the Q&A forum of Thang Dang's fraudulent ComponentPro brand
If you purchased anything from ComponentPro, you have been scammed. Contact the payment processor
who sold you the license and ask for your money back.

Back to ComponentPro Q&A Forum Index