SSH-Keygen "no such file or directory"

PS>ssh-keygen -t rsa -b 4096 -C "[email protected]"
Generating public/private rsa key pair.
Enter file in which to save the key (//.ssh/id_rsa):
Could not create directory '//.ssh': Read-only file system
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Saving key "//.ssh/id_rsa" failed: No such file or directory

The command could not save your key. Specify a file, at a location where you have write access:

ssh-keygen -t rsa -b 4096 -C "[email protected]" -f /path/to/key

This will save your private key in /path/to/key and the public key in /path/to/key.pub. When successful, instead of an error message, you will see something like:

Your identification has been saved in /path/to/key.
Your public key has been saved in /path/to/key.pub.
The key fingerprint is:
76:f7:82:04:1e:64:eb:9c:df:dc:0a:6b:26:73:1b:2c
The key's randomart image is:
+--[ RSA 2048]----+
|        o        |
|       o .       |
|        +        |
|       + +       |
|        S o .    |
|       . = = o   |
|        E * + o  |
|        o.++ o   |
|         *o..    |
+-----------------+

And then, to make ssh look for the file at the custom location, use the -i flag:

ssh -i /path/to/key -vT [email protected]

Alternatively, if you have an authentication agent running, you can add your key to the agent with:

ssh-add /path/to/key

Once your key is stored by the agent, you can simply do:

ssh -T [email protected]

The response should look something like:

Hi USER! You've successfully authenticated, but GitHub does not provide shell access.

And you can go ahead and clone your repository with:

git clone [email protected]:USER/REPO

For me, the ssh-keygen command appears to fail only when using cmd:

Your identification has been saved in [...]/.ssh/id_rsa. fdopen [...]/.ssh/id_rsa.pub failed: No such file or directory

The private key is generated, but the public key file is created with 0 bytes.

If I run the command in Git Bash on Windows, it works.


This work for me: ssh-add '/home/user/.ssh/id_rsa'