OpenSSH on Windows - "XXX Could not save your public key in __PROGRAMDATA__

Evvy73 picture Evvy73 · Jul 19, 2018 · Viewed 21.5k times · Source

I am trying to install OpenSSH on a Windows Server (2012 R2 standard) and I have been following the instructions at this locataion: https://www.server-world.info/en/note?os=Windows_Server_2012&p=openssh

I ran Powershell as Administrator and all seems to install correctly up to the part where I try to generate the SSH host-key by running the command .\ssh-keygen.exe -A (step 7 of the instructions). After running this it returns an error saying:

RSA Could not save your public key in __PROGRAMDATA__\\ssh/ssh_host_rsa_key.9uX3wf3apv: No Such file of directory"

The same error also displays for DSA, ECDSA and ED25519.

Screenshot of errors

If anyone can tell me where I am going wrong here it would be appreciated. I've searched the web and not found any other references to this.

Answer

Anthon picture Anthon · Aug 28, 2018

The __PROGRAMDATA__ refers to your environment variable PROGRAMDATA (Which probably is set to C:\ProgramData).

It is usually easiest to open an cmd command prompt and type

mkdir %PROGRAMDATA%\ssh

or powershell

mkdir $env:ProgramData\ssh

and then rerun the

.\ssh-keygen.exe -A