Victor Tihomirov
Victor Tihomirov

Reputation: 19

Vagrant Vagrantfile config

I have this vagranfile for box "centos/7"

Vagrant.configure("2") do |config|
  config.vm.box = "centos/7"
  config.vm.network :private_network, ip: "192.168.33.10"
  config.vm.synced_folder ".", "/home/vagrant"
  config.vm.provision "shell", path: "./conf/bitrix-env.sh"

  config.vm.boot_timeout = 100


 config.vm.provider :virtualbox do |vb|
   vb.gui = true
   vb.memory = "1024"
 end

end

vagrant up - command works clear, but scripts in provision don't install after i tried to start vagrant provision, but had an error:

SSH is getting permission denied errors when attempting to connect
to the IP for SSH. This is usually caused by network rules and not being
able to connect to the specified IP. Please try changing the IP on
which the guest machine binds to for SSH.

How can i fix this and install all provisions?

Upvotes: 1

Views: 187

Answers (1)

tux
tux

Reputation: 1820

The problem is due to the below line in your vagrantfile

  config.vm.synced_folder '.', '/home/vagrant' 

The authorized_keys file for the vagrant user is located in /home/vagrant/.ssh inside the vagrant machine, which enables to ssh into the vagrant box.

As you are mounting your current directory to /home/vagrant, all the contents of /home/vagrant are over-written and there is no authorized key file.

Change the mount path to anything except /home/vagrant, and you will able to ssh into the machine. As example

  config.vm.synced_folder '.', '/home/vagrant/somepath' 

Upvotes: 1

Related Questions