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@myem
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 "myemail@myemail.com"
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:
... myemail@myemail.com
The key's randomart image is:...`
I know this is an old thread, but I thought the answer might help others.
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)
In Windows I had to create the environment variable HOME
pointing to my user profile first (C:\Users\<name>)
or whatever directory you prefer.
Then start a new command line window, create a a .ssh
directory in your user profile or choosen diretory using mkdir ".ssh"
command.
After doing that I was able to use the ssh-keygen without any path problems.
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.
For MacOS
Open terminal and make sure you have .ssh directory.
On your home(~) folder enter ls -hal
and you will see all hidden directories and make sure you have .ssh directory, if not do mkdir .ssh
then enter this ssh-keygen -t rsa -C "myemail@myemail.com"
then you have: Generating public/private rsa key pair.
Enter file in which to save the key (/Users/YOURUSERNAME/.ssh/id_rsa):
press Enter (you don't need to enter nothing if you agree with that path or you need to enter your path from root of volume)
then follow answer what is gonna ask press Enter.
Check it here https://help.github.com/en/enterprise/2.16/user/authenticating-to-github/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent
I faced the same problem. Solution on windows:
mkdir .ssh
This will create a .ssh folder.