Saving ssh key fails

Eva Dias picture Eva Dias · Sep 15, 2011 · Viewed 167.8k times · Source

i just started a Git tutorial and I get to a deadend: I try to generate a rsa key part and it fails. I did this, in git bash:

ssh-keygen -t rsa -C "[email protected]"

And i got this:

Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/Eva/.ssh/id_rsa):
enter passphrase:
enter same passphrase again:
open /c/Users/Eva/.ssh/id_rsa failed: no such file or directory.
Saving the key failed:/c/Users/Eva/.ssh/id_rsa.

I tried to save in a different folder and it went OK. but now i do the command ssh -T [email protected] and it gives me the error permisson denied (publickey).

Answer

csaba.sulyok picture csaba.sulyok · Nov 30, 2013

If you're using Windows, the unix-style default path of ssh-keygen is at fault.

In Line 2 it says Enter file in which to save the key (/c/Users/Eva/.ssh/id_rsa):. That full filename in the parantheses is the default, obviously Windows cannot access a file like that. If you type the Windows equivalent (c:\Users\Eva\.ssh\id_rsa), it should work.

Before running this, you also need to create the folder. You can do this by running mkdir c:\Users\Eva\.ssh, or by created the folder ".ssh." from File Explorer (note the second dot at the end, which will get removed automatically, and is required to create a folder that has a dot at the beginning).

c:\Users\Administrator\.ssh>ssh-keygen -t rsa -C "[email protected]"
Generating public/private rsa key pair.
Enter file in which to save the key (/home/Administrator/.ssh/id_rsa): C:\Users\Administrator\.ssh\id_rsa
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in C:\Users\Administrator\.ssh\id_rsa.
Your public key has been saved in C:\Users\Administrator\.ssh\id_rsa.pub.
The key fingerprint is:
... [email protected]
The key's randomart image is:...`

I know this is an old thread, but I thought the answer might help others.