【问题标题】:vagrant ssh does not connect to vm on windows 10vagrant ssh 无法连接到 Windows 10 上的 vm
【发布时间】:2019-07-09 12:13:12
【问题描述】:

[编辑] 我卸载了 vagrant 和 virtualbox。我有 virtualbox 版本 5.0 和最新版本的 vagrant,现在我有两者的最新版本(virtual box 6.0.1),我尝试了相同的常规步骤,但出现了相同的不想要的输出。

vagrant 在 Windows 10 上无法连接到 *vm** 我的 vagrant ssh 输出:“VM 必须正在运行才能打开 SSH 连接。运行vagrant up\n启动虚拟机。”

我在搜索引擎上发现 vm for windows 10 有问题,这里是官方的 调试页面https://github.com/hashicorp/vagrant/issues/9027 我试过了,但对我不起作用。

但是,这些可能对其他人有用:
1- $vagrant --debug ssh
不需要的输出:检查screenshot 最后一行是:INFO interface: Machine: error-exit ["Vagrant::Errors::VMNotRunningError", "VM must be running to open SSH connection. Run vagrant up\nto start the virtual machine."]

2- $vagrant up; vagrant ssh
不需要的输出:“VM 必须正在运行才能打开 SSH 连接。运行 vagrant up\n启动虚拟机。”

3- $vagrant provision
不需要的输出:==> 默认值:VM 当前未运行。请先用vagrant up 调出它,然后运行这个命令。

4- 我按照这里提到的步骤https://kb.vmware.com/s/article/1007131 并重新启动电脑,然后再次运行 vagrant ssh,
不需要的输出:VM 必须正在运行才能打开 SSH 连接。运行vagrant up 启动虚拟机。

也试过了:vagrant up; vagrant ssh(以防万一还有其他问题,例如超时?)
不需要的输出:VM 必须正在运行才能打开 SSH 连接。运行vagrant up 启动虚拟机。

5-终于
一个-vagrant destroy
B-vagrant up
C-vagrant ssh
不需要的输出:必须在运行此命令之前创建 VM。先运行vagrant up

我希望输出是 vagrant 和 vm 之间的成功连接。 喜欢这个输出 this output 由 Carl 完成

我的流浪档案:

# -*- mode: ruby -*-
# vi: set ft=ruby :

# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure("2") do |config|
  # The most common configuration options are documented and commented below.
  # For a complete reference, please see the online documentation at
  # https://docs.vagrantup.com.

  # Every Vagrant development environment requires a box. You can search for
  # boxes at https://vagrantcloud.com/search.
  config.vm.box = "hashicorp/precise64"

  # Disable automatic box update checking. If you disable this, then
  # boxes will only be checked for updates when the user runs
  # `vagrant box outdated`. This is not recommended.
  # config.vm.box_check_update = false

  # 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.
  # NOTE: This will enable public access to the opened port
  # config.vm.network "forwarded_port", guest: 80, host: 8080

  # Create a forwarded port mapping which allows access to a specific port
  # within the machine from a port on the host machine and only allow access
  # via 127.0.0.1 to disable public access
  # config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1"

  # 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"

  # 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"

  # Provider-specific configuration so you can fine-tune various
  # backing providers for Vagrant. These expose provider-specific options.
  # Example for VirtualBox:
  #
  # config.vm.provider "virtualbox" do |vb|
  #   # Display the VirtualBox GUI when booting the machine
  #   vb.gui = true
  #
  #   # Customize the amount of memory on the VM:
  #   vb.memory = "1024"
  # end
  #
  # View the documentation for the provider you are using for more
  # information on available options.

  # Enable provisioning with a shell script. Additional provisioners such as
  # Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the
  # documentation for more information about their specific syntax and use.
  # config.vm.provision "shell", inline: <<-SHELL
  #   apt-get update
  #   apt-get install -y apache2
  # SHELL
end

【问题讨论】:

  • 你的 vagrant 文件的内容是什么?
  • 我将它包含在问题正文中@AndreiLupuleasa
  • 这是一个 VirtualBox 错误,它不是 Vagrant 特有的。另请参阅VirtualBox machine starts, but not running(尽管这是针对 Linux 的)。

标签: database shell vagrant virtual-machine git-bash


【解决方案1】:

我刚刚找到了一个临时解决方案:

我在运行命令vagrant upvagrant ssh 时打开了virtualbox 应用程序 我不知道这是否是完美的解决方案,但是当我完成任务并重新启动机器并发现一切正常时,我会更新这个答案。

vagrant ssh 输出:

欢迎使用 Vagrant 构建的虚拟机。最后登录时间:9 月 14 日星期五 2012 年 06:23:18 来自 10.0.2.2 vagrant@precise64:~$

查看以下 3 个正在运行的应用

【讨论】: