git clone从配置脚本失败

时间:2017-10-19 17:34:58

标签: git bash vagrant

当Vagrant完成配置Ubuntu时,我有一个脚本可以安装所有依赖项和来自不同存储库的两个项目。但我的git克隆失败了这条消息:

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. 

但是,当我在SSH中使用git clone时,它可以完美运行...我在克隆之前取消了配置文件中的StrictHostKeyChecking

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

为什么git clone在脚本中而不在SSH中失败?我该如何解决我的问题?

编辑:如我所说,我的流浪档案:

# -*- 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

1 个答案:

答案 0 :(得分:0)

因此,您的配置脚本以root身份运行,但您已更新了您的vagrant用户的文件,这在ssh时可以正常工作。

你想要的是以臭名昭着的用户身份运行脚本,你需要privileged option

  

privileged(boolean) - 指定是否执行shell脚本   作为特权用户与否(sudo)。默认情况下,这是“true”

编辑您的Vagrant文​​件并更改

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