简体   繁体   English

git clone从配置脚本失败

[英]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. 当Vagrant完成配置Ubuntu时,我有一个脚本可以安装所有依赖项以及来自不同存储库的两个项目。 But my git clone fail with this message : 但是我的git clone失败并显示以下消息:

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 : 但是,当我在SSH中执行git clone ,它可以正常工作...在克隆之前,我在配置文件中StrictHostKeyCheckingStrictHostKeyChecking

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? 为什么git clone在脚本中失败而不在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. 因此,您的配置脚本以root身份运行,但是您已经为流浪用户更新了文件,当您使用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). privileged (布尔)-指定是否以特权用户身份执行Shell脚本(sudo)。 By default this is "true" 默认情况下,这是“ true”

Edit your Vagrantfile and change 编辑您的Vagrantfile并进行更改

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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