Vagrant Vagrantfile配置

时间:2018-05-17 12:36:34

标签: vagrant virtualbox vagrantfile vagrant-windows

我有这个用于框的游戏文件" 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 - 命令工作正常,但提供的脚本不能安装 在我尝试启动 vagrant provision 之后,却出现了错误:

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.

我如何解决此问题并安装所有条款?

1 个答案:

答案 0 :(得分:1)

问题是由于您的vagrantfile中的以下行

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

流浪者用户的authorized_keys文件位于流浪汉机器内的/home/vagrant/.ssh中,可以进入流浪盒。

当您将当前目录挂载到/ home / vagrant时,/ home / vagrant的所有内容都被覆盖,并且没有授权的密钥文件。

将挂载路径更改为除/ home / vagrant之外的任何内容,您就可以将ssh插入到计算机中。例如

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