0

I'm using the PowerShell terminal in Windows 10.
I created a folder "new_folder" in ~/.ssh

mkdir ~/.ssh/new_folder

Then I try to run ssh-keygen with the -f option.
The documentation says "[-f output_keyfile]".
Both ssh-keygen -t rsa -b 4096 -f ~/.ssh/new_folder
and ssh-keygen -t rsa -b 4096 -f ~/.ssh/new_folder/new_file fail with this error:

Saving key "~/.ssh/new_folder" failed: No such file or directory

I did the same using CMD terminal, and it works with both relative and absolute path.

ssh-keygen -t rsa -b 4096 -f "C:/Users/alex/.ssh/new_key"
ssh-keygen -t rsa -b 4096 -f "./new_key"

What's wrong with ssh-keygen in PowerShell ?

phuclv
  • 30,396
  • 15
  • 136
  • 260
Alex 75
  • 113

1 Answers1

1

The tilde in PowerShell only works under certain conditions, so it's better to avoid it, because you can't know without trying if it will work in your context.

So, instead of ~/.ssh/ you should use C:\Users\USERNAME\.ssh. This will work in all cases.

harrymc
  • 498,455