Failure to install openssh using chocolatey

I am trying to install the openssh package using chocolatey. I got the necessary command from a blog post but it is failing:

PS C:\WINDOWS\system32> choco install openssh -params '"/SSHServerFeature /KeyBasedAuthenticationFeature"' –y
Chocolatey v0.10.8
Installing the following packages:
openssh;-y
By installing you accept licenses for the packages.
openssh v0.0.21.0 already installed.
 Use --force to reinstall, specify a version to install, or try upgrade.
-y not installed. The package was not found with the source(s) listed.
 If you specified a particular version and are receiving this message, it is possible that the package name exists but the
version does not.
 Version: ""
 Source(s): "https://chocolatey.org/api/v2/"

Chocolatey installed 0/2 packages. 1 packages failed.
 See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).

Warnings:
 - openssh - openssh v0.0.21.0 already installed.
 Use --force to reinstall, specify a version to install, or try upgrade.

Failures
 - -y - -y not installed. The package was not found with the source(s) listed.
 If you specified a particular version and are receiving this message, it is possible that the package name exists but the
version does not.
 Version: ""
 Source(s): "https://chocolatey.org/api/v2/"

So I have two problems:

  1. Why is the ‘-y’ option failing?
  2. The package seems to be already installed but:
> choco uninstall openssh -y
Chocolatey v0.10.8
Uninstalling the following packages:
openssh

openssh v0.0.21.0
 Skipping auto uninstaller - No registry snapshot.

Chocolatey uninstalled 1/1 packages.
 See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).

does not fix the problem. The install still fails.

I then try to start the ssh-agent but that also fails:

> Start-Service ssh-agent
Start-Service : Cannot find any service with service name 'ssh-agent'.
At line:1 char:1
+ Start-Service ssh-agent
+ ~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (ssh-agent:String) [Start-Service], ServiceCommandException
    + FullyQualifiedErrorId : NoServiceFoundForGivenName,Microsoft.PowerShell.Commands.StartServiceCommand

Can anyone help please?

I haven’t messed with chocolatey much, but it looks like the command is reading the ‘-y’ as a second package to install, not as a switch. I did a quick test and if you put the -y before the -params it should read it correctly.

choco install openssh -y -params '"/SSHServerFeature /KeyBasedAuthenticationFeature"'

alternatively you can use this format which also looks like it works

choco install openssh --params='"/SSHServerFeature /KeyBasedAuthenticationFeature"' -y

Thanks Jeremy, that has fixed it. The SSH client is now working.

Just curious.
Any reason you choose to go the route chocolatey vs using PowerShellGet?

It’s in v5 and higher by default.
v4 you had to download and install it.

Details…

Package Management for PowerShell Modules with PowerShellGet

blogs.msdn.microsoft.com/mvpawardprogram/2014/10/06/package-management-for-powershell-modules-with-powershellget

PowerShellGet Module

technet.microsoft.com/en-us/library/dn835097.aspx
docs.microsoft.com/en-us/powershell/module/powershellget/?view=powershell-5.1
www.powershellgallery.com
GitHub - PowerShell/PowerShellGet: PowerShellGet is the package manager for PowerShell