Vagrant错误:连接超时。 重试

我有一个服务器与Ubuntu 12.04,Virtualbox 4.3和Vagrant 1.5.1。 我试图使用这个框http://puppet-vagrant-boxes.puppetlabs.com/centos-64-x64-vbox4210.box然而不当。 当我跑“stream浪”时,我得到这个消息:

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. 

这是我的stream浪文件

 # 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 

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

首先,尝试:看看你的机器configuration中有什么无用的私钥

 $ 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 

stream浪SSHconfiguration文档

二,做:将文件insecure_private_key的内容改为自己系统私钥的内容

尝试启用您的虚拟框的graphics用户界面在这篇文章中stream言卡住连接超时,并按照评论中的步骤报告。

如果它不起作用尝试添加这个修改你的vagrantfile:

创build一个名为“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" 

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

使用Oracle VM VirtualBox Manager,直接启动您的虚拟机或

把这个添加到你的Vagrantfile中

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

并跑“stream浪”

login使用默认vagrant证书

 user: vagrant pass: vagrant 

添加防火墙规则

 sudo ufw allow 22 

引导阶段的SSH连接超时可能由于以下原因而发生:

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

要debugging该问题,请运行它为:

 VAGRANT_LOG=debug vagrant up 

如果没有什么明显的,那么尝试从另一个terminal连接到它,通过vagrant ssh或通过:

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

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

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


如果它是一次性虚拟机,你可以随时destroy它并重新up它。 另外考虑升级你的Vagrant和Virtualbox。

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

问题 :login到guest vagrant ssh开发环境( vagrant ssh的命令超时。 它通常在另一台主机上正常工作。

debugging步骤:

  1. 在Vagrantfile中,我启用了Virtualbox GUI(如另一个答案中推荐的)来查看导致超时的原因。 Ubuntu要求inputlogin名和密码,这不应该是因为它应该使用ssh密钥。

  2. 我没有运行vagrant ssh ,而是多次运行一个等效的ssh命令,添加和删除不同的ssh选项。 其中一个超时错误信息读取为“无法login到[example.com]”…这是毫无意义的,因为这个问题与[example.com]无关。

  3. 所以这促使我看看.ssh / config在哪里[example.com]可能有一些相关性。

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

解决scheme :确保每个.ssh / config条目都设置了Host

尝试生成insecure_private_key

我通过删除位于~/.vagrant.d下的insecure_private_key来解决这个问题

也许原因是insecure_private_key文件是旧的

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

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

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

现在工作正常。

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

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

在您需要closures机器并重新启动之后:

 vagrant halt vagrant up 

我如何修复:

在vagrantfile,启用/取消注释下面…

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

这个问题可能是由许多因素造成的,包括虚拟机挂起等待用户响应的情况。 然而,私钥和公钥之间的不匹配是一个常见的问题。 为了解决这个问题,你需要在你的主机上提供一个与虚拟机上的公钥文件相匹配的私钥文件。 我在我们的博客上发布了一个有3种可选方法的解决scheme。

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

这适用于我:

  1. login:gui通过login/ pass:stream浪/stream浪
  2. 修改/etc/rc.local文件以在exit 0之前包含行sh /etc/init.d/networking restart
  3. 禁用:gui
  4. 无家可归或stream浪者重新加载

https://github.com/mitchellh/vagrant/issues/391#issuecomment-2078383

我有同样的问题,这是我与stream浪汉的第一次经历。

我设法通过使用公共networking而不是私人networking来“解决”问题

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

用属于您的networking类的IPreplace192.168.3.175

我想了解私人networking有什么问题,但…

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

我会增加这个,直到你能够stream浪SSH进入。