vagrant stalls on 'default: SSH auth method: private key' and then times out [closed] - vagrant

Closed. This question is not about programming or software development. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 days ago.
Improve this question
I have the following vagrantfile:
Vagrant.configure("2") do |config|
config.vm.box ="ubuntu/focal64"
config.vm.network "forwarded_port", guest: 80, host: 8000
config.vm.boot_timeout = 600
config.vm.network "private_network", ip: "192.168.56.11"
config.vm.define "trusty" do |node|
node.vm.hostname = "trusty.local"
node.vm.provision "ansible" do |ansible|
ansible.playbook = "main.yml"
end
end
config.vm.provider "virtualbox" do |vb|
vb.customize ["modifyvm", :id, "--uart1", "0x3F8", "4"]
vb.customize ["modifyvm", :id, "--uartmode1", "file", File::NULL]
vb.customize ["modifyvm", :id, "--cableconnected1", "on"]
vb.customize ["modifyvm", :id, "--vram", "128"]
vb.memory = "4096"
vb.cpus = "2"
end
config.vm.provision "shell", inline: <<-SHELL
apt-get update
SHELL
end
software specs:
windows 11 pro OS build 22000.1455
WSL2
Vagrant 2.3.4
VirtualBox 7.0.2 r154219
I tried many suggestions found in GitHub issues and SOF non worked so far:
BIOS settings enable virtualization features
Hyper-V disabled
Virtual Machine Platform (I disabled it but then obviously wsl won't work so I enabled it again)
Windows Hypervisor Platform (disabled)
installed the VirtualboxWSL2 plugin. for vagrant
increased the memory and cpus of the vb
any other suggestions?

Related

Vagrant host to guest connection slow

I've recently checked out a project that hasn't been touched in 8 months.
On vagrant up-ing I'm finding that any connections made to the guest are ridiculously slow, for example 12 database CRUD operations are taking five minutes to execute against the database on the guest (and it's not the database operations taking the time).
I'm finding though if I ping stackoverflow from both the Windows host and the guest they're returning very similar times back.
Annoyingly there's been quite a few changes since I was last able to get this working due to the previous vagrant box not working. Changes are as follows:
Changing of the actual vagrant box from centos[6.5] to Centos/6
introduction of --natdnshostresolver1 and --natdnsproxy1 (to try fix this problem)
Addition of config.vm.synced_folder ".", "/vagrant", type: "virtualbox" (required or the vagrant up failed)
My vagrantfile is as follows:
Vagrant.configure("2") do |config|
config.vm.box = "centos/6"
config.vm.provider "virtualbox" do |v|
v.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
v.customize ["modifyvm", :id, "--natdnsproxy1", "on"]
end
config.vm.hostname = "DEV"
config.vm.provision "shell" do |s|
s.path = "build.sh"
s.args = ["development"]
end
config.vm.synced_folder ".", "/vagrant", type: "virtualbox"
config.vm.synced_folder "../releases", "/mnt/releases"
config.vm.synced_folder "../sites", "/mnt/releases/sites"
config.vm.synced_folder "../environment/components", "/mnt/components"
config.vm.synced_folder "../environment/scripts", "/mnt/scripts"
config.vm.synced_folder "../core", "/mnt/releases/core"
config.vm.synced_folder "../controller", "/mnt/releases/controller"
config.vm.network :forwarded_port, guest: 80, host: 8000
config.vm.network :forwarded_port, guest: 3306, host: 3306
config.vm.network :forwarded_port, guest: 8080, host: 8080
config.vm.network :forwarded_port, guest: 22000, host: 22000
end
Vagrant version is 1.9.2 (downgraded from 1.9.3 and 1.9.4)
Virtual box version is 5.1.18
So after lots and lots of searching it appears the problem is with VirtualBox rather than Vagrant.
I came across many posts which say adjust the nictype in the vagrant file like such. This is to adjust the virtual networking hardware provided by virtualbox.
config.vm.provider "virtualbox" do |v|
v.customize ["modifyvm", :id, "--nictype1", "82540EM"]
end
Other suggestions were virtio and AMD, this feature and settings can be read in the official documentation here: https://www.virtualbox.org/manual/ch06.html.
However
This barely did anything for me if I'm honest.
After more digging I came across this article How to speed up virtual machines in VirtualBox enormously with a simple tweak which simply put 'switch power plans to boost performance'. I was skeptical, but I run a laptop on powersaver so i'd thought I might as well give it a go. It genuinely solved the problem.

Vagrant /etc/hosts

I've been changing my /etc/hosts file to redirect live urls to my local vagrant box, which worked fine until recently.
I have something like this in my host file
example.be 10.11.10.12
I need to do this because I'm using a third party javascript SDK which is linked to the live domain.
I think this is the most important stuff in the config file:
Vagrant.configure(2) do |config|
# Every Vagrant development environment requires a box. You can search for
# boxes at https://atlas.hashicorp.com/search.
config.vm.box = "bento/debian-7.8"
config.vm.network "forwarded_port", guest: 80, host: 3001
config.vm.network "private_network", ip: "10.11.10.12"
config.ssh.forward_agent = true
config.vm.synced_folder ".", "/vagrant", type: "nfs" # NFS because VirtualBox shared VM is too slow
config.vm.provider "virtualbox" do |vb|
# This all might be a bit excessive, but it'll run ;)
vb.memory = 2048
vb.cpus = 4
# The internet says these changes improve VM performance
vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
vb.customize ["modifyvm", :id, "--natdnsproxy1", "on"]
vb.customize ["modifyvm", :id, "--ioapic", "on"]
end
end
I've found similar questions, but none exactly answer my question. The thing is, it worked before and now it doesn't, that the hardest part for me...
FYI: I'm using OS X Yosemite 10.10.5
Okay, I feel stupid now, it seems I just needed to turn things around in my hosts file...
So I should have:
10.11.10.12 example.be
Strange it worked before, though.
Anyway, back to work. Move along, nothing to see here.

Vagrant memory customization does not work

In my Vagrantfile, I am trying to customize the memory of the VirtualBox VM using the following code snippet. I am using the following box for the VM - http://cloud-images.ubuntu.com/vagrant/trusty/current/trusty-server-cloudimg-amd64-vagrant-disk1.box
Vagrant.configure("1") do |config|
config.vm.customize ["modifyvm", :id, "--memory", 1024]
end
Vagrant.configure("2") do |config|
config.vm.provider "virtualbox" do |v|
v.name = "FJORD_VM"
v.memory = 1024
end
end
But this does not work and the VM starts with the default 512MB RAM. What could be the issue here? I am using the latest 1.7.2 Vagrant. I have also tried using
v.customize ["modifyvm", :id, "--memory", 1024]
in the Vagrant.configure("2") block and still it does not work.
I also intercepted the calls to VBoxManage by creating my local wrapper script that logs the arguments before calling the actual VBoxManage. I see no calls to customize the VM memory.
I second what #ydaetskcoR says about removing the 1.0 section - not only might it confuse Vagrant but it seems redundant. I am using the same box as you and it's working just fine for me:
config.vm.provider "virtualbox" do |v|
v.memory = 1024
v.cpus = 2
v.customize [ :guestproperty, :set, :id, "/VirtualBox/GuestAdd/VBoxService/--timesync-set-threshold", 10000 ]
end
I am also using Vagrant 1.7.2 and Virtualbox 4.3.16, and as I said, it's working fine for me.
As you can use Vagrant 1.7.2 you just need Vagrant.configure("2"), as here
So, you can use:
Vagrant.configure("2") do |config|
config.vm.provider :virtualbox do |v|
v.customize ["modifyvm", :id, "--memory", "1024"]
v.customize ["modifyvm", :id, "--name", "FJORD_VM"]
end
end

How to enable internet access inside Vagrant?

If I run curl google.com, I can't see the output, only a blank page. My Vagrantfile contains:
Vagrant.configure("2") do |config|
config.vm.box = "trumobi"
#config.vm.box_url = "http://192.168.136.129/package.box"
config.ssh.default.username = "trumobi"
config.vm.network :public_network
config.vm.network :forwarded_port, host: 8000, guest: 8000
end
If you are using Vagrant + VirtualBox + Ubuntu, you might want to add the following block to your VagrantFile:
config.vm.provider "virtualbox" do |v|
v.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
v.customize ["modifyvm", :id, "--natdnsproxy1", "on"]
end
If you are using ubuntu, and you think your firewall is on, here's how you turn off the firewall:
sudo ufw disable
This happens sometimes for me if I switch the host network connection, like disconnecting my laptop Ethernet cable and start using the wireless network.
I found that rebooting the Vagrant vm (vagrant halt, vagrant up) fixes things.
Disabling firewall helped me.
In my CentOS guest box I did:
# sudo service iptables save
# sudo service iptables stop
# sudo chkconfig iptables off
I tried all of the above without success (Vagrant+Virtualbox+Ubuntu 14.04). Virtualbox was showing 'Adapter 1 (NAT): cable disconnected'. Adding the following to my Vagrantfile fixed it:
config.vm.provider 'virtualbox' do |vb|
vb.customize ['modifyvm', :id, '--cableconnected1', 'on']
end
Found here: https://github.com/mitchellh/vagrant/issues/7648

How can I create a VM in Vagrant with VirtualBox with two CPUs?

On Windows 7 64 bit trying to start up a VM (Ubuntu 32 bit). I'm having trouble getting my VM to show two cores despite adding the modify vm command in my Vagrantfile. My Vagrant version is 1.2.2.
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "precise32"
config.vm.box_url = "http://files.vagrantup.com/precise32.box"
config.vm.provider :virtualbox do |vb|
vb.customize ["modifyvm", :id, "--memory", "2048"]
vb.customize ["modifyvm", :id, "--cpus", "2"]
end
end
With this Vagrantfile I issue the vagrant up command. Then I issue vagrant ssh followed by lscpu which yields:
Architecture: i686
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 1
On-line CPU(s) list: 0
Thread(s) per core: 1
Core(s) per socket: 1
Socket(s): 1
Vendor ID: GenuineIntel
CPU family: 6
Model: 58
Stepping: 9
CPU MHz: 2565.513
BogoMIPS: 5131.02
L1d cache: 32K
L1d cache: 32K
L2d cache: 6144K
I think CPU(s) should show 2, so my VM only has one CPU right now. How can I get 2 CPUs to show up when I run lscpu?
Add vb.customize ["modifyvm", :id, "--ioapic", "on"] to the config.vm.provider block inside your Vagrantfile.
Looking at the VirtualBox documentation it mentions:
"Note Enabling the I/O APIC is required for 64-bit guest operating
systems, especially Windows Vista; it is also required if you want to
use more than one virtual CPU in a virtual machine."
If you are running vagrant using Oracle Virtualbox then the most common issue is with Hyper-V in Windows 7, 8 or 10. That will limit you to 32bit and one cpu.
Run or search for "Windows Features" and select "Turn Windows Features On or Off".
In the checkboxes make sure Hyper-V is off - you can't enable VT-x for Virtualbox with Microsoft Hyper-V hogging it.
Then, you can make your Vagrantfile boot very user friendly with:
config.vm.provider "virtualbox" do |vb|
vb.memory = "2404"
vb.cpus = "2"
end
Assuming you want to have two cores running and just a bit over 2 Gig of memory
ps - don't forget to add your port forwarding. For PHPStorm (xdebug, mysql, and web) I use:
config.vm.network "forwarded_port", guest: 80, host: 8080
config.vm.network "forwarded_port", guest: 3306, host: 3306
config.vm.network "forwarded_port", guest: 9000, host: 9000
It seems you have not mentioned which provider you are using. As of Vagrant 1.7 many VM providers (such as VirtualBox, HyperV) supports the following configuration in your Vagrantfile:
config.vm.provider "virtualbox" do |v|
v.memory = 1024
v.cpus = 2
end
Check out the specific provider you are using in the vagrant documentation.

Resources