CMD.exe and Powershell.exe cannot generate ssh keys using ssh-keygen

Uri 1 Reputation point
2021-07-26T20:24:33.357+00:00

Hope you can help me out here. I've been playing around with some SSH authentication. I have no idea why this is happening, but now when I run a simple ssh-keygen command I get a response saying Access is denied. in addition to a pop-up that reads "This app can't run on your PC. To find a version for your PC, check with the software publisher".

I then tried running the ssh-keygen command in Poweshell (as admin and as regular user) and got the following:

    Program 'ssh-keygen.exe' failed to run: The specified executable is not a valid application for this OS platform.At
    line:1 char:1
    + ssh-keygen
    + ~~~~~~~~~~.
    At line:1 char:1
    + ssh-keygen
    + ~~~~~~~~~~
        + CategoryInfo          : ResourceUnavailable: (:) [], ApplicationFailedException
        + FullyQualifiedErrorId : NativeCommandFailed

However, using ssh -V shows that it is installed:

OpenSSH_for_Windows_8.1p1, LibreSSL 3.0.2

I can still SSH fine into other devices, if that's of any relevant.

Any help would be very much appreciated here!

Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,526 questions
0 comments No comments
{count} votes

4 answers

Sort by: Most helpful
  1. Rich Matheisen 46,721 Reputation points
    2021-07-26T21:27:11.677+00:00

    This isn't a PowerShell problem.

    Do you have permission on the EXE to execute it?
    Is the EXE file blocked (check its properties)?

    What version of Windows are you running? Is it 32- or 64-bit?
    Do you have the location of the executable in your PATH environment variable?

    Use one of the methods in this line to determine the "bit-ness" of the EXE: check-if-program-is-32-bit-or-64-bit-on-windows-10

    0 comments No comments

  2. MotoX80 33,736 Reputation points
    2021-07-26T21:47:08.377+00:00

    From an admin command prompt, use the where.exe program to verify that you are trying to execute C:\Windows\System32\OpenSSH\ssh-keygen.exe.

    Or just run the program directly.

    118046-capture.jpg

    0 comments No comments

  3. Uri 1 Reputation point
    2021-07-27T07:42:39.997+00:00

    @MotoX80 thanks for that. That seems to work!

    So now I do wonder, how can I change the path of the ssh-keygen command to route back to the system32\openssh\ssh-keygen.exe executable?


  4. MotoX80 33,736 Reputation points
    2021-07-27T12:11:04.837+00:00

    how can I change the path

    Did the where command find a different ssh-keygen executable in some other folder or is the OpenSSh folder missing from the path environment variable?

    118284-capture.jpg

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.