6

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 "houReal@gmail.com"
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.

dengApro
  • 3,848
  • 2
  • 27
  • 41
  • have you tried this using "sudo" ? – User123456 Dec 14 '17 at 03:41
  • 1
    Related: [Best way to use multiple SSH private keys on one client](https://stackoverflow.com/a/41135590/4133798) – Sajib Khan Dec 14 '17 at 03:42
  • @ BRjava No plece for sudo. I can't do this . ' Enter file in which to save the key (/Users/dengjiangzhou/.ssh/id_rsa): **sudo** ~/.ssh/id_rsa_nettuts' – dengApro Dec 14 '17 at 03:47
  • 2
    When SSH reads a path name, it does not accept `~` for home directory. You could have spelled out `/Users/hou` instead of using `~` but since you were already in your `.ssh` sub-directory, the method you ended up using worked fine as well. – torek Dec 14 '17 at 17:43

4 Answers4

10

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 "houReal@gmail.com"
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:
User123456
  • 2,492
  • 3
  • 30
  • 44
0

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 "houReal@gmail.com"

    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
Community
  • 1
  • 1
A1a5h3
  • 59
  • 1
  • 6
0

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

cloudcop
  • 957
  • 1
  • 9
  • 15
-1

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@example.com" 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

maC
  • 11
  • 3