更新 Ubuntu 来宾后的流浪"ssh_exchange_identification: Connection closed by remote host"



这是我第二次发生这种情况:我使用 Vagrant 创建了一个虚拟的 Ubuntu 机器,并在运行后

sudo apt-get 更新sudo apt-get upgrade

我得到了这个:

    default: SSH username: vagrant
    default: SSH auth method: private key
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
Timed out while waiting for the machine to boot. This means that
Vagrant was unable to communicate with the guest machine within
the configured ("config.vm.boot_timeout" value) time period.
If you look above, you should be able to see the error(s) that
Vagrant had when attempting to connect to the machine. These errors
are usually good hints as to what may be wrong.
If you're using a custom box, make sure that networking is properly
working and you're able to connect to the machine. It is a common
problem that networking isn't setup properly in these boxes.
Verify that authentication configurations are also setup properly,
as well.
If the box appears to be booting properly, you may want to increase
the timeout ("config.vm.boot_timeout") value.

当我调试 ssh 连接时,我看到这个:

vagrant ssh -- -vvv
OpenSSH_6.9p1, LibreSSL 2.1.8
debug1: Reading configuration data ~/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 20: Applying options for *
debug1: /etc/ssh/ssh_config line 102: Applying options for *
debug2: ssh_connect: needpriv 0
debug1: Connecting to 127.0.0.1 [127.0.0.1] port 2222.
debug1: Connection established.
debug1: key_load_public: No such file or directory
debug1: identity file ~/.vagrant/machines/default/virtualbox/private_key type -1
debug1: key_load_public: No such file or directory
debug1: identity file ~/.vagrant/machines/default/virtualbox/private_key-cert type -1
ssh_exchange_identification: Connection closed by remote host

这在Linux中发生在我身上,在Mac OS上也发生了同样的事情。

也许有一个错误,或者我做错了什么。

以下解决方案非常适合我:

  1. 转到主目录路径:sudo chmod go-w/usr/local
  2. 转到项目框:a)流浪者重新加载,b)流浪者UP和c)流浪者SSH。

我在 OSX 1.0.1 和 Vagrant 1.9.1 上的 laravel/homestead 1.0.1 框中遇到了这个问题。

在虚拟机箱虚拟机设置中打开适配器上的"电缆已连接"。

Virtual Box GUI>VM Settings>Network>Adapter> ☑ Cable Connected

要永久解决此问题...把它添加到你的流浪文件的中间。

config.vm.provider 'virtualbox' do |vb| vb.customize ['modifyvm', :id, '--cableconnected1', 'on'] end

ssh_exchange_identification: Connection closed by remote host可能与 VirtualBox 5.0.20 中有关使用通配符来宾地址处理端口转发的更改有关,这会导致您遇到的connection closed问题。有关此问题的详细信息:

  • 虚拟盒子票
  • 流浪问题

有两种方法可以解决此问题:

  1. 安装包含修补程序的测试版本,该修复程序将设置初始.15来宾 IP 地址
  2. Vagrantfile中为forwarded_port设置定义guest_ip值(文档)。

这是我在遇到相同错误后对我有用的方法。

从终端中,导航到包含 .vagrant 目录的文件夹并运行以下命令:

 $ vagrant destroy
 $ vagrant up
 $ vagrant ssh

您应该恢复并运行。祝您编码愉快!

最新更新