无法使用 Powershell 7 使用 SSH

Adn*_*hir 5 windows ssh openssh powershell-7

当我尝试使用 powershell 7 来使用 ssh 时,它会抛出错误:

ssh: The term 'ssh' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
Run Code Online (Sandbox Code Playgroud)

powershell 错误

但它在 cmd 和 windows powershell 上运行良好 使用 CMD 工作 使用 Windows Powershell

我还注意到我无法将目录更改为 OpenSSH (C:\Windows\System32\OpenSSH) 无法 cd 到 OpenSSH

我尝试将 Openssh 添加到系统路径,安装 openssh 客户端和服务器,但没有成功。

我该如何修复它?

Adn*_*hir 1

我终于解决了这个问题。

安装 PowerShell 时,我常常选中启用 PowerShell 远程处理的复选框。不过,这次我没有,现在 SSH 可以工作了。

解决方法如下:

  1. 如果未安装 OpenSSH(甚至无法在 cmd 中工作),则首先按照以下步骤操作:开始使用 OpenSSH for Windows
  2. 卸载 PowerShell。
  3. 下载安装程序:PowerShell 最新版本
  4. 在安装过程中,请确保未选中 PowerShell 远程处理框。 保持 PowerShell 远程处理处于未选中状态

这就是我所要做的。

这是它工作的屏幕截图: 在此输入图像描述