PowerShell OpenSSHUtils

7.6k Views Asked by At

I am trying to import module OpenSSHUtils under Win 10, PS 5.1.

The latest version (whatever the number) is apparently not available.

> Install-Module -Force OpenSSHUtils -Scope CurrentUser
PackageManagement\Install-Package : No se encontró ninguna coincidencia para el criterio de búsqueda especificado y el nombre de paquete 'OpenSSHUtils'
...
> Find-Module -Name 'OpenSSHUtils' -Verbose
VERBOSE: Detalles del repositorio: Nombre = 'PSGallery', Ubicación = 'https://www.powershellgallery.com/api/v2'; IsTrusted = 'False'; IsRegistered = 'True'.
VERBOSE: Detalles del repositorio: Nombre = 'PSGallery', Ubicación = 'https://www.powershellgallery.com/api/v2'; IsTrusted = 'False'; IsRegistered = 'True'.
VERBOSE: Uso del proveedor 'PowerShellGet' para buscar paquetes.
VERBOSE: No se especificó el parámetro -Repository. PowerShellGet usará todos los repositorios registrados.
VERBOSE: Obteniendo el objeto de proveedor para el proveedor de PackageManagement 'NuGet'.
VERBOSE: La ubicación especificada es 'https://www.powershellgallery.com/api/v2' y el proveedor de PackageManagement es 'NuGet'.
VERBOSE: Searching repository 'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='OpenSSHUtils'' for ''.
VERBOSE: Total package yield:'0' for the specified package 'OpenSSHUtils'.
PackageManagement\Find-Package : No se encontró ninguna coincidencia para el criterio de búsqueda especificado y el nombre de paquete 'OpenSSHUtils'. Prueba
Get-PSRepository para ver todos los orígenes de paquete registrados disponibles.
...

So I tried with ver 1.0.0.1

> Install-Module -Name OpenSSHUtils -RequiredVersion 1.0.0.1 -Scope CurrentUser

Untrusted repository
You are installing the modules from an untrusted repository. If you trust this repository, change its InstallationPolicy value by running the Set-PSRepository cmdlet.
Are you sure you want to install the modules from 'PSGallery'?
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "N"): y
PackageManagement\Install-Package : El módulo "OpenSSHUtils" no se puede instalar ni actualizar porque la firma Authenticode del archivo "OpenSSHUtils.psd1" no es
válida.
...

When faced with the signature issue, I tried downloading the nuget and installing locally as mentioned here, at https://www.powershellgallery.com/packages/OpenSSHUtils/1.0.0.1 . But it is apparently not available anymore ("The owner has unlisted this package. This could mean that the module is deprecated or shouldn't be used anymore.") Note that I could access individual files https://www.powershellgallery.com/packages/OpenSSHUtils/1.0.0.1/Content/OpenSSHUtils.psd1 and https://www.powershellgallery.com/packages/OpenSSHUtils/1.0.0.1/Content/OpenSSHUtils.psm1 .

So I am intrigued by a few issues. Mainly:

  1. How can I get OpenSSHUtils installed?

Other more granular questions:

  1. When I try to install the package from the gallery, the problem is with the signature. Does this mean that the package is actually available, and I should find a way to solve the signature issue? Or it may be the case that the package is not there anyway?
  2. How can I work around the signature issue?
  3. Where can I find the nuget package?
  4. Is having the psd1 and psm1 equivalent to having the nuget?

Related:

Windows 10 SSH server installation does not create required services

2

There are 2 best solutions below

0
On BEST ANSWER

Quick Answer

In short, OpenSSHUtils has been deprecated by Microsoft (as you've indicated) and is no longer required. It is not recommended that you attempt to install this.

If you explain to us what feature from OpenSSHUtils you require, we can help you with a workaround.

  • Most likely you'll be able to find what you're looking for on the Windows OpenSSH Github Repo

Furthermore, this GitHub comment references most of the open issues regarding the deprecation. https://github.com/MicrosoftDocs/windowsserverdocs/issues/3400#issuecomment-658249949

Manual Installation

This is not recommended, but I'm explaining it to give you a better understanding of custom modules. This can also be used if Install-Module is not available on your version of PowerShell.

Where can I find the nuget package?

You've actually already linked it (https://www.powershellgallery.com/packages/OpenSSHUtils/1.0.0.1). If you click on "Manual Download" you'll be able to manually download it.

Is having the psd1 and psm1 equivalent to having the nuget?

The psd1 is all you need to be able to use the module. You'll need to manually install it.

  1. type $env:PSModulePath to determine the locations PowerShell looks for modules on your system. The recommended location is C:\Windows\system32\WindowsPowerShell\v1.0\Modules\ for system-wide use.
C:\Users\user\Documents\WindowsPowerShell\Modules;C:\Program Files\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules\;c:\Program Files (x
86)\Microsoft SQL Server\110\Tools\PowerShell\Modules\;C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\Modules;C:\Program Files\Microsoft Monitoring Agent\
Agent\PowerShell\
  1. Create the OpenSSHUtils directory in C:\Windows\system32\WindowsPowerShell\v1.0\Modules\

  2. Copy the directories and folders from opensshutils.1.0.0.1.nupkg to this location. You can discard the NuGet specific items (package, OpenSSHUtils.nuspec, _rels, package, [Content_Types].xml)

  3. Use Get-Module -ListAvailable to verify the OpenSSHUtils Module is listed

1
On

Quick and Dirty Answer:

This is the command needed to install it, to get past the signature check. Install-Module -Name OpenSSHUtils -RequiredVersion 1.0.0.1 -SkipPublisherCheck -Scope CurrentUser

Note: (-Scope CurrentUser is optional, that was in the question, so it's in the answer.)

Short Answer with Explanation:

What klabarge said about OpenSSHUtils being depreciated and likely no longer needed is correct, but, if you need or want to install it, it's still possible, and quite easy.

The PowerShell command is simply: Install-Module -Name OpenSSHUtils -RequiredVersion 1.0.0.1 -SkipPublisherCheck You can add on additional parameters such as -Scope with either CurrentUser or AllUsers, if necessary, but the default Scope, if run in an Admin PowerShell prompt, is AllUsers.

You will be presented with the following:Are you sure you want to install the modules from 'PSGallery'? [Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "N") so you must press Y (or A) in order to proceed, allowing it to install the module from PSGallery.

As you note in your question:

So I tried with ver 1.0.0.1

Install-Module -Name OpenSSHUtils -RequiredVersion 1.0.0.1 -Scope CurrentUser

Untrusted repository You are installing the modules from an untrusted repository. If you trust this repository, change its InstallationPolicy value by running the Set-PSRepository cmdlet. Are you sure you want to install the modules from 'PSGallery'? [Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "N"): y PackageManagement\Install-Package : El módulo "OpenSSHUtils" no se puede instalar ni actualizar porque la firma Authenticode del archivo "OpenSSHUtils.psd1" no es válida. ... When faced with the signature issue, I tried downloading the nuget and installing locally as mentioned here, at https://www.powershellgallery.com/packages/OpenSSHUtils/1.0.0.1 .

The relevant portion of the error, in English:

Install-Package : The module 'OpenSSHUtils' cannot be installed or updated because the authenticode
signature of the file 'OpenSSHUtils.psd1' is not valid.                                                                 

So, essentially, it's signed with a key that Windows 10 no longer recognizes as valid, and so, to bypass that, -SkipPublisherCheck is required.

You can then, in an Administrative Powershell Prompt, run Get-Module -ListAvailable | ? Name -like '*OpenSSHUtils*' to verify that it is installed.

If it worked, you'll see something like so:

ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     1.0.0.1    OpenSSHUtils                        {Repair-SshdHostKeyPermission, Repair-FilePermission, Repair-AuthorizedKeyPermissio...