You need to enable JavaScript to run this app.
最新活动
大模型
产品
解决方案
定价
生态与合作
支持与服务
开发者
了解我们

Windows 11 OpenSSH服务器默认Shell改为bash后Mac端无法SSH连接的问题求助

Windows 11 OpenSSH服务器默认Shell改为bash后Mac端无法SSH连接的问题求助

大家好,我最近在Windows上搭建了OpenSSH服务器,用Mac终端尝试远程连接。一开始把默认Shell设为cmd.exe、PowerShell或者GitBash的时候,都能正常连接并使用,但当我把默认Shell改成bash之后,就没法成功连接了。

我是用这条命令修改默认Shell的:

New-ItemProperty -Path "HKLM:\SOFTWARE\OpenSSH" -Name DefaultShell -Value "C:\Windows\System32\bash.exe" -PropertyType String -Force

从Mac端SSH连接时,我得到了如下错误日志:

debug1: channel 0: new [client-session]
debug1: Requesting no-more-sessions@openssh.com
debug1: Entering interactive session.
debug1: pledge: filesystem
debug1: client_input_global_request: rtype hostkeys-00@openssh.com want_reply 0
debug1: client_input_hostkeys: searching /Users/masamoto/.ssh/known_hosts for 192.168.68.74 / (none)
debug1: client_input_hostkeys: searching /Users/masamoto/.ssh/known_hosts2 for 192.168.68.74 / (none)
debug1: client_input_hostkeys: hostkeys file /Users/masamoto/.ssh/known_hosts2 does not exist
debug1: Sending environment.
debug1: channel 0: setting env LC_TERMINAL_VERSION = "3.4.20"
debug1: channel 0: setting env LC_CTYPE = "UTF-8"
debug1: channel 0: setting env LC_TERMINAL = "iTerm2"
debug1: client_global_hostkeys_private_confirm: server used untrusted RSA signature algorithm ssh-rsa for key 0, disregarding
debug1: update_known_hosts: known hosts file /Users/masamoto/.ssh/known_hosts2 does not exist
ファイルにアクセスできません。(※ 该日文提示意为"无法访问文件")
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
debug1: client_input_channel_req: channel 0 rtype eow@openssh.com reply 0
debug1: channel 0: free: client-session, nchannels 1
Connection to 192.168.68.74 closed.
Transferred: sent 4988, received 3760 bytes, in 0.1 seconds
Bytes per second: sent 63995.5, received 48240.4
debug1: Exit status 0

我猜测问题出在无法访问C:\Windows\System32\bash.exe这个文件上:

  • 在Windows本地打开PowerShell,直接执行C:\Windows\System32\bash.exe是能正常启动bash的;
  • 但如果先通过SSH把默认Shell设为PowerShell并成功连接,再在这个远程会话里运行C:\Windows\System32\bash.exe,就会弹出上述的“无法访问文件”错误,无法执行。

另外,通过SSH连接的用户和本地登录的用户一样,都属于管理员组。我还试过把C:\Windows\System32\bash.exe复制到用户文件夹里,再把这个复制后的路径设为默认Shell,但结果还是一样,连接失败。

有没有大佬知道怎么解决这个问题呀?

备注:内容来源于stack exchange,提问作者Masamoto Miyata

火山引擎 最新活动