我在 Windows 上启动了一个 OpenSSH 服务器,并从 Mac 终端进行连接。
当默认 shell 是 cmd.exe、PowerShell 或 GitBash 时,我能够连接,但当我更改为 bash 时则无法连接。
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 [email protected]
debug1: Entering interactive session.
debug1: pledge: filesystem
debug1: client_input_global_request: rtype [email protected] 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
ファイルにアクセスできません。(※ This message is displayed in Japanese. It means "Cannot access file.)
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
debug1: client_input_channel_req: channel 0 rtype [email protected] 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。但是,在将默认 OpenSSH 终端设置为 PowerShell 并通过 ssh 从 Mac 连接后,运行“C:\Windows\System32\bash.exe”会显示“无法访问文件”并且无法执行。(此消息以日语显示并翻译成英语,因此可能与实际消息不同。)
通过 SSH 连接的用户属于管理员组,与在 Windows 上登录的用户相同。
我尝试将“C:\Windows\System32\bash.exe”复制到用户文件夹并将其设置为默认shell,但结果是一样的。
有谁知道如何解决这个问题?