Laravel Vagrant Up SSH Problems - laravel

I am trying to create a Laravel App with the help of homestead vagrant. I am using a Windows 7 development environment. I'm using the Per Project Installation and I'm at the point in the Laravel Documentation that I can vagrant up my project. When I do vagrant up in my project I get hung up on
SSH auth method: password
and I get the following message:
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.
I am using Laravel 5.3 and Vagrant 1.9.0. I was using Vagrant 1.8.4, but once I started having trouble I installed Vagrant 1.9.0, but received the exact same error. I tried te following fix from here, and from the vb.gui I could see the following error from the launched server:
[ 0.100000] Failed to access perfctr msr (MSR c0010007 is 0)
lvmetad is not active yet, using direct activation during sysinit
lvmetad is not active yet, using direct activation during sysinit
Scanning for Btrfs filesystems
/dev/mapper/vagrant--vg-root:clean, 127066/2559088 files, 1241443/10228736 blocks
[ 10.420196] piix4_smbus 0000:00:07.0: SMBus base address uninitialized - updrade BIOS or use force_addr=0xadr
[ ] A start jon is running for Raise network interfaces (4 min 44s / 5min 5 s)
and then the server start and I can log in, but my folders and IP from my Homestead.yaml file are not set on the server.
This is my Homestead.yaml file:
---
ip: "192.168.10.10"
memory: 2048
cpus: 1
hostname: mysite
name: mysite
provider: virtualbox
authorize: C:/Users/xxx/.ssh/id_rsa.pub
keys:
- C:/Users/xxx/.ssh/id_rsa
folders:
- map: "C:/Users/xxx/www/mysite"
to: "/home/vagrant/mysite"
sites:
- map: homestead.app
to: "/home/vagrant/mysite/public"
databases:
- homestead
While the instance is running and I run:
vagrant ssh-config
I get
Host mysite
HostName 127.0.0.1
User vagrant
Port 2222
UserKnownHostsFile /dev/null
StrictHostKeyChecking no
PasswordAuthentication no
IdentitiesOnly yes
LogLevel FATAL
ForwardAgent yes
when I run:
vagrant global-status
I get:
id name provider state directory
-----------------------------------------------------------------------
66eb5bf mysite virtualbox running C:/Users/xxx/www/mysite
When I try and get the degub info from vagrant by using this:
vagrant up --debug > vdebug.txt
generates a lot of messages in the command prompt but only this in the vdebug.txt file:
Bringing machine 'mysite' up with 'virtualbox' provider...
==> mysite: Importing base box 'laravel/homestead'...
[KProgress: 20%
[KProgress: 30%
[KProgress: 60%
[KProgress: 70%
[KProgress: 90%
[K==> mysite: Matching MAC address for NAT networking...
==> mysite: Checking if box 'laravel/homestead' is up to date...
==> mysite: Setting the name of the VM: mysite
==> mysite: Clearing any previously set network interfaces...
==> mysite: Preparing network interfaces based on configuration...
mysite: Adapter 1: nat
mysite: Adapter 2: hostonly
==> mysite: Forwarding ports...
mysite: 80 (guest) => 8000 (host) (adapter 1)
mysite: 443 (guest) => 44300 (host) (adapter 1)
mysite: 3306 (guest) => 33060 (host) (adapter 1)
mysite: 5432 (guest) => 54320 (host) (adapter 1)
mysite: 22 (guest) => 2222 (host) (adapter 1)
==> mysite: Running 'pre-boot' VM customizations...
==> mysite: Booting VM...
==> mysite: Waiting for machine to boot. This may take a few minutes...
mysite: SSH address: 127.0.0.1:2222
mysite: SSH username: vagrant
mysite: SSH auth method: password
If you made it to the end of this post thank you! My questions is how do I get my IP and Folders from my Homestead.yaml file to the server. Any help would be greatly appreciated. Also Let me know if I can add any more info. I will keep you updated on my status.
EDIT 1
I forgot to add that I enabled virtualization already.
EDIT 2
I changed the Homestead.yaml file in my projects folder to have the IP set to 192.168.10.20 instead of 192.168.10.10 and still no changes. I will keep updating till I have an answer.
EDIT 3
Tried to change the Vagrantfile located in my project folder to add the following in the Vagrant.configure function:
config.vm.network "public_network", ip: "192.168.10.20", :bridge => "en1: Realtek PCIe GBE Family Controller #2"
I received the same error, but I also received this:
Specific bridge 'en1: Realtek PCIe GBE Family Controller #2' not found. You may be asked to specify
which network to bridge to.

This error occurs because the Ubuntu tries to raise all your network interfaces, but your cable isn't connected, then it waits until this timeout.
It seems that this problem occurs when you export a VM, more info on https://www.virtualbox.org/ticket/15705
You can edit your Vagrantfile and add these lines in the end of Vagrant.configure loop:
config.vm.provider "virtualbox" do |vb|
vb.customize ["modifyvm", :id, "--cableconnected1", "on"]
end
Basically add this right before the very last "end".

I did have the same error in the past it was because the virtualization in my machine wasn't enabled.
Try to enable it in your machine. To do it you need to get into the BIOS.
There are useful information at Vagrant stuck connection timeout retrying as well.

[ ] A start jon is running for Raise network interfaces (4 min 44s / 5min 5 s)
https://askubuntu.com/a/841432
That link shows how to reduce the timeout for the DHCP client from 5 minutes to 15 seconds. I logged in via VirtualBox to do it. That worked for me.

Related

homestead didn't wants to start normaly

I updated Virtualbox to 6.0.2 and Vagrant into 2.2.3 in MacOSX Siera. Also remove old laravel/homestead folder and download new one v8.0.2. But when install virtualbox and vagrant on my MacOSX and run vagrant up it make new ssh keys and move it into new virtual box machine. First indicator that I saw is that he forward only 22 port into virtual machine and make it in some strange name(previous naming is like homestead-7), and last time is homestead_default_1549352737068_70025. Here is list of logs that I get from console:
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'laravel/homestead'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'laravel/homestead' version '7.0.0' is up to date...
==> default: Setting the name of the VM: homestead_default_1549352737068_70025
==> 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: 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:
default: Vagrant insecure key detected. Vagrant will automatically replace
default: this with a newly generated keypair for better security.
default:
default: Inserting generated public key within guest...
default: Removing insecure key from the guest if it's present...
default: Key inserted! Disconnecting and reconnecting using new SSH key...
==> default: Machine booted and ready!
Next problem that I see when ssh to it that it didn't have project folder with sub-folders that defined in Homestead.yaml file also it didn't have mysql connection also apache/nginx didn't belongs there(my web sites didn't wants to start). Here is my Homestead.yaml snippet:
ip: "192.168.10.10"
memory: 2048
cpus: 1
provider: virtualbox
authorize: ~/.ssh/id_rsa.pub
keys:
- ~/.ssh/id_rsa
folders:
- map: ~/developing/projects
to: /home/vagrant/projects
sites:
- map: project_test.test
to: /home/vagrant/projects/project_test/public
- map: project_test2.test
to: /home/vagrant/projects/project_test2/public
databases:
- project_test
- project_test2
I try multiple times vagrant destroy && vagrant up --provision but it didn't helps me. Can anybody help me what to do next?Any idea?
After uninstall all(Vagrant and Virtualbox) and install new version. It's partially works. I can ssh to it, it works mysql connect when set ip to be 127.0.0.1 (didn't bind to be "192.168.10.10" from Homestead file) but still can't access to any of my websites over my browser :(
Try adding your sites to your local /etc/hosts file.
192.168.10.10 project_test.test
192.168.10.10 project_test2.test

Configuring Homestead error

When I use vagrant up command I have this error message:
Bringing machine 'name' up with 'parallels' provider...
==> name: Checking if box 'laravel/homestead' is up to date...
==> name: Clearing any previously set forwarded ports...
==> name: Preparing network interfaces based on configuration...
name: Adapter 0: shared
name: Adapter 1: hostonly
==> name: Clearing any previously set network interfaces...
==> name: Forwarding ports...
name: 80 => 8000
name: 443 => 44300
name: 3306 => 33060
name: 5432 => 54320
name: 8025 => 8025
name: 27017 => 27017
==> name: Running 'pre-boot' VM customizations...
==> name: Booting VM...
==> name: Waiting for machine to boot. This may take a few minutes...
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.
On Parallels the VM is created and when I launch I arrive to login page.
I'm using PhpStorm on Mac and followed this tutorial: http://www.pascallandau.com/blog/laravel-with-phpunit-on-vagrant-in-phpstorm/
How can I fix the issue?

vagrant up fails for bento/ubuntu-16.04 on Oracle VirtualBox 5.0.16 r105871

Today I was planning to get the latest Ubuntu release into my virtual box using vagrant. After loading the image and running vagrant up, I got an error as reported below, which relates to the network configuration of the virtual box.
Interestingly, there are already some posts online (mainly on GitHub, e.g.: https://github.com/mitchellh/vagrant/issues/7155), but also on AskUbuntu (https://askubuntu.com/questions/760871/network-settings-fail-for-ubuntu-xenial64-vagrant-box), StackOverflow (vagrant up command giving error and eth1 not showing a resolvable ip address) and StackExchange (https://unix.stackexchange.com/questions/188413/not-able-to-resolve-ip-address-for-eth1-in-vagrant-vm). However these issues relate to either xenial64 (i.e. not bento) or use a public_network configuration.
As reported in https://askubuntu.com/questions/760871/network-settings-fail-for-ubuntu-xenial64-vagrant-box, this issue does not exist for ubuntu/trusty64 or ubuntu/wily64, but seems to be an issue for both ubuntu/xenial64 and bento/ubuntu-16.04 (i.e. both Ubuntu 16 boxes).
As you will see in my Vagrantfile below, I have a simple setup for bento/ubuntu-16.04 and use private_network only. To be clear, I can't really use this post (vagrant up command giving error and eth1 not showing a resolvable ip address) since it suggests to comment out the public_network part of the vagrant configuration. Also, I should mention that there are no other VM's running at the time this error occurs.
From the error log it seems obvious that there is an issue with the netowrk interface eth1, but what exactly the problem is, is unclear to me. I have previously successfully started the hashicorp/precise32 and ubuntu/trusty64 Ubuntu boxes with the same vagrant configuration and the same Oracle VB and have not encountered this problem.
Any help is appreciated. My technical setup and reference files are listed below.
Cheers
AHL
Setup:
Vagrant: v1.8.1
Oracle VirtualBox: v5.0.16 r105871
Ubuntu box: bento/ubuntu-16.04 (https://atlas.hashicorp.com/bento/boxes/ubuntu-16.04)
Host machine: Lenovo X1 Carbon, Windows 10
Vagrantfile:
Vagrant.configure(2) do |config|
config.vm.box = "bento/ubuntu-16.04"
config.vm.network "private_network", ip: "192.168.33.10"
end
Output:
C:\Users\AHL\workspace>vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'bento/ubuntu-16.04' is up to date...
==> 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: Adapter 2: hostonly
==> default: Forwarding ports...
default: 22 (guest) => 2222 (host) (adapter 1)
==> 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: Machine booted and ready!
GuestAdditions 5.0.16 running --- OK.
==> default: Checking for guest additions in VM...
==> default: Configuring and enabling network interfaces...
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!
/sbin/ifdown eth1 2> /dev/null
Stdout from the command:
Stderr from the command:
mesg: ttyname failed: Inappropriate ioctl for device
C:\Users\AHL\workspace>
I had the problem and found that for some reason, the virtual box did not connect the virtual cable to the network interface.
I solved it by adding
vb.customize ["modifyvm", :id, "--cableconnected1", "on"]
to my config.vm.provider "virtualbox" do |vb| loop, for example in my case I wanted 1GB RAM, USB3 and the network cable connected:
config.vm.provider "virtualbox" do |vb|
vb.memory = "1024"
vb.customize ["modifyvm", :id, "--usbxhci", "on"] # Connect USB3 disk
vb.customize ["modifyvm", :id, "--cableconnected1", "on"]
end
I did not need this --cableconnected1 line in any other boxes I have used, only in config.vm.box = "bento/ubuntu-16.04".
Maybe you have to check if doing vagrant updoes not connect any of your cables, I had also an extra network and eth0 was unwired and eth1 was wired.
Check your particular case. Maybe you have to play with the number after the option.
Hope this helps!
I think in your list, you need to add https://github.com/mitchellh/vagrant/issues/6871
The issue is still open - There are some users who reported they could fix the issue (https://github.com/mitchellh/vagrant/issues/6871#issuecomment-223290622 or https://github.com/mitchellh/vagrant/issues/6871#issuecomment-222348226)
If you can build your box yourself using packer, there are some fixes on the network issue.

Laravel homestead and vagrant setup not working

I followed the original documentation for vagrant and homestead but every site.app:8000 you visit it just keeps loading and nothing happens. Is there an error within this configuration files?
Homestead.yaml
ip: "192.168.10.10"
memory: 2048
cpus: 1
provider: virtualbox
authorize: ~/.ssh/id_rsa.pub
keys:
- ~/.ssh/id_rsa
folders:
- map: ~/Developer/laravel
to: /home/vagrant/laravel
sites:
- map: hello-world.local
to: /home/vagrant/laravel/hello-world/public
databases:
- homestead
hosts
192.168.10.10 hello-world.local
vagrant up log
Bringing machine 'default' up with 'virtualbox' provider...
==> 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: Adapter 2: hostonly
==> default: Forwarding ports...
default: 80 (guest) => 8000 (host) (adapter 1)
default: 443 (guest) => 44300 (host) (adapter 1)
default: 3306 (guest) => 33060 (host) (adapter 1)
default: 5432 (guest) => 54320 (host) (adapter 1)
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: Machine booted and ready!
==> default: Checking for guest additions in VM...
default: The guest additions on this VM do not match the installed version of
default: VirtualBox! In most cases this is fine, but in rare cases it can
default: prevent things such as shared folders from working properly. If you see
default: shared folder errors, please make sure the guest additions within the
default: virtual machine match the version of VirtualBox you have installed on
default: your host and reload your VM.
default:
default: Guest Additions Version: 5.0.20
default: VirtualBox Version: 5.1
==> default: Setting hostname...
==> default: Configuring and enabling network interfaces...
==> default: Mounting shared folders...
default: /vagrant => /Users/nikla/Developer/homestead
default: /home/vagrant/laravel => /Users/nikla/Developer/laravel
==> default: Machine already provisioned. Run `vagrant provision` or use the `--provision`
==> default: flag to force provisioning. Provisioners marked to run always will still run.
nmap log
Starting Nmap 7.12 ( https://nmap.org ) at 2016-07-29 22:55 ART
Nmap scan report for 192.168.10.10
Host is up (0.00063s latency).
Not shown: 994 closed ports
PORT STATE SERVICE
22/tcp open ssh
80/tcp open http
443/tcp open https
3306/tcp open mysql
5432/tcp open postgresql
9000/tcp open cslistener
Nmap done: 1 IP address (1 host up) scanned in 13.19 seconds
I have check your "vagrant up" log and I see all things ok. I have compared your log with my machine's log and is similar.
Try to open the IP in the web browser (change the IP with your Vagrant VM IP):
http://192.168.10.10/
Do you have some firewall, antivirus or another software that could disable the communication?
Try to execute a nmap to see wich ports are open. I paste my nmap, from my host machine to my virtual machine, so you can see wich ports are open.
$ nmap 192.168.10.10
Starting Nmap 6.47 ( http://nmap.org ) at 2016-07-30 01:48 Hora de verano romance
Nmap scan report for homestead.app (192.168.10.10)
mass_dns: warning: Unable to determine any DNS servers. Reverse DNS is disabled. Try using --system-dns or specify valid servers with --dns-servers
Host is up (0.0019s latency).
Not shown: 993 closed ports
PORT STATE SERVICE
22/tcp open ssh
80/tcp open http
111/tcp open rpcbind
443/tcp open https
3306/tcp open mysql
5432/tcp open postgresql
9000/tcp open cslistener
MAC Address: 08:00:27:CD:99:8C (Cadmus Computer Systems)
Nmap done: 1 IP address (1 host up) scanned in 21.83 seconds
Check:
The id_rsa.pub and the id_rsa are in this folder.
The /Users/nikla/Developer/laravel folder exists in your host machine.
The /home/vagrant/laravel exists in your Vagrant VM machine. You can check it login in the machine using the command "vagrant ssh".
Try to access to the http://test.app without the 8000 port.
I don't see the database in your Homestead.yaml file. You should have the next text in this file
databases:
- homestead

Vagrant can't assign static ip to box

I have the following inside my Vagrant file.
config.vm.network "private_network", ip: "192.168.33.12"
When I "vagrant up", vagrant is assigning 127.0.0.1. I'm not sure what's causing this. Below is the full trace.
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Clearing any previously set forwarded ports...
==> default: Fixed port collision for 22 => 2222. Now on port 2200.
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
default: Adapter 2: hostonly
==> default: Forwarding ports...
default: 22 (guest) => 2200 (host) (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:2200
default: SSH username: vagrant
default: SSH auth method: private key
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
==> default: Configuring and enabling network interfaces...
==> default: Mounting shared folders...
default: /vagrant => C:/vm2
==> default: Machine already provisioned. Run `vagrant provision` or use the `--provision`
==> default: flag to force provisioning. Provisioners marked to run always will still run.
what you see here
default: SSH address: 127.0.0.1:2200
is not your VM IP address - this is just for vagrant to ssh into the box using an available port (in your case 2200). vagrant configures on your VM the eth0 interface to communicate with the host
Login to the VM and run ifconfig you will see you have (at least) 2 interfaces available with eth0 on 10.0.2.15 and eth1 on 192.168.33.12
As a shorthand way of doing this, a oneliner you can run from the host to see assigned IPs on the guest:
$ vagrant ssh -c "ifconfig | grep 'inet addr'"
Which will give you an output like this:
inet addr:10.0.2.15 Bcast:10.0.2.255 Mask:255.255.255.0
inet addr:192.168.200.200 Bcast:192.168.200.255 Mask:255.255.255.0
inet addr:127.0.0.1 Mask:255.0.0.0
Here are the steps that i choose while setting up the static ip of the Ubuntu machine:
ls /etc/netplan/ //go to this directory to find the config file
Note: the YAML file is very strict about the indentations e.g
dhcp4:true //will give wrong indentation error
dhcp4: true //right way to give
Now edit the config file:-
sudo nano /etc/netplan/01-netcfg.yaml
Change Default settings from :-
network:
version: 2
renderer: networkd
eth0:
dhcp4: true
dhcp6: false
optional: true
nameservers:
addresses: [8.8.8.8,8.8.4.4]
To
network:
version: 2
renderer: networkd
ethernets:
eth0:
dhcp4: no
addresses: [172.28.32.11/16] //here choose your desired IP
gateway4: 172.28.32.1 //provide the gateway address,
nameservers:
addresses: [8.8.8.8,8.8.4.4]
Now do :
sudo netplan apply // to apply the network settings
You can then check that the ip address remains same during any course between vagrant halt/up
Here is what i did for the virtual box set machine of vagrant:
Add this to to vagrant file :-
config.vm.network "private_network", ip: "any IP address that you choose"
Then do the Vagrant Reload and you should be good.
In case the VM stucks for Vagrant Up command in retrying the connect or ssh .. do this:-
Run the below command from the cmder console:-
vagrant plugin install vagrant-vbguest
After this enable Vagrant GUI by adding the following to the vagrant file:-
config.vm.provider :virtualbox do |vb|
vb.gui = true
end
Now do the vagrant up
the vagrant gui window will open and Keep Pressing "S" to skip and enter the login screen
Login with the username/password which is root/vagrant by default
and run the following command:-
sudo ln -s /opt/VBoxGuestAdditions-4.3.10/lib/VBoxGuestAdditions /usr/lib/VBoxGuestAdditions
Now come out of the vagrant gui window shell and
remove the line added earlier for enabling the vagrant gui
from the cmder console do "vagrant up" again
Done!

Resources