简体   繁体   中英

git clone fail from config script

When Vagrant is done configuring Ubuntu, I have a script which installs all the dependencies and two projects from different repositories. But my git clone fail with this message :

Cloning into 'frontend'...
Host key verification failed.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists. 

But when I do my git clone in SSH it works perfectly... I desactivated the StrictHostKeyChecking in my config file before the the cloning with :

echo -e "Host *" >> /home/vagrant/.ssh/config
echo -e "\tStrictHostKeyChecking no" >> /home/vagrant/.ssh/config

Why is the git clone failing in a script and not in SSH? How can I solve my problem?

EDIT : as asked, my vagrant file :

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|
  config.vm.box = "bento/ubuntu-17.04"

  config.vm.network "private_network", ip: "192.168.50.5"
  config.vm.synced_folder "./../projects", "/home/vagrant/projects"

  config.vm.provider "virtualbox" do |v|
    v.name = "devOS"
  end

  config.vm.provision "shell", path: "./configure"
end

So your provisioning script is run as root, but you have updated the files for your vagrant user, which will work fine when you ssh.

What you want is to run the script as vagrant user and you need the privileged option

privileged (boolean) - Specifies whether to execute the shell script as a privileged user or not (sudo). By default this is "true"

Edit your Vagrantfile and change

config.vm.provision "shell", path: "./configure", privileged: false

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM