ssh-keygen -f confusion

2

0

While trying to create rsa keypairs for a project inside the project dir I was experimenting with ssh-keygen's -f option. When I test it in a freshly created directory everything works as expected, but when I try to use the exact same syntax on another equally permissioned directory ssh-keygen just keeps telling me No such file or directory.

In a way it is right saying so, because it is supposed to create these files. (The directory in which it shall work exists.)

The syntax I use for key creation is:

ssh-keygen -q -t rsa -f /abspath/id_rsa -N ""

eFrane

Posted 2011-08-01T11:09:04.947

Reputation: 155

is /abspath/ an indication of the command or is it what you actually typed? – Sathyajith Bhat – 2011-08-01T12:22:36.990

/abspath/ is just meant to indicate that I used an absolute path to a folder there as is required by ssh-keygen – eFrane – 2011-08-01T15:48:32.007

Answers

1

I am not able to recreate this problem unless I specify a directory that does not actually exist. I suggest that you look at where you're trying to create the key pair, making sure that the directory exist.

Kusalananda

Posted 2011-08-01T11:09:04.947

Reputation: 1 941

0

First, you need to create a directory to store your host key file:

$ mkdir -p $HOME/.ssh/mykey

Second, depending on which key type, you can reate a host key file in your $HOME/.ssh/mykey : (choose ONE)

$ ssh-keygen -t rsa -f $HOME/.ssh/mykey/rsa_key_file

or

$ ssh-keygen -t dsa -f $HOME/.ssh/mykey/dsa_key_file

or

$ ssh-keygen -t ecdsa -f $HOME/.ssh/mykey/ecdsa_key_file

or

ssh-keygen -t ed25519 -f $HOME/.ssh/mykey/ed25519_key_file

Lastly, to verify the key is generated successfully:

$ ls -l $HOME/.ssh/mykey/

Färid Alijani

Posted 2011-08-01T11:09:04.947

Reputation: 101