使用WSL 2在Vagrant中拒绝连接

使用WSL 2在Vagrant中拒绝连接,vagrant,virtualbox,windows-subsystem-for-linux,vagrant-provision,Vagrant,Virtualbox,Windows Subsystem For Linux,Vagrant Provision,我正在尝试WSL2,也在尝试流浪者。我在Ubuntu20.04中使用了它,它工作正常,但现在我在Windows10的WSL2中遇到了问题。我的问题可能是关于WSL上的SSH问题,似乎127.0.0.1:222无法连接到虚拟机中的映像。如果我的理解有误,请纠正我 涉及的技术版本 Windows 10版本19042.630 WSL和Windows 10内部的Vagrant版本2.2.14 WSL2-Ubuntu20.04 仅在Windows 10主机中使用Virtual Box 6.1 流浪汉档

我正在尝试WSL2,也在尝试流浪者。我在Ubuntu20.04中使用了它,它工作正常,但现在我在Windows10的WSL2中遇到了问题。我的问题可能是关于WSL上的SSH问题,似乎127.0.0.1:222无法连接到虚拟机中的映像。如果我的理解有误,请纠正我

涉及的技术版本

  • Windows 10版本19042.630
  • WSL和Windows 10内部的Vagrant版本2.2.14
  • WSL2-Ubuntu20.04
  • 仅在Windows 10主机中使用Virtual Box 6.1
流浪汉档案

Vagrant.configure(“2”)do | config|
config.vm.box=“基本”
config.ssh.username=“vagrant”
config.ssh.password=“vagrant”
config.vm.define“laravel_特使”do | laravel_特使|
laravel_emission.vm.hostname=“192.168.12.12”
laravel_emission.vm.box=“bento/ubuntu-18.04”
laravel_特使.vm.network:专用_网络,ip:“192.168.12.12”
laravel|u emission.vm.provider“virtualbox”do | bionicv|
生物记忆=4096
bionicv.CPU=4
bionicv.customize[“modifyvm”,:id,“--uartmode1”,“disconnected”]
结束
laravel_emission.vm.synced_文件夹“/mnt/c/Users/jjjmigz-win10/Code/gcp home”,“/home/vagrant/Code/gcp home”
结束
config.vm.network“forwarded_port”,guest:8992,host:8991,host_ip:“127.0.0.1”
结束
错误原始文本

jmigzwsl@jmigzw10:/mnt/c/Users/jjmigz-win10/Code/laravel\u gitlab\u ci\u cd\u与特使$vagrant up

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配置

export VAGRANT\u WSL\u ENABLE\u WINDOWS\u ACCESS=“1”
export PATH=“$PATH:/mnt/c/Program Files/Oracle/VirtualBox”
export VAGRANT_WSL_WINDOWS_ACCESS_USER_HOME_PATH=“/mnt/c/Users/jjjmigz-win10/Code/laravel_gitlab_ci_cd_与特使”
我尝试的

  • 我试图将我的主机ip:“127.0.0.1”更改为我的Vagrant文件,但仍然出现错误,而且我无法在internet上使用WSL2找到类似此问题的真正解决方案

  • 我试图将此
    config.vm.boot\u timeout
    添加到
    Vagrantfile
    中,但仍然出现错误

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

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


    • 一点猴子补丁,给你。 只需安装插件
      vagrant plugin install virtualbox_WSL2
      vagrant ssh
      即可从WSL2开始工作


      源代码:

      嗨,我也面临同样的问题。您找到解决方案了吗?是否已在ubunntu上安装openssh服务器并使其在启动时运行?systemctl是否启用openssh@Wirabakti是的,我已经尝试启动我的ssh,我遵循了这一点,但仍然存在相同的问题。我尝试在主机中使用Hyper-V作为提供程序,它正常工作,下面是我为此创建的视频教程