Int*_*rer 2 windows ssh powershell openssh sshd
我有一台 Windows 10 Pro 计算机,我可以ssh
将其作为cmd
. 我希望将 shell 设置为powershell.exe
(不是默认的cmd.exe
)。
C:\ProgramData\ssh\sshd
我尝试在本文中设置以下内容,然后设置Restart-Service sshd
,但这不起作用:
Subsystem powershell c:/Windows/System32/WindowsPowerShell/v1.0/powershell.exe -sshs -NoLogo -NoProfile
Run Code Online (Sandbox Code Playgroud)
这也不起作用:
Subsystem powershell C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -sshs -NoLogo -NoProfile
Run Code Online (Sandbox Code Playgroud)
我已经确认C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
PowerShell的位置正确。
如何使 shell 成为 PowerShell 以ssh
访问 Windows 主机?
Subsystem
并不意味着更改您的默认 shell,恰恰相反 \xe2\x80\x93 它定义了客户端必须显式请求的命令。(它实际上是服务器端别名。)
因此,您找到的配置片段并不意味着改变您从常规中获得的内容ssh
;它的目的是允许本地 PowerShell 实例调用 SSH 客户端并在服务器上启动远程 PowerShell,而无需知道其路径(它需要指定的只是子系统名称)。
具体来说,该-sshs
选项表明它适用于使用或cmdlet通过 SSH 进行PSRemoting,该 cmdlet 可以通过 SSH 在 PowerShell\xc2\xa07 中运行。Enter-PSSession
Invoke-Command
PS> Enter-PSSession -HostName otherpc\n[otherpc] PS>\n
Run Code Online (Sandbox Code Playgroud)\n(-HostName
选项使其使用 SSH,而-ComputerName
使其使用 WinRM。)
(这在 PowerShell 5 \xe2\x80\x93 中不起作用,其 PSRemoting 支持只能通过 WinRM运行,但如果您需要 PowerShell,那么 WinRM 实际上是 SSH 的不错替代品。)
\n实际上,更改 Windows OpenSSH(Microsoft 官方版本)中的默认 shell 是完全不同的 \xe2\x80\x93 它在此页面上记录:
\nPS> Enter-PSSession -HostName otherpc\n[otherpc] PS>\n
Run Code Online (Sandbox Code Playgroud)\n
归档时间: |
|
查看次数: |
1468 次 |
最近记录: |