SSH connection is refused by Vagrant box

544 views
Skip to first unread message

Keith Mills

unread,
Oct 26, 2020, 1:11:53 PM10/26/20
to Vagrant
Hi All,

I have WSL v2 Ubuntu 20.04, Host OS is Windows 10 (Version 2004 (OS Build 19041.572)).  I have setup a Linux Vagrant box (ubuntu/focal64), VirtualBox as the provider, on my machine and mapped port 2222 of my host to 22 of the guest Linux box. I have not added any new interfaces and I am using the default NAT networking. Vagrant up returns error: Warning: Connection refused. Retrying..... I can't ssh into the Vagrant box by ssh vag...@127.0.0.1 -p 2222 from the host machine.

Host OS: Windows 10   (Version 2004 (OS Build 19041.572))

Guest OS: WSL v2 Ubuntu 20.04

VirtualBox: v 6.1

Vagrant: v 2.2.10

Vagrantfile:
Vagrant.configure("2") do |config| 
     config.vm.box = "ubuntu/trusty64"
 


     config.vm.synced_folder ".", "/vagrant", disabled: true
 


     config.vm.provider "virtualbox" do |vb|
 

             vb.memory = "4024"
 

             vb.cpus = "1"
 

     end
 


     config.vm.provision "ansible" do |ansible|
 

             ansible.become = true
 

             ansible.verbose = "v"
 

             ansible.playbook = "roles/firewall.yml"
 

             ansible.galaxy_roles_path = "./roles"


     end

end

keith@LAPTOP:/mnt/c/Users/KeithJames/selinux$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Box 'ubuntu/trusty64' could not be found. Attempting to find and install...
    default: Box Provider: virtualbox
    default: Box Version: >= 0
==> default: Loading metadata for box 'ubuntu/trusty64'
    default: URL: https://vagrantcloud.com/ubuntu/trusty64
==> default: Adding box 'ubuntu/trusty64' (v20190514.0.0) for provider: virtualbox
    default: Downloading: https://vagrantcloud.com/ubuntu/boxes/trusty64/versions/20190514.0.0/providers/virtualbox.box
Download redirected to host: cloud-images.ubuntu.com
==> default: Successfully added box 'ubuntu/trusty64' (v20190514.0.0) for 'virtualbox'!
==> default: Importing base box 'ubuntu/trusty64'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'ubuntu/trusty64' version '20190514.0.0' is up to date...
==> default: Setting the name of the VM: selinux_default_1603730977681_54622
==> 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 (guest) => 2222 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> 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: Warning: Connection refused. Retrying...
    default: Warning: Connection refused. Retrying...
^C==> default: Waiting for cleanup before exiting...
Vagrant exited after cleanup due to external interrupt.

VM shows:
Ubuntu 14.04.6 LTS vagrant-ubuntu-trusty-64 tty1

vagrant-ubuntu-trusty-64 login:

And I can log in successfully!

Firewall / Antivirus turned off.

Hyper-V is not installed.

keith@LAPTOP:/mnt/c/Users/KeithJames/selinux$ sudo netstat -ptaun | grep 'sshd'
[sudo] password for keith:
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      7931/sshd: /usr/sbi
tcp6       0      0 :::22                   :::*                    LISTEN      7931/sshd: /usr/sbi

keith@LAPTOP:/mnt/c/Users/KeithJames/selinux$ sudo netstat -ptaun | grep '22'
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      7931/sshd: /usr/sbi
tcp6       0      0 :::22                   :::*                    LISTEN      7931/sshd: /usr/sbi

keith@LAPTOP:/mnt/c/Users/KeithJames/selinux$ vagrant ssh-config
Host default
  HostName 127.0.0.1
  User vagrant
  Port 2222
  UserKnownHostsFile /dev/null
  StrictHostKeyChecking no
  PasswordAuthentication no
  IdentityFile /mnt/c/Users/KeithJames/.vagrant.d/insecure_private_key
  IdentitiesOnly yes
  LogLevel FATAL

vagrant ssh does nothing and vagrant reload has same error






Reply all
Reply to author
Forward
0 new messages