【问题标题】:Windows 10 SSH server installation does not create required servicesWindows 10 SSH 服务器安装未创建所需服务
【发布时间】:2020-07-31 05:15:28
【问题描述】:

我正在尝试在我的 Windows 10 电脑上安装 Open-SSH,以便使用 ssh 从我的 linux 机器连接到它。我关注this tutorial,但是一旦我必须运行Start-Service ssh-agent 之类的东西,它就会说该服务不存在。另一个不起作用的是Install-Module -Force OpenSSHUtils,它说the signature of the file 'OpenSSHUtils.psd1' is not valid. 我尝试了许多其他教程,在每个教程之前都卸载了所有内容,但没有一个可以工作。有没有办法手动安装这些东西?我错过了安装的重要步骤吗?

【问题讨论】:

  • 如果您没有正确安装模块,那么很可能没有任何效果。如果运行以下命令会产生什么结果?获取执行策略。还有你用什么方法安装的? Powershell/DISM/Windows 功能?
  • @Scepticalist 当我运行该命令时,它显示不受限制。 (我正在使用管理员权限)我已经尝试了所有这三种方法,但我觉得我使用 Powershell 获得的最远
  • 这个问题与Powershell中的编码问题无关。

标签: powershell windows-10 openssh


【解决方案1】:

您知道您可以使用“添加功能”选项直接在 Windows 10 中安装 SSH,对吗?无需下载外部模块/工具,除非内置模块/工具不能满足您的所有需求。

Installation of OpenSSH For Windows Server 2019 and Windows 10

# Install the OpenSSH Client
Add-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0

# Install the OpenSSH Server
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0

使用图形用户界面

How to Enable and Use Windows 10’s New Built-in SSH Commands

然而,如果您决定使用外部的东西,那么,在真正实施之前,请始终测试破坏性(CUD = 创建、更新、删除)代码。

Find-Module -Name 'OpenSSHUtils' -Verbose

<#
VERBOSE: Repository details, Name = 'PSGallery', Location = 'https://www.powershellgallery.com/api/v2'; IsTrusted = 'False'; IsRegistered = 'True'.
VERBOSE: Repository details, Name = 'PSGallery', Location = 'https://www.powershellgallery.com/api/v2'; IsTrusted = 'False'; IsRegistered = 'True'.
VERBOSE: Using the provider 'PowerShellGet' for searching packages.
VERBOSE: The -Repository parameter was not specified.  PowerShellGet will use all of the registered repositories.
VERBOSE: Getting the provider object for the PackageManagement Provider 'NuGet'.
VERBOSE: The specified Location is 'https://www.powershellgallery.com/api/v2' and PackageManagementProvider is 'NuGet'.
VERBOSE: Searching repository 'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='OpenSSHUtils'' for ''.
VERBOSE: Total package yield:'1' for the specified package 'OpenSSHUtils'.

Version              Name                                Repository           Description                                                                                                           
-------              ----                                ----------           -----------                                                                                                           
1.0.0.1              OpenSSHUtils                        PSGallery            Configure OpenSSH for Windows related security settings like file owner and permissions. 
#>


Find-Module -Name 'OpenSSHUtils' -Verbose | 
Save-Module -Path "$env:USERPROFILE\Documents\WindowsPowerShell\Modules" -Verbose -WhatIf
<#
VERBOSE: Repository details, Name = 'PSGallery', Location = 'https://www.powershellgallery.com/api/v2'; IsTrusted = 'False'; IsRegistered = 'True'.
VERBOSE: Repository details, Name = 'PSGallery', Location = 'https://www.powershellgallery.com/api/v2'; IsTrusted = 'False'; IsRegistered = 'True'.
VERBOSE: Using the provider 'PowerShellGet' for searching packages.
VERBOSE: The -Repository parameter was not specified.  PowerShellGet will use all of the registered repositories.
VERBOSE: Getting the provider object for the PackageManagement Provider 'NuGet'.
VERBOSE: The specified Location is 'https://www.powershellgallery.com/api/v2' and PackageManagementProvider is 'NuGet'.
VERBOSE: Searching repository 'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='OpenSSHUtils'' for ''.
VERBOSE: Total package yield:'1' for the specified package 'OpenSSHUtils'.
VERBOSE: Repository details, Name = 'PSGallery', Location = 'https://www.powershellgallery.com/api/v2'; IsTrusted = 'False'; IsRegistered = 'True'.
VERBOSE: Using the provider 'PowerShellGet' for searching packages.
VERBOSE: Using the specified source names : 'PSGallery'.
VERBOSE: Getting the provider object for the PackageManagement Provider 'NuGet'.
VERBOSE: The specified Location is 'https://www.powershellgallery.com/api/v2' and PackageManagementProvider is 'NuGet'.
VERBOSE: Searching repository 'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='OpenSSHUtils'' for ''.
VERBOSE: Total package yield:'1' for the specified package 'OpenSSHUtils'.
What if: Performing the operation "Save Package" on target "'OpenSSHUtils' to location 'C:\Users\Daniel\Documents\WindowsPowerShell\Modules'".
#>

Install-Module -Name 'OpenSSHUtils' -Verbose -WhatIf

<#
VERBOSE: Using the provider 'PowerShellGet' for searching packages.
VERBOSE: The -Repository parameter was not specified.  PowerShellGet will use all of the registered repositories.
VERBOSE: Getting the provider object for the PackageManagement Provider 'NuGet'.
VERBOSE: The specified Location is 'https://www.powershellgallery.com/api/v2' and PackageManagementProvider is 'NuGet'.
VERBOSE: Searching repository 'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='OpenSSHUtils'' for ''.
VERBOSE: Total package yield:'1' for the specified package 'OpenSSHUtils'.
What if: Performing the operation "Install-Module" on target "Version '1.0.0.1' of module 'OpenSSHUtils'".
#>

【讨论】:

  • 我遵循了所有命令,但Install-Module -Name 'OpenSSHUtils' -Verbose gives this error: 无法安装或更新模块“OpenSSHUtils”,因为文件“OpenSSHUtils.psd1”的身份验证签名无效。 microsoft 的教程,当它说要这样做时:Start-Service sshd # OPTIONAL but recommended: Set-Service -Name sshd -StartupType 'Automatic' 它什么也不做,因为该服务不存在。甚至没有任何与 ssh 或 sshd 相关的服务。
  • 您可以从这里手动下载模块:powershellgallery.com/packages/OpenSSHUtils/1.0.0.1。使用 winzip 或类似工具打开 NuPkg 并将文件夹复制到您的模块文件夹。然后看看 Import-module 是否有效。
猜你喜欢
  • 2017-03-14
  • 2018-02-05
  • 1970-01-01
  • 1970-01-01
  • 2018-02-18
  • 2017-02-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多