35

The recent beta version of OpenSSH on Windows 10 does not accept my openssh formatted private key:

enter image description here

The same key works on ssh shipped with git shell from github.

Is there a format option for openssh on Windows that I'm missing or is this a bug?

AK_
  • 1,879
  • 4
  • 21
  • 30
  • 2
    Same problem for me. Not only working with `git shell` but also when running `ssh` from WSL. – Uri Dec 25 '17 at 08:20
  • @Uri then probably it's an invalid format you are using! Git shell ssh works with valid formats – AK_ Dec 25 '17 at 08:24
  • 1
    I know this is a really old post, but please [edit] to convert your images of text into actual text. [See here](https://meta.stackoverflow.com/a/285557/11107541) for why. – starball Nov 16 '22 at 17:45
  • It's so annoying when overreaching moderators close relevant questions... If OpenSSH and git shell aren't "tools primarily used by programmers", then I don't know what is. Anyways, I had the same problem and found the culprit to be the be line endings. Windows style CRLF didn't work, but it was all good after converting to LF. I guess others searching for this answer will never find it though... – Erling T Aug 16 '23 at 10:29

5 Answers5

72

I got this working.. believe it or not by adding a single LF at the end of your private key file. E.G

-----BEGIN OPENSSH PRIVATE KEY-----
KEY
-----END OPENSSH PRIVATE KEY-----
 

Without the LF the private key worked fine with putty, secureCRT, WinSCP, GIT etc... but Windows (which is used by VisualCode) Kept giving me "invalid Format"

General Grievance
  • 4,555
  • 31
  • 31
  • 45
Grev
  • 833
  • 6
  • 4
19

Windows 10 currently (as of January 2018) only supports ed25519 keys (reference: https://github.com/PowerShell/Win32-OpenSSH/issues/973). I see that you are trying to connect to Amazon Web Services. If you manage your key using the AWS console, you can only use an RSA key.

However, if you are trying to connect to an existing EC2 instance, you can do the following:

  1. Create the private/public key in Windows cmd using the command "ssh-keygen", if you have not already done this. The key pair is saved in files id_ed25519.pub and id_ed25519 in your .ssh directory
  2. Connect to your AWS EC2 instance. Add the contents of the id_ed25519.pub to your authorized_keys file within the .ssh directory
  3. Now you can connect to your EC2 instance using the Windows 10 SSH client.
simon
  • 12,666
  • 26
  • 78
  • 113
  • Maybe you can add a way to convert keys to this standard? – AK_ Jan 02 '18 at 15:36
  • For this to work both the server and the client have to support the same signature protocol, which is not the case. – simon Jan 02 '18 at 15:48
8

I had a similar issue. I copied it id_rsa from Linux to Windows 10. I knew that it was probably line-terminating issue. So I downloaded dos2unix for Windows https://waterlan.home.xs4all.nl/dos2unix.html, and ran dos2unix id_rsa, and it worked afterwards.

Raza
  • 3,147
  • 2
  • 31
  • 35
5

For me, a new line at the end of the file solved the problem.

Fenghe Xu
  • 81
  • 1
  • 2
2

try this

ssh-keygen -o -a 100 -t ed25519 -f ~/.ssh/id_rsa -C "your email"

and catch the folder with this command

cat ~/.ssh/id_rsa.pub

hope this help.