Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Saving ssh key fails

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).

like image 651
Eva Dias Avatar asked Sep 15 '11 11:09

Eva Dias


People also ask

How do I save my ssh keys?

Enter a passphrase for your SSH key in the Key passphrase and Confirm passphrase fields. Click Save public key. From the save dialog, choose where to save your public key, name the file with the . pub file extension, and click Save.

Can I copy an SSH key to another machine?

Copy the key to a server The copying may ask for a password or other authentication for the server. Only the public key is copied to the server. The private key should never be copied to another machine.

Where do ssh keys get saved?

SSH keys are typically configured in an authorized_keys file in . ssh subdirectory in the user's home directory. Typically a system administrator would first create a key using ssh-keygen and then install it as an authorized key on a server using the ssh-copy-id tool.

Do SSH key pairs expire?

SSH Key pairs in general do not have an expiration date because they do not have metadata outside of their key strings.


2 Answers

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.

like image 106
csaba.sulyok Avatar answered Oct 05 '22 04:10

csaba.sulyok


If you prefer to use a GUI to create the keys

  1. Use Putty Gen to generate a key
  2. Export the key as an open SSH key
  3. As mentioned by @VonC create the .ssh directory and then you can drop the private and public keys in there
  4. Or use a GUI program (like Tortoise Git) to use the SSH keys

For a walkthrough on putty gen for the above steps, please see http://ask-leo.com/how_do_i_create_and_use_public_keys_with_ssh.html

like image 20
First Zero Avatar answered Oct 05 '22 06:10

First Zero