我正在尝试通过 SSH 从我的 Linux 机器连接到 WSL,但目前还没有成功。我研究过:
- https://superuser.com/questions/1123552/how-to-ssh-into-wsl
- https://github.com/Microsoft/BashOnWindows/issues/300
- https://superuser.com/questions/1111591/how-can-i-ssh-into-bash-on-ubuntu-on-windows-10
我几乎尝试了所有方法。关闭防火墙、不同的端口、AllowUsers、PermitRootLogin、UsePrivilegeSeparation 等。我实际上可以毫无问题地从 Windows 机器 ssh 到我的 Linux 机器。而且由于我关闭了 Windows 系统上的防火墙,我在调试连接(从 Linux 到 WSL)时也得到了“已建立连接”的信息:
$ ssh -vvv 192.168.2.8 -p 2222
OpenSSH_7.5p1, OpenSSL 1.1.0e 16 Feb 2017
debug1: Reading configuration data /home/user/.ssh/config
debug1: /home/user/.ssh/config line 1: Applying options for *
debug1: Reading configuration data /etc/ssh/ssh_config
debug2: resolving "192.168.2.8" port 2222
debug2: ssh_connect_direct: needpriv 0
debug1: Connecting to 192.168.2.8 [192.168.2.8] port 2222.
debug1: Connection established.
debug1: identity file /home/user/.ssh/id_rsa type 1
debug1: key_load_public: No such file or directory
debug1: identity file /home/user/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/user/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/user/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/user/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/user/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/user/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/user/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.5
^C
但没有出现登录信息,所以我按 Ctrl+C 键。Linux 机器是 Arch Linux,SSH 版本见上文。
我很确定问题一定出在 Windows 机器上,因为当我在 Windows 机器上尝试本地 ssh (ssh -vvv[电子邮件保护]-p 2222):连接已建立,然后中断。
希望有人能给出更多想法。