流浪错误:连接超时。重试


12

我有一台装有Ubuntu 12.04,Virtualbox 4.3和Vagrant 1.5.1的服务器。我正在尝试使用此框http://puppet-vagrant-boxes.puppetlabs.com/centos-64-x64-vbox4210.box但未成功。当我“无所事事”运行时,我收到以下消息:

Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'centos-64-x64-vbox4210'...
==> default: Matching MAC address for NAT networking...
==> default: Setting the name of the VM: rafael_default_1396403974194_51967
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
==> default: Forwarding ports...
    default: 22 => 2222 (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
    default: Error: Connection timeout. Retrying...
    default: Error: Connection timeout. Retrying...
    default: Error: Connection timeout. Retrying...
    default: Error: Connection timeout. Retrying...
    default: Error: Connection timeout. 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.

这是我的流浪文件

# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  # All Vagrant configuration is done here. The most common configuration
  # options are documented and commented below. For a complete reference,
  # please see the online documentation at vagrantup.com.

  # Every Vagrant virtual environment requires a box to build off of.
  config.vm.box = "centos-64-x64-vbox4210"
  config.vm.boot_timeout = 600
  # The url from where the 'config.vm.box' box will be fetched if it
  # doesn't already exist on the user's system.
  # config.vm.box_url = "http://domain.com/path/to/above.box"

  # Create a forwarded port mapping which allows access to a specific port
  # within the machine from a port on the host machine. In the example below,
  # accessing "localhost:8080" will access port 80 on the guest machine.
  # config.vm.network "forwarded_port", guest: 80, host: 8080

  # Create a private network, which allows host-only access to the machine
  # using a specific IP.
  # config.vm.network "private_network", ip: "192.168.33.10"

  # Create a public network, which generally matched to bridged network.
  # Bridged networks make the machine appear as another physical device on
  # your network.
  # config.vm.network "public_network"

  # If true, then any SSH connections made will enable agent forwarding.
  # Default value: false
  # config.ssh.forward_agent = true

  # Share an additional folder to the guest VM. The first argument is
  # the path on the host to the actual folder. The second argument is
  # the path on the guest to mount the folder. And the optional third
  # argument is a set of non-required options.
  # config.vm.synced_folder "../data", "/vagrant_data"
  # Enable provisioning with chef server, specifying the chef server URL,
  # and the path to the validation key (relative to this Vagrantfile).
  #
  # The Opscode Platform uses HTTPS. Substitute your organization for
  # ORGNAME in the URL and validation key.
  #
  # If you have your own Chef Server, use the appropriate URL, which may be
  # HTTP instead of HTTPS depending on your configuration. Also change the
  # validation key to validation.pem.
  #
  # config.vm.provision "chef_client" do |chef|
  #   chef.chef_server_url = "https://api.opscode.com/organizations/ORGNAME"    
  #   chef.validation_key_path = "ORGNAME-validator.pem"
  # end
  #
  # If you're using the Opscode platform, your validator client is
  # ORGNAME-validator, replacing ORGNAME with your organization name.
  #
  # If you have your own Chef Server, the default validation client name is
  # chef-validator, unless you changed the configuration.
  #
  #   chef.validation_client_name = "ORGNAME-validator"
end

我的服务器没有图形界面如何解决?谢谢。


有没有可能影响防火墙规则?
pbacterio

Answers:


4

首先,尝试:查看您的计算机配置中有哪些无用的私钥

$ vagrant ssh-config

例:

$ vagrant ssh-config
Host default
  HostName 127.0.0.1
  User vagrant
  Port 2222
  UserKnownHostsFile /dev/null
  StrictHostKeyChecking no
  PasswordAuthentication no
  IdentityFile C:/Users/konst/.vagrant.d/insecure_private_key
  IdentitiesOnly yes
  LogLevel FATAL

流浪的SSH配置文件

其次,执行以下操作:用yorn自己的系统私钥的内容 更改文件insecure_private_key的内容



这似乎工作完美!我删除了不安全的密钥,并让Vagrant生成了它自己的新密钥,并且像魅力一样工作
vishal.biyani 2015年

1
您是如何实现的?您编辑了哪个文件?
Cookie Cookie

@cookieC:/Users/USER_NAME/.vagrant.d/insecure_private_key
shilovk '16

@shilovk是什么意思@cookie

2

尝试按照本文中的报告启用虚拟机的GUI Vagrant卡住了连接超时并遵循注释中的步骤。

如果不起作用,请尝试将此修改添加到您的vagrantfile中:

创建一个名为“ script.sh”的文件,其中包含以下命令:

mkdir /home/vagrant/.ssh
wget --no-check-certificate -O authorized_keys 'https://github.com/mitchellh/vagrant/raw/master/keys/vagrant.pub'
mv authorized_keys /home/vagrant/.ssh
chown -R vagrant /home/vagrant/.ssh
chmod -R go-rwsx /home/vagrant/.ssh

然后将其添加到您的vagrantfile中:

  # running script shell
    config.vm.provision :shell, :path => "script.sh"

2

引导阶段的SSH连接超时可能由多种原因引起,例如:

  • 系统等待用户交互(例如,共享分区未准备就绪),
  • sshd 配置错误
  • 防火墙配置错误(如果它不是本地的),
  • 您的私钥不匹配,
  • config.vm.boot_timeout 时间段时间太短(您可以使用),
  • 确保在BIOS中启用了虚拟化。

要调试该问题,请按以下方式运行它:

VAGRANT_LOG=debug vagrant up

如果没有明显的内容,请尝试通过以下方式从另一个终端连接到该终端vagrant ssh

vagrant ssh-config > vagrant-ssh; ssh -F vagrant-ssh default

如果SSH仍然失败,请使用GUI重新运行它(例如config.gui = true)。

如果不是,请检查正在运行的进程(例如:),vagrant ssh -c 'pstree -a'或验证您的sshd_config


如果是一次性的虚拟机,可以随时destroy它和up它一次。还可以考虑升级您的Vagrant和Virtualbox。


1

尝试打开防火墙上的端口22。

使用Oracle VM VirtualBox Manager,直接启动VM或

将此添加到您的Vagrantfile

config.vm.provider :virtualbox do |vb|
  vb.gui = true
end

并“流浪”

使用默认的无业游民凭证登录

user: vagrant
pass: vagrant

添加防火墙规则

sudo ufw allow 22

0

我刚刚解决了类似的问题。

问题:登录来宾开发环境的命令vagrant ssh已超时。通常,它可以在另一台主机上正常工作。

调试步骤:

  1. 在Vagrantfile中,我启用了Virtualbox GUI(根据另一个答案的建议),以查看造成超时的原因。Ubuntu要求输入登录名和密码,这是不应该的,因为它应该使用ssh密钥。

  2. vagrant ssh我没有运行,而是运行了等效的ssh命令很多次,添加和删除了不同的ssh选项。超时错误消息之一显示为“无法登录[example.com]”……这是没有意义的,因为此问题与[example.com]无关。

  3. 因此,这促使我查看了[ssh / config],其中[example.com]可能与之相关。

根本原因:在.ssh / config中Host,偶然有一个未设置的条目。因此,它将那个配置规则应用于所有 ssh调用,包括vagrant ssh(这只是较长的ssh命令的快捷方式)。

解决方案:确保已Host设置每个.ssh / config条目。


0

尝试生成 insecure_private_key

我通过删除insecure_private_key位于下的~/.vagrant.d

也许原因是insecure_private_key文件太旧


0

我有同样的问题。我从SystemPrefereces-> Security-> Firewall中删除了所有内容,并从SystemPreferences-> Shared中删除了所有服务。然后,我再次启用了远程登录。这解决了我的问题。如果这不能解决您的问题,您可以访问此网站并自行检查。(ServerFaqs)


0

我遇到了类似的问题。这是我所做的。

  • 在BIOS中启用虚拟化
  • ssh-add ~/.vagrant.d/insecure_private_key
  • 添加config.vm.boot_timeout = 600到我的~/Homestead/Vagrantfile

现在工作正常。


0

您需要能够使用GUI。在Vagrant文件中删除以下行的注释:

config.vm.provider :virtualbox do |vb|
  vb.gui = true
end

需要关闭计算机并重新启动后:

vagrant halt
vagrant up

0

我如何解决:

在vagrantfile中,启用/取消注释以下内容...

config.vm.network "private_network", ip: "192.168.33.10"
...
config.vm.network "public_network"

0

可能由许多因素引起此问题,包括VM盒挂起以等待用户响应的情况。但是,一个常见的问题是私钥和公钥之间的不匹配。要解决此问题,您需要在主机上提供与VM框中的公钥文件匹配的私钥文件。我在这里的博客上发布了具有3种可选方法的解决方案...

http://www.productiveminds.com/blog/vagrant-ssh-authentication-how-to-successfully-login-into-vm-box-using-vagrant-up/



0

我有同样的问题,这是我第一次与流浪汉接触。

我设法通过使用公共网络而不是专用网络来“解决”该问题

config.vm.network "public_network", ip: "192.168.3.175"

替换192.168.3.175为属于您的网络类别的IP。

我想了解专用网络到底有什么问题...


它还没有工作。= /
PoLIVoX

然后确保您拥有最新版本的vagrant和virtualbox(从网站上下载软件包)
damko 2014年

顺便说一句,由于某些自定义设置(例如“〜/ .bashrc”)以及我的Mint 15框中存在“ / etc / SuSE-release”(由其他软件要求),我在安装过程中遇到了一些问题。但是,在我所做的所有更改中,我真正相信,解决该问题的方法是安装最新软件包
damko 2014年

我更新了服务器,但无法正常工作!= /
PoLIVoX'4

我没有使用发行版提供的软件包。我从其官方网站(vagrant和virtualbox)
damko 2014年

0

config.vm.boot_timeout-Vagrant等待机器启动并可以访问的时间(以秒为单位)。默认情况下,这是300秒。

我会增加它,直到您能够使用SSH。


我尝试了,但没有成功。= /我将超时时间设置为600
PoLIVoX 2014年

您可以发布您的Vagrantfile吗?
dmourati 2014年

我发布了Vagrantfile。
PoLIVoX 2014年
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.