首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用WSL 2在Vagrant中拒绝连接

使用WSL 2在Vagrant中拒绝连接
EN

Stack Overflow用户
提问于 2020-11-25 09:10:39
回答 1查看 6.3K关注 0票数 8

我正在尝试WSL 2,在它上也尝试Vagrant。我在Ubuntu20.04中使用了它,它工作正常,但现在我在Windows 10中的WSL 2中遇到了问题。我的问题可能是WSL上的SSH问题,似乎127.0.0.1:222无法连接到虚拟盒中的图像。如果我的理解有误,请纠正我。

技术版本涉及

只在19042.630

  • Vagrant 10主机

中构建

  • Windows 10版本2.2.14和Windows 10
  • WSL 2-Ubuntu20.04
  • 虚拟盒

Vagrant文件

代码语言:javascript
复制
Vagrant.configure("2") do |config|
    config.vm.box = "base"
    config.ssh.username = "vagrant"
    config.ssh.password = "vagrant"
    config.vm.define "laravel_envoy" do |laravel_envoy|
      laravel_envoy.vm.hostname = "192.168.12.12"
      laravel_envoy.vm.box = "bento/ubuntu-18.04"
      laravel_envoy.vm.network :private_network, ip: "192.168.12.12"
      laravel_envoy.vm.provider "virtualbox" do |bionicv|
        bionicv.memory = 4096
        bionicv.cpus = 4
        bionicv.customize ["modifyvm", :id, "--uartmode1", "disconnected"]
      end
      laravel_envoy.vm.synced_folder "/mnt/c/Users/jjmigz-win10/Code/gcp-home","/home/vagrant/Code/gcp-home"
    end

    config.vm.network "forwarded_port", guest: 8992, host: 8991, host_ip: "127.0.0.1"

  end

错误原始文本

jmigzwsl@jmigzw10:/mnt/c/Users/jjmigz-win10/Code/laravel_gitlab_ci_cd_with_envoy$ vagrant up

代码语言:javascript
复制
Bringing machine 'laravel_envoy' up with 'virtualbox' provider...
==> laravel_envoy: Clearing any previously set forwarded ports...
==> laravel_envoy: Clearing any previously set network interfaces...
==> laravel_envoy: Preparing network interfaces based on configuration...
    laravel_envoy: Adapter 1: nat
    laravel_envoy: Adapter 2: hostonly
==> laravel_envoy: Forwarding ports...
    laravel_envoy: 8992 (guest) => 8991 (host) (adapter 1)
    laravel_envoy: 22 (guest) => 2222 (host) (adapter 1)
==> laravel_envoy: Running 'pre-boot' VM customizations...
==> laravel_envoy: Booting VM...
==> laravel_envoy: Waiting for machine to boot. This may take a few minutes...
    laravel_envoy: SSH address: 127.0.0.1:2222
    laravel_envoy: SSH username: vagrant
    laravel_envoy: SSH auth method: password
    laravel_envoy: Warning: Connection refused. Retrying...
    laravel_envoy: Warning: Connection refused. Retrying...
    laravel_envoy: Warning: Connection refused. Retrying...
    laravel_envoy: Warning: Connection refused. Retrying...
    laravel_envoy: Warning: Connection refused. Retrying...
    laravel_envoy: Warning: Connection refused. Retrying...
    laravel_envoy: Warning: Connection refused. Retrying...
    laravel_envoy: Warning: Connection refused. Retrying...
    laravel_envoy: Warning: Connection refused. Retrying...
    laravel_envoy: Warning: Connection refused. Retrying...
    laravel_envoy: Warning: Connection refused. Retrying...
    laravel_envoy: Warning: Connection refused. Retrying...
    laravel_envoy: Warning: Connection refused. Retrying...
    laravel_envoy: Warning: Connection refused. Retrying...
    laravel_envoy: Warning: Connection refused. Retrying...
    laravel_envoy: Warning: Connection refused. Retrying...
    laravel_envoy: Warning: Connection refused. Retrying...
    laravel_envoy: Warning: Connection refused. Retrying...
    laravel_envoy: Warning: Connection refused. Retrying...
    laravel_envoy: Warning: Connection refused. Retrying...
    laravel_envoy: Warning: Connection refused. Retrying...
    laravel_envoy: Warning: Connection refused. Retrying...
    laravel_envoy: Warning: Connection refused. Retrying...
    laravel_envoy: Warning: Connection refused. Retrying...
    laravel_envoy: Warning: Connection refused. Retrying...
    laravel_envoy: Warning: Connection refused. Retrying...
    laravel_envoy: Warning: Connection refused. Retrying...
    laravel_envoy: Warning: Connection refused. Retrying...
    laravel_envoy: Warning: Connection refused. Retrying...
    laravel_envoy: Warning: Connection refused. 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.

~/..bashrc配置

代码语言:javascript
复制
export VAGRANT_WSL_ENABLE_WINDOWS_ACCESS="1"
export PATH="$PATH:/mnt/c/Program Files/Oracle/VirtualBox"
export VAGRANT_WSL_WINDOWS_ACCESS_USER_HOME_PATH="/mnt/c/Users/jjmigz-win10/Code/laravel_gitlab_ci_cd_with_envoy"

我试过什么

  • 我试图将我的host_ip:"127.0.0.1“改为我的Vagrantfile文件,但是我还是遇到了错误,而且我无法在互联网上使用WSL 2找到真正的解决方案。

  • 我试图将这个config.vm.boot_timeout添加到Vagrantfile中,但仍然得到了错误

  • 我试图将这个bionicv.gui = true添加到我的Vagrantfile中,但是仍然得到了错误

相关问题-过时且不使用WSL 2

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-03-12 23:00:57

打点小猴子的补丁给你。只需安装插件vagrant plugin install virtualbox_WSL2vagrant ssh工作从WSL2。

源代码:https://github.com/Karandash8/virtualbox_WSL2

票数 16
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65001570

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档