通过 Powershell 安装 OpenSSH

当您尝试使用 ssh <username>@<hostname>.local``(或 ``ssh <username>@<IP address>)连接到 Raspberry Pi 时,出现以下错误信息:

ssh: The term 'ssh' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the
spelling of the name, or if a path was included, verify that the path is correct and try again.

这意味着您的计算机系统版本较旧,没有预装 OpenSSH。您需要按照以下教程手动安装。

  1. 在 Windows 桌面的搜索框中输入 powershell,右键点击 Windows PowerShell,并从出现的菜单中选择 以管理员身份运行

    ../_images/powershell_ssh.jpg
  2. 使用以下命令安装 OpenSSH.Client

    Add-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0
    
  3. 安装完成后,您将看到以下输出:

    Path          :
    Online        : True
    RestartNeeded : False
    
  4. 使用以下命令验证安装情况。

    Get-WindowsCapability -Online | Where-Object Name -like 'OpenSSH*'
    
  5. 此时系统会显示 OpenSSH.Client 已成功安装。

    Name  : OpenSSH.Client~~~~0.0.1.0
    State : Installed
    
    Name  : OpenSSH.Server~~~~0.0.1.0
    State : NotPresent
    

    警告

    如果未出现上述提示,这意味着您的 Windows 系统仍然过于陈旧,建议安装第三方 SSH 工具,例如 PuTTY

  6. 现在,重启 PowerShell 并继续以管理员身份运行。在此状态下,您可以使用 ssh 命令登录到 Raspberry Pi,系统会提示您输入之前设置的密码。

    ../_images/powershell_login.png