无法从 Windows 10 通过 SSH 连接到虚拟机(之前可以正常工作)

无法从 Windows 10 通过 SSH 连接到虚拟机(之前可以正常工作)

我正在 Windows 10 主机上的 Oracle Virtual Box 中运行 Ubuntu 14 VM,以完成运行 mininet 的大学作业。一切都运行良好,直到有一天我醒来并尝试 ssh 进入虚拟机,它让我登录(显示欢迎消息),但提示不显示。就像它只是一条闪烁的线,表明我可以输入,但如果我按 Enter 或任何其他内容,我的计算机会发出蜂鸣声,然后按Ctrl+D结束它。

我使用 ssh

ssh user@ip

它在前一天工作得非常完美,我不记得做过任何会毁掉它的改变。我卸载了虚拟机映像并重新导入了新版本,重新安装了虚拟盒,并尝试了虚拟机内的各种设置以使其正常工作,但无济于事。我可以使用 PuTTy ssh 进入虚拟机,但我需要使用 Visual Studio,而且它不支持 PuTTy。我觉得问题出在我的主机上,但我无法弄清楚它是什么。

关于我可以采取哪些措施来尝试修复它,有什么建议吗?

使用下面的 -v 命令更新。我用Ctrl+手动关闭连接后,连接关闭了D。欢迎消息显示,但之后什么也没有,只是光标闪烁。

PS C:\WINDOWS\system32> ssh -v  [email protected]
OpenSSH_for_Windows_7.7p1, LibreSSL 2.6.5
debug1: Reading configuration data C:\\Users\\HP/.ssh/config
debug1: C:\\Users\\HP/.ssh/config line 1: Applying options for 192.168.56.10
debug1: Connecting to 192.168.56.10 [192.168.56.10] port 22.
debug1: Connection established.
debug1: identity file C:\\Users\\HP/.ssh/id_rsa type 0
debug1: key_load_public: No such file or directory
debug1: identity file C:\\Users\\HP/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file C:\\Users\\HP/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file C:\\Users\\HP/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file C:\\Users\\HP/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file C:\\Users\\HP/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file C:\\Users\\HP/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file C:\\Users\\HP/.ssh/id_ed25519-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file C:\\Users\\HP/.ssh/id_xmss type -1
debug1: key_load_public: No such file or directory
debug1: identity file C:\\Users\\HP/.ssh/id_xmss-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_for_Windows_7.7
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.6.1p1 Ubuntu-2ubuntu2
debug1: match: OpenSSH_6.6.1p1 Ubuntu-2ubuntu2 pat OpenSSH_6.6.1* compat 0x04000000
debug1: Authenticating to 192.168.56.10:22 as 'cs551'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: [email protected]
debug1: kex: host key algorithm: ecdsa-sha2-nistp256
debug1: kex: server->client cipher: [email protected] MAC: <implicit> compression: none
debug1: kex: client->server cipher: [email protected] MAC: <implicit> compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:wDmGnoAN/7DHHH1OTiFsKC3l4v5PYvxOm659KKLCDwk
debug1: Host '192.168.56.10' is known and matches the ECDSA host key.
debug1: Found key in C:\\Users\\HP/.ssh/known_hosts:1
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey after 134217728 blocks
debug1: pubkey_prepare: ssh_get_authentication_socket: No such file or directory
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Offering public key: RSA SHA256:iMnIfpXDKQgmDCnJSUpBS1x4uOM3gXOa888wrKwkLDI C:\\Users\\HP/.ssh/id_rsa
debug1: Authentications that can continue: publickey,password
debug1: Trying private key: C:\\Users\\HP/.ssh/id_dsa
debug1: Trying private key: C:\\Users\\HP/.ssh/id_ecdsa
debug1: Trying private key: C:\\Users\\HP/.ssh/id_ed25519
debug1: Trying private key: C:\\Users\\HP/.ssh/id_xmss
debug1: Next authentication method: password
debug1: read_passphrase: can't open /dev/tty: No such file or directory
[email protected]'s password:
debug1: Authentication succeeded (password).
Authenticated to 192.168.56.10 ([192.168.56.10]:22).
debug1: channel 0: new [client-session]
debug1: Requesting [email protected]
debug1: Entering interactive session.
debug1: pledge: network
debug1: console doesn't support the ansi parsing
Welcome to Ubuntu 14.04.2 LTS (GNU/Linux 3.13.0-53-generic x86_64)

 * Documentation:  https://help.ubuntu.com/

Last login: Tue Feb 16 06:16:59 2021 from 192.168.56.1

oot
eu: 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.56.10 closed.
Transferred: sent 2212, received 2552 bytes, in 64.7 seconds
Bytes per second: sent 34.2, received 39.5
debug1: Exit status 0
PS C:\WINDOWS\system32>

答案1

(1) 首先,您可以通过在Linux机器上运行以下命令来重新配置SSH服务器:

sudo dpkg-reconfigure openssh-server

如果上述命令失败,只需在 Linux 机器上重新生成 SSH 密钥即可:

$ ssh-keygen -b 2048 -t rsa

(2) 其次,您以管理员身份打开PowerShell (PS)。您需要以普通用户身份打开 PS,其中存在您现有的 SSH 环境变量,然后 SSH 将再次工作。

(3) 第三,从 Windows 机器上删除旧的 SSH 公钥

$ ssh-keygen -R 192.168.56.10

(4) 最后就可以正常进行 SSH 了。

相关内容