Linux – WinSCP and PuttyGen fail on conversion of openSSH private key to PEM or PPK formtype on windows

opensshoracle-linuxputtysshwinscp

I’ve generated a Linux Instance in the Oracle Cloud. Locally I work on Windows-10 Client computer. During generation of the Linux Instance Private and Open-SSH public keys have been generated in Linux and been downloaded to local windows, too.
With this now

1.) Private keys in Open-SSH format are stored on both windows and linux and kept secret

2.) I can login from into Linux using the public key with this

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -command ssh -i D:\wrk\ssh-key-2020-08-01.key opc@xxx.xx.xx.xxx.
Connection is established, thus key validation is successful.

Now I need a SFTP GUI Client on window for file exchange.

I tried WinSCP or Filezilla. Both tool require the privat key either in PPK or PEM format. The private key file provided by OCI/oracle [always free version, thus no support from oracles side to be expected] has .KEY file extension and has openSSH format, guess it's SSH2.

<edit added in response to comment of  Martin Prikryl>

Actually WinSCP does try to handle my private openSSH Keyfile by offering to convert it to Putty format. Trying to convert WinScp then signals an error: "unrecogniszed key type". Anyhow my openSSH Pub/key-keypair has proven to work with a key-exchange over a SSH-Console connection.

</edit added in response to comment of  Martin Prikryl>

Need to work on the existing private key, because I don't see a way to exchange any files between the Clound/Linux and my local Client/Windows-10. Thus I can't transfer any newly created secret private key files in PEM or PPK-Format from linux to windows or vice versa, without a FSTP connection.

Thus my question

How can I convert the openSSH private key in windows into PEM or PPK Format – when I get the error "unrecognised key type" while trying to do so with WinSCP?

additional info
Trying to come close to the request of @Martin Prikryl:

I created another LINUX instance with its own SSL-keypair and publish this here. The instance will be disposed later, thus I guess there is no need for privacy of this instance.

powershell>openssl rsa -check -in ssh-key-trial.key RSA key ok writing RSA key

-----BEGIN RSA PRIVATE KEY-----
MIIEowIBAAKCAQEAsUQnog4X8CramCQMGk9MHJ+43QSrIsUsTpvrSvYpS+PcJEWY
RhHMDJWnJmxj6qc44WZLU1dx/578X7UvARlVXRr7vEOW00ruk7TNViH1+1Qt2tkz
RI5VIhPvjeN4YKs7NfdLRQNB0hmMKavkkhyUHYQZozS/w6+uby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qblVcH+EEZn8wKBgQCDje66GXXPkB8nnv8CsWcPWZFTnLB47y5MsHhP
izux9aFGiOnzTm88G8RKSP6abaMuaT+rxvproKT0bxxZqT6P0PSMY2bXmEAWid/9
tBTMo1JMAkgcbU9X0m3os+lgAwkvwGaT/3gILvmgcqmneWURw2igDrOdM+GcbhhO
5x32YQKBgH04h5jE+AfK+Y+BzigpJIDwDvLjr6DzinW8rTzTT7bsqRg0TT85mvp+
qK9Ndn3aDClj6FgrYsn1xsHoEy2V/AkmFRuZiC44bouiAvAX06XBs5uOjS4tWD+5
7Fryt6MkS7UmBPYvYn2yhAPmg4v2cfyqFB7k8ZTdCX2uqJzubkiz    
-----END RSA PRIVATE KEY-----

rsa -check on the original private keyfile says it's ok. WinScp, Putty and PuttyGen nevertheless don't accept it. Hope this supports my case.

@ Martin Prikryl

Yes, I just copied the output of the above <openssl rsa -check..>-command into the text compound above. Below you see the content of the original file ssh-key-trial.key.

-----BEGIN PRIVATE KEY-----
MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCxRCeiDhfwKtqY
JAwaT0wcn7jdBKsixSxOm+tK9ilL49wkRZhGEcwMlacmbGPqpzjhZktTV3H/nvxf
tS8BGVVdGvu8Q5bTSu6TtM1WIfX7VC3a2TNEjlUiE++N43hgqzs190tFA0HSGYwp
q+SSHJQdhBmjNL/Dr65vJADz6bJ256hxQb9nk9hCHFj53Exq4mz3aXIhA2Bxl8cW
GGt8cOeKkMV3dgfEj5E0+hNSsoCTo2APhAFH9e5XinCO6joXhmNz6TEdEAgckm4b
Ie0wjTs2C+rIG+0Pbh7GKDFTEcGHQNAh7zorHCpyo7OhR+o/BO1r5379sSnA4Bjp
l6n0RMvLAgMBAAECggEAAJ9IhP8QiMdfVAylrMLmSuzk/urv+ixMqr8rKDmAPBLK
gevRjD424dZtCSLsdah+AJXeKoz0hmFVpV+v7pUn0IQloVIrz/0uglRIGbGYfTPH
vQYDAyfjzmhyxbUXQbW9fH+Be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
/KoUHuTxlN0Jfa6onO5uSLM=
-----END PRIVATE KEY-----

As I just found out now -File is a decrypted version of -File. My problem is/was that WinScp and PuttyGen can't handle the encrypted form of the file. <openssl rsa -check..>-command can decrypte the input and writes the decrypted version to the output.

This command decryptes the private key directly into the outputfile:

openssl  rsa -in ssh-key-trial.key -out decrypted_ssh-key-trial.key

Using this file now with WinScp I get a connection the the Oracle Infrastructure Instance. Problem solved.

Problem cause is:
WinSCP and PuttyGen fail on conversion of openSSH private key (encrypted form) to PEM or PPK formtype on windows.
Solution: openSSH private key has to be decrypted first by SSH-Tool of windows-10.

WinScp, PuttyGen can't read open SSH in encrypted form, aka with fileheader <RSA PRIVATE KEY>

thus solution is:
decrypte the file to the form as show above. This format is understood by WinScp 5.17.7 (Build 10640), PuttyGen Rel 0.73

Thanks to @Martin Prikryl for your support in this desperate situation, which helped me to come to an end with this.

Best Answer

I had the same issue.
Generated ssh keys using rsa, 2048 and git bash.Using PuttyKey Gen to convert failed.
I then downloaded the latest version and it worked.
Version 0.74 according to help / about.

There is new functionality even though I've been using the same format for several years. Possibly Windows Git Bash uses new openssh or a newer process.