When I try to create an SSH key using sudo ssh-keygen -t rsa
I get the request:
Enter file in which to save the key (/root/.ssh/id_rsa):
However, I would like the file to be saved in /home/user2/.ssh/id_rsa
. When I enter that directory I get this error:
Saving key "/home/user2/.ssh/id_rsa" failed: No such file or directory
Any attempt to enter a different directory returns an error.
How can I generate the key in /home/user2/.ssh/id_rsa
?
EDIT: when I remove sudo
I get this problem:
Generating public/private rsa key pair.
Enter file in which to save the key (/home/hduser/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Saving key "/home/hduser/.ssh/id_rsa" failed: Not a directory
But shouldn't SSH create the directory?
/home/user2/.ssh/
exist?sudo
in the first place?sudo