Search code examples
windows-7sshvirtualboxpuppetvagrant

Why won't Vagrant ssh into my virtual box when I use `Vagrant Up` on Windows 7 command line?


Whenever I try to Vagrant Up it will load the box and do most everything right, but because I'm trying to use Puppet to provision this CentOS 6.3 minimal I need SSH to work during Vagrant Up (if I want it as autonomous as possible).

I get the following information from Vagrant's INFO log:

DEBUG virtualbox_4_2:   - [1, "ssh", 2222, 22]
 INFO ssh: Connecting to SSH: 127.0.0.1:2222
 INFO ssh: SSH not up: #<Timeout::Error: execution expired>
 INFO subprocess: Starting process: ["C:\\Program Files\\Oracle\\VirtualBox\\VBoxManage.exe", "showvminfo", "c2e7375d-159f-4014-9bda-ff9914423f4c", "--machinereadable"]
DEBUG subprocess: Selecting on IO
DEBUG subprocess: stdout: name="Vagrant-Apache-Nick_1360372174"

Solution

  • During Vagrant Up your Windows system tries to connect to SSH. If you type on your command line:

    set VAGRANT_LOG=INFO
    

    You may see it fail and try a couple of times. It looks like this:

    INFO ssh: Connecting to SSH: 127.0.0.1:2222
    

    This is happening because the timeout is set to 10. This can be modified by placing the following in your Vagrantfile:

    config.ssh.timeout = 300
    

    You can use any number you like but I recommend something above 100.

    Sources:

    1. This guy had some useful troubleshooting information.
    2. Vagrant Docs for Vagrantfiles
    3. Vagrant Docs for Vagrantfile SSH Timeout
    4. Vagrant Docs for Debugging
    5. Hours of Troubleshooting (Keep Smilin')