【问题标题】:Vagrant "ssh_exchange_identification: Connection closed by remote host" after update Ubuntu guest更新 Ubuntu 来宾后流浪“ssh_exchange_identification:远程主机关闭连接”
【发布时间】:2016-05-27 16:59:29
【问题描述】:

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

sudo apt-get 更新 sudo apt-get 升级

我知道了:

    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 上也发生过。

也许有错误或我做错了什么。

【问题讨论】:

    标签: linux macos ubuntu vagrant virtual-machine


    【解决方案1】:

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

    1. 进入主目录路径:sudo chmod go -w /usr/local
    2. 转到项目框:a) vagrant reload,b) vagrant up & c) vagrant ssh。

    【讨论】:

      【解决方案2】:

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

      在 Virtual Box VM 设置中打开适配器上的“已连接电缆”。

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

      要永久修复此问题...将其添加到您的 vagrantfile 中间。

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

      【讨论】:

      • 这解决了我今天使用 VirtualBox 5.0.30 和 Vagrant 1.9.1 的问题
      【解决方案3】:

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

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

      1. Install a test build 包含将设置初始 .15 访客 IP 地址的修复程序
      2. Vagrantfile 中为 forwarded_port 设置 (documentation) 定义一个 guest_ip 值。

      【讨论】:

      • 彼得,感谢您的评论,因为我已经更新了我的 VirtualBox,我不能说这是否解决了我的问题或者是否发生了其他事情。不幸的是,我错过了跟踪这个问题的机会。不过还是谢谢。
      【解决方案4】:

      在我遇到同样的错误后,这对我有用。

      从您的终端导航到您的 .vagrant 目录所在的文件夹并运行以下命令:

       $ vagrant destroy
      
       $ vagrant up
      
       $ vagrant ssh
      

      您应该已恢复正常运行。 编码愉快!

      【讨论】:

      • 不要这样做!这也将破坏数据库,如 MySQL 和其他环境变量,这是无法撤消的。无论如何,这并不是真正的解决方案,因为这并不能解决问题,只能绕过它(可能是暂时的)
      • 小心丢失你的流浪盒子!
      猜你喜欢
      • 2021-02-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-08-13
      • 1970-01-01
      • 1970-01-01
      • 2013-01-25
      • 1970-01-01
      相关资源
      最近更新 更多