The Computer Oracle

How can I change the directory that ssh-keygen outputs to?

Become or hire the top 3% of the developers on Toptal https://topt.al/25cXVn

--

Music by Eric Matyas
https://www.soundimage.org
Track title: Over Ancient Waters Looping

--

Chapters
00:00 Question
00:59 Accepted answer (Score 174)
01:48 Answer 2 (Score 0)
02:07 Thank you

--

Full question
https://superuser.com/questions/1004254/...

Accepted answer links:
[tutorial]: https://help.github.com/articles/generat.../
[manual page for ssh-keygen]: http://www.openbsd.org/cgi-bin/man.cgi/O...
[ssh-keygen -f confusion]: https://superuser.com/questions/317608/s...
[Linux / Unix ssh-keygen: Create A Host Key File]: http://www.cyberciti.biz/faq/howto-linux.../

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#ssh #git

#avk47



ACCEPTED ANSWER

Score 185


You should be able to do this by specifying the name of the output file with the -f option, e.g.,

ssh-keygen -t rsa -b 4096 -C "your_email@example.com" -f $HOME/.ssh/id_rsa

Of course, it really helps if the output directory has already been created.

For further reading:




ANSWER 2

Score 0


On Windows 10:

From the accepted answer, $HOME did not work for me for the path, but %userprofile% does:

ssh-keygen -f %userprofile%/.ssh/id_rsa



ANSWER 3

Score 0


For me you should use this option -f like this :

ssh-keygen -t rsa -b 2048 -f /home/user/project/ssh-keys/id_ras

And finally sh-keygen generate two file private and public into this directory

/home/user/project/ssh-keys/id_ras
/home/user/project/ssh-keys/id_ras.pub