无法通过 Powershell 7 使用 SSH

Cannot use SSH using Powershell 7

提问人:Adnan Bin Zahir 提问时间:8/7/2023 更新时间:8/7/2023 访问量:135

问:

当我尝试使用 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.

Error in powershell

但它适用于 cmd 和 windows powershellWorking on CMD Working on Windows Powershell

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

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

我该如何解决?

Windows SSH OpenSSH PowerShell-7

评论

0赞 Nathan McCoy 8/7/2023
当您以什么身份登录时,表示可执行文件驻留?adnanwhere ssh.exe
0赞 Adnan Bin Zahir 8/7/2023
在powershell 7中,它什么也没说,但在其他终端(cmd)中它输出:C:\Windows\System32\OpenSSH\ssh.exe
0赞 Daemon-5 8/8/2023
您是否检查过同名的现有别名或批处理文件:?可能有不同的路径:如果 32 位应用程序在文件夹路径中包含“\System32”文件夹名称,系统会自动重定向到 SysWOW64 文件夹Get-Alias -Name ssh
0赞 Adnan Bin Zahir 8/9/2023
@Daemon-5,不,没有现成的别名。 输出:Get-Alias -Name sshGet-Alias: This command cannot find a matching alias because an alias with the name 'ssh' does not exist.

答:

1赞 Adnan Bin Zahir 12/12/2023 #1

我终于解决了这个问题。

安装 PowerShell 时,我曾经选中启用 PowerShell 远程处理的框。但是,这次我没有,现在SSH可以工作了。

解决方案如下:

  1. 如果未安装 OpenSSH(甚至在 cmd 中不起作用),请先按照以下步骤操作: 适用于 Windows 的 OpenSSH 入门
  2. 卸载 PowerShell。
  3. 下载安装程序:PowerShell 最新版本
  4. 在安装过程中,请确保未选中“PowerShell 远程处理”框。Keep PowerShell remoting unchecked

这就是我所要做的。

这是它工作的屏幕截图:enter image description here