Saving ssh key fails
Clash Royale CLAN TAG#URR8PPP
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 "myemail@myemail.com"
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 git@github.com
and it gives me the error permisson denied (publickey).
ssh -T git@github.com
permisson denied (publickey).
9 Answers
9
If you prefer to use a GUI to create the 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
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:UsersEva.sshid_rsa
), it should work.
Enter file in which to save the key (/c/Users/Eva/.ssh/id_rsa):
c:UsersEva.sshid_rsa
c:UsersAdministrator.ssh>ssh-keygen -t rsa -C "myemail@myemail.com"
Generating public/private rsa key pair.
Enter file in which to save the key (/home/Administrator/.ssh/id_rsa): C:UsersAdministrator.sshid_rsa
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in C:UsersAdministrator.sshid_rsa.
Your public key has been saved in C:UsersAdministrator.sshid_rsa.pub.
The key fingerprint is:
... myemail@myemail.com
The key's randomart image is:...`
I know this is an old thread, but I thought the answer might help others.
It looks like you are executing that command from a DOS session (see this thread), and that means you need to create the .ssh
directory before said command.
.ssh
Or you can execute it from the bash session (part of the msysgit distribution), and it should work.
+1, thx, helped me a lot.. ".ssh" directory was missing ;-)
– d4Rk
Nov 4 '14 at 23:24
In my case this was the correct answer, just forgot to create the directories specified in path
– blissini
May 6 '16 at 9:55
I had the same issue. I had to provide the full path using Windows conventions.
At this step:
Enter file in which to save the key (/c/Users/Eva/.ssh/id_rsa):
Enter file in which to save the key (/c/Users/Eva/.ssh/id_rsa):
Provide the following value:
c:userseva.sshid_rsa
c:userseva.sshid_rsa
OSX too: instead of ~/.ssh/id_rsa I had to use /Users/<username>/.ssh/id_rsa
– AVProgrammer
Mar 17 '16 at 15:47
Yep, on macOS I needed to type in the whole path of the intended keyfile for the second SSH key I generated (the first one worked with just the file name).
– Aditya M P
Dec 11 '16 at 13:58
I had to provide the full path too on High Sierra.
– BaDr Amer
Mar 12 at 8:35
You have to create the .ssh folder yourself for saving ssh keys.
By the way, I used this path style: C:/Users/you/.ssh/id_rsa
C:/Users/you/.ssh/id_rsa
I was using bash on windows that came with git. The problem was I assumed the tilde (~) which I was using to denote my home path would expand properly. It does work when using cd, but to fix this error I had to just give it the absolute path.
In Windows I had to create the environment variable HOME
pointing to my user profile first (C:Users<name>)
or whatever directory you prefer.
HOME
(C:Users<name>)
Then start a new command line window, create a a .ssh
directory in your user profile or choosen diretory using mkdir ".ssh"
command.
.ssh
mkdir ".ssh"
After doing that I was able to use the ssh-keygen without any path problems.
I struggled with the same problem for a while just now (using Mac). Here is what I did and it finally worked:
(1) Confirm the .ssh directory exists:
#show all files including hidden
ls -a
(2) Accept all default values by just pressing enter at the prompt
Enter file in which to save the key (/Users/username/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
You should get a message :
Your identification has been saved in /Users/username/.ssh/id_rsa.
Your public key has been saved in /Users/username/.ssh/id_rsa.pub.
The key fingerprint is:
BZA156:HVhsjsdhfdkjfdfhdX+BundfOytLezXvbx831/s youremail.@email.com
The key's randomart image is:XXXXX
PS If you are configuring git for rails, do the following (source):
git config --global color.ui true
git config --global user.name "yourusername"
git config --global user.email "youremail@email.com"
ssh-keygen -t rsa -C "youremail@email.com"
(then accept all defaults by pressing enter)
Your method should work fine on a Mac, but on Windows, two additional steps are necessary.
Saving the id_rsa key in this location should solve the permission error.
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Note that you must create the directory before running the command. To Create a windows directory starting with a . you have to put a . before it and it will automatically be removed ".ssh." creates ".ssh".
– marsh
Apr 27 '17 at 14:28