I want to run a command like:

ssh-keygen -t rsa -b 4096 -C "your_email@example.com"

My understanding is that ssh-keygen outputs to the home directory. I'm working on a networked computer using Git Bash (Windows, MYSS MINGW64) where the home directory is one I don't have access to. I change the home directory like so:

export HOME=C:/Users/myusername

so now when I enter:

echo $HOME

it says:


but when I again try to run the ssh-keygen command it runs in the directory that I don't have access to. I've looked through the profile file for some hard coded path but can't find anything. How do I change it to point to a directory that I do have access to?

up vote 57 down vote accepted

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:

  • Much obliged. I overlooked the -f option. I just created a new folder with mkdir .ssh in my HOME and ran the command you said. Thank you very much. – Phlox Midas Nov 24 '15 at 9:09

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.