我正在尝试在 Win 10、PS 5.1 下导入模块 OpenSSHUtils。
最新版本(无论编号如何)显然不可用。
> 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.
...
所以我尝试使用版本 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.
...
当遇到签名问题时,我尝试下载 nuget 并在本地安装,如上所述 here ,位于https://www.powershellgallery.com/packages/OpenSSHUtils/1.0.0.1 。 但它显然不再可用(“所有者已取消列出此软件包。这可能意味着该模块已被弃用或不应再使用。”) 请注意,我可以访问单个文件 https://www.powershellgallery.com/packages/OpenSSHUtils/1.0.0.1/Content/OpenSSHUtils.psd1 和 https://www.powershellgallery.com/packages/OpenSSHUtils/1.0.0.1/Content/OpenSSHUtils.psm1 .
所以我对一些问题很感兴趣。 主要是:
- 如何安装 OpenSSHUtils?
其他更具体的问题:
- 当我尝试从库安装软件包时,问题出在签名上。 这是否意味着该软件包实际上可用,我应该找到解决签名问题的方法? 或者可能是包裹根本不存在?
- 如何解决签名问题?
- 在哪里可以找到 nuget 包?
- 拥有
psd1
和psm1
是否等同于拥有 nuget?
相关:
Windows 10 SSH server installation does not create required services
最佳答案
快速回答
简而言之,OpenSSHUtils 已被 Microsoft 弃用(正如您所指出的)并且不再需要。不建议您尝试安装此程序。
如果您向我们解释您需要 OpenSSHUtils 的哪些功能,我们可以帮助您找到解决方法。
- 您很可能能够在 Windows OpenSSH Github Repo 上找到您要查找的内容。
此外,此 GitHub 评论引用了有关弃用的大多数未决问题。 https://github.com/MicrosoftDocs/windowsserverdocs/issues/3400#issuecomment-658249949
手动安装
不建议这样做,但我解释它是为了让您更好地理解自定义模块。如果 Install-Module
在您的 PowerShell 版本上不可用,也可以使用此方法。
Where can I find the nuget package?
您实际上已经链接了它 ( https://www.powershellgallery.com/packages/OpenSSHUtils/1.0.0.1 )。如果您点击“手动下载”,您将能够手动下载它。
Is having the psd1 and psm1 equivalent to having the nuget?
只需 psd1 即可使用该模块。您需要手动安装它。
- 输入
$env:PSModulePath
以确定 PowerShell 在系统上查找模块的位置。建议的位置是 C:\Windows\system32\WindowsPowerShell\v1.0\Modules\以便在系统范围内使用。
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\
在 C:\Windows\system32\WindowsPowerShell\v1.0\Modules\中创建 OpenSSHUtils 目录
将目录和文件夹从
opensshutils.1.0.0.1.nupkg
复制到此位置。您可以丢弃 NuGet 特定项目(包、OpenSSHUtils.nuspec、_rels、包、[Content_Types].xml)使用 Get-Module -ListAvailable 验证 OpenSSHUtils 模块是否已列出
关于PowerShell OpenSSHUtils,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62873521/