【问题标题】:Vagrant freezes (timeouts) at SSH auth method: private keyVagrant 在 SSH 身份验证方法处冻结(超时):私钥
【发布时间】:2021-01-14 01:21:00
【问题描述】:

所以 - 我搜索了这个并发现了大约 100 万个关于 vagrant 配置和 ssh 代理的问题。我尝试了很多解决方案,但没有任何效果。我尝试为网络适配器(VirtualBox)添加选项,销毁机器,重新安装 vagrant 等等,每次我需要运行 vagrant 这个东西都会阻止我工作。

现在我正在使用全新的操作系统安装 (Ubuntu 20.04)!我按照 oracle 网站上的说明安装了 VirtualBox 6.1,并从 vagrantup.com/downloads 下载了正确的 vagrant 二进制文件。

再一次 - vagrant 立即失败了!好吧 - 让我们面对现实吧 - vagrant 有问题,应该被替换,但是有些项目我没有任何预算来迁移到容器,所以我需要让这个设置再次工作 - 希望有人为我提供解决方案,实际上有效。

好的 - 这是最终的vagrant up 输出:

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.

因此机器运行但 vagrant 无法连接并运行配置。它基本上是下载图像并启动它。

所以我试试vagrant ssh --debug

我看到的最后几行:

Checking key permissions: ~/.vagrant.d/insecure_private_key
 INFO ssh: Invoking SSH: /tmp/.mount_vagran2MLjJR/usr/bin/ssh ["vagrant@127.0.0.1", "-p", "2222", "-o", "LogLevel=FATAL", "-o", "Compression=yes", "-o", "DSAAuthentication=yes", "-o", "IdentitiesOnly=yes", "-o", "StrictHostKeyChecking=no", "-o", "UserKnownHostsFile=/dev/null", "-i", "~/.vagrant.d/insecure_private_key"]

就是这样 - 该命令将失败,恕不另行通知。

所以我只能杀死虚拟机(使用 vagrant halt 关闭也不起作用!)并尝试获取更多日志:

(只是为了确保我重新安装了 vbguest 插件)

vagrant up --debug

好的 - 屏幕输出看起来像一个循环。而且我只能使用给定的选项(密钥路径等)找到“正在尝试 SSH 连接...”

几分钟后(我猜是配置的超时)我可以看到:

INFO interface: Machine: error-exit ["Vagrant::Errors::VMBootTimeout", "Timed out while waiting for the machine to boot. This means that\nVagrant was unable to communicate with the guest machine within\nthe configured (\"config.vm.boot_timeout\" value) time period.\n\nIf you look above, you should be able to see the error(s) that\nVagrant had when attempting to connect to the machine. These errors\nare usually good hints as to what may be wrong.\n\nIf you're using a custom box, make sure that networking is properly\nworking and you're able to connect to the machine. It is a common\nproblem that networking isn't setup properly in these boxes.\nVerify that authentication configurations are also setup properly,\nas well.\n\nIf the box appears to be booting properly, you may want to increase\nthe timeout (\"config.vm.boot_timeout\") value."]

这是一些配置:

unless Vagrant.has_plugin?("vagrant-vbguest")
  raise 'vagrant-vbguest is not installed, see README.md!'
end
unless Vagrant.has_plugin?("vagrant-disksize")
  raise 'vagrant-disksize is not installed, see README.md!'
end
Vagrant.configure("2") do |config|
  # https://docs.vagrantup.com
  config.vm.box = "ubuntu/bionic64"
  config.disksize.size = "25GB"

  # forward http traffic
  config.vm.network "forwarded_port", guest: 80, host: 8083
  # forward mysql
  config.vm.network "forwarded_port", guest: 3306, host: 3308
  # forward xdebug
  config.vm.network "forwarded_port", guest: 9000, host: 9000
  # forward elastic
  config.vm.network "forwarded_port", guest: 9200, host: 9200
  # forward solr
  config.vm.network "forwarded_port", guest: 8983, host: 8983

  config.vm.synced_folder ".", "/vagrant",
    type: "virtualbox",
    id: "vagrant-root",
    owner: "vagrant",
    group: "www-data",
    mount_options: ["dmode=775,fmode=664"]

  config.vm.provider "virtualbox" do |vb|
    vb.memory = "8192"
    vb.cpus = 4
    vb.customize [ "modifyvm", :id, "--uartmode1", "disconnected" ]
    vb.customize [ "modifyvm", :id, "--cableconnected1", "on" ]
  end

  config.vm.provision "shell", path: "config/bootstrap.sh"
  config.vm.provision "shell", path: "config/solr.sh"
  config.vm.provision "shell", path: "config/startup.sh", run: "always"

end

我的问题是 - 我不知道如何解决这个问题。如果我可以禁用 ssh 身份验证或使用密码,我会很高兴,但我需要连接到 vm 才能更改它......即使我可以使用 virtualbox 登录,我也只能修复我的本地安装。但是还有其他人也在处理该代码,并且解决方案应该可以解决此问题。

再次总结一下:

我们处理:

  • 标准的 Ubuntu 20.04
  • 标准的 VirtualBox 安装
  • 原始的 vagrant 二进制文件

全新安装

不会工作

亲切的问候, 菲利普

【问题讨论】:

标签: ssh vagrant virtualbox vagrant-ssh


【解决方案1】:

好的,通过添加以下行(此处引用:https://github.com/hashicorp/vagrant/issues/11777),我可以成功地将配置和 ssh 运行到机器中。

config.vm.provider :virtualbox do |v|
  v.customize ["modifyvm", :id, "--uart1", "0x3F8", "4"]
  v.customize ["modifyvm", :id, "--uartmode1", "file", File::NULL]
end

所以你似乎需要什么(目前 - 我 100% 确定 vagrant 的下一个 ssh 问题只有几个月后):

Vagrant.configure("2") do |config|
  config.vm.provider "virtualbox" do |vb|
    vb.customize [ "modifyvm", :id, "--uartmode1", "file", File::NULL ]
    vb.customize [ "modifyvm", :id, "--uart1", "0x3F8", "4" ]
    vb.customize [ "modifyvm", :id, "--cableconnected1", "on" ]
  end
end

我注意到选项vb.customize [ "modifyvm", :id, "--uartmode1", "file", File::NULL ] 已经设置了不同的值(vb.customize [ "modifyvm", :id, "--uartmode1", "disconnected" ])并且不知道您是否可以分配多个值或原始选项导致问题。所以我不能肯定地说,如果有人对此有更多的见解,额外的解释会很棒。

我的版本看起来像(仅相关行):

Vagrant.configure("2") do |config|
  config.vm.provider "virtualbox" do |vb|
    vb.customize [ "modifyvm", :id, "--uartmode1", "disconnected" ]
    vb.customize [ "modifyvm", :id, "--uartmode1", "file", File::NULL ]
    vb.customize [ "modifyvm", :id, "--uart1", "0x3F8", "4" ]
    vb.customize [ "modifyvm", :id, "--cableconnected1", "on" ]
  end
end

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-12-30
    • 2017-09-08
    • 1970-01-01
    • 2019-10-11
    • 1970-01-01
    • 2017-04-19
    • 2014-05-20
    相关资源
    最近更新 更多