Ubuntu

無法從 Windows 10 SSH 進入虛擬機(之前可以正常工作)

  • February 16, 2021

我在我的主機 Windows 10 機器上的 Oracle Virtual Box 中執行 Ubuntu 14 VM,用於執行 mininet 的大學作業。一切都執行良好,直到有一天我醒來並嘗試通過 ssh 連接到虛擬機,它讓我登錄(顯示歡迎消息),但沒有顯示提示。就像它只是一條閃爍的線,表示我可以輸入,但如果我按 Enter 或任何其他操作,我的電腦會發出嗶聲,然後按Ctrl+D結束它。

我使用 SSH

ssh user@ip

它在前一天執行得非常好,我不記得做過任何會毀掉它的改變。我已經解除安裝了 VM 映像並重新導入了新版本,我已經重新安裝了虛擬機,並嘗試了 VM 內的各種設置以使其工作但無濟於事。我可以使用 PuTTy SSH 進入 VM,但我需要使用 Visual Studio,它不支持 PuTTy。我覺得問題出在我的主機上,但我無法弄清楚它是什麼。

關於我可以做些什麼來嘗試修復它的任何提示?

使用下面的 -v 命令更新。Ctrl我用+手動關閉連接後連接關閉D。歡迎消息顯示,但之後什麼都沒有,只是游標閃爍。

PS C:\WINDOWS\system32> ssh -v  cs551@192.168.56.10
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: curve25519-sha256@libssh.org
debug1: kex: host key algorithm: ecdsa-sha2-nistp256
debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: kex: client->server cipher: chacha20-poly1305@openssh.com 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
cs551@192.168.56.10'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 no-more-sessions@openssh.com
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 eow@openssh.com 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) 首先,您可以通過在 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了。

引用自:https://unix.stackexchange.com/questions/634772