dengApro
dengApro

Reputation: 4008

Mac OS , Error when generating an SSH key with Git: “no such file”

I want to work with GitHub and multiple accounts. I am following this tutorial, I need to generate a unique SSH key for our second GitHub account and meet a problem:

Saving key "~/.ssh/id_rsa_nettuts" failed: No such file or directory

There is a a very similar answer, while the answers are all windows and do not work.

The code is as following:

$ ls                 
id_rsa      id_rsa.pub  id_rsa_nettuts  known_hosts
$ ssh-keygen -t rsa -C "[email protected]"
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/hou/.ssh/id_rsa): ~/.ssh/id_rsa_nettuts
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Saving key "~/.ssh/id_rsa_nettuts" failed: No such file or directory
$

Many Thanks in advance.

Upvotes: 6

Views: 19422

Answers (4)

cloudcop
cloudcop

Reputation: 1073

adding just pointer to what @User123456 said, it doesn't matter where you run the cmd as long you give the full path & file name to save your key

/Users/username/.ssh/id_rsa_netus

Upvotes: 0

maC
maC

Reputation: 11

I know that this is an old question but today I had this problem and if anyone else is facing ssh issues below are the steps that worked for me I have a mac:

  1. $ ssh-keygen -t rsa -b 2048 -C "[email protected]" Generating public/private rsa key pair.

2.Enter file in which to save the key (/home/user/.ssh/id_rsa):
I just accepted the recommended path pressing enter

3.After assigning a file to save your SSH key, you'll get a chance to set up a passphrase for your SSH key: Enter passphrase (empty for no passphrase): Enter same passphrase again: If successful, you'll see confirmation of where the ssh-keygen command saved your identification and private key.

4.Open your browser and paste the url directory ex. file:///home/user/.ssh/id_rsa.pub And you will see a json format of ssh key ending up with your email

5.Add into your git ssh key settings

Upvotes: -1

A1a5h3
A1a5h3

Reputation: 59

I agree with BRjava's solution. In addition to his answer, I say check your file directory to see if a ".ssh" file exists. (Caveat: Do not try to create one because windows explorer won't let you anyway).

If the file does not exist, simply carry out these

Steps:

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

    Generating public/private rsa key pair.

  2. Enter file in which to save the key (/home/hp/.ssh/id_rsa): "Press Enter on your Keyboard" (note: The directory will be created) Enter passphrase (empty for no passphrase): Enter same passphrase again:

(The below steps are not needed if you only intend getting past enter "passphrase" stage)

Then proceed to your Git repo

  1. Manage Account (With the assumption you are on bitbucket client)
  2. Click on SSH Keys and then Add Key
  3. Open the id_rsa.pub file created in step 2:
  4. copy the contents in above mentioned file and paste the contents in the text box on bitbucket.
  5. Add key

Upvotes: 0

User123456
User123456

Reputation: 2738

hope you are inside .ssh dir . When you are entering key name , just enter the file name instead of path. EX:

ssh-keygen -t rsa -C "[email protected]"
Generating public/private rsa key pair.
Enter file in which to save the key (/home/hp/.ssh/id_rsa): id_rsa_netus
Enter passphrase (empty for no passphrase): 
Enter same passphrase again:

Upvotes: 10

Related Questions