无法从Vagrant配置文件克隆私人仓库

tre*_*ums 14 git ssh ssh-keys vagrant

我有包含shell命令的vagrant配置脚本.当我尝试通过此脚本中的git和private\public keys克隆私人仓库时出现错误:

Cloning into 'brand.api'...

Stderr from the command:

stdin: is not a tty
dpkg-preconfigure: unable to re-open stdin: No such file or directory
Host key verification failed.
fatal: The remote end hung up unexpectedly
Run Code Online (Sandbox Code Playgroud)

但是当我git clone ...从配置脚本中排除命令并在vagrant box中自己调用它时一切正常.

这是供应文件:

#setting up Git
apt-get install -y git
mkdir ~/.ssh
mkdir ~/bin
cp /vagrant/bin/git-ssh.sh  ~/bin
cp /vagrant/keys/mygit.key ~/.ssh/mygit.key 
cp /vagrant/keys/mygit.pub ~/.ssh/mygit.pub

chmod 600 ~/.ssh/*
echo 'export GIT_SSH=~/bin/git-ssh.sh' >> ~/.bashrc
source ~/.bashrc

#installing brand-api
git clone git@****.ru:brand.api.git
Run Code Online (Sandbox Code Playgroud)

有什么问题?

更新

将git repo主机添加到known_hosts后,我得到了这个:

Stderr from the command:

stdin: is not a tty
dpkg-preconfigure: unable to re-open stdin: No such file or directory
Permission denied, please try again.
Permission denied, please try again.
Permission denied (publickey,password).
fatal: The remote end hung up unexpectedly
Run Code Online (Sandbox Code Playgroud)

但是,如果我通过登录我的盒子vagrant ssh并尝试克隆一切都没问题.

tma*_*lai 18

git服务器的SSH密钥未知/可信.当您在VM上手动克隆repo时,会收到一个提示,要求验证指纹,对吧?

您可以跳过主机密钥验证~/.ssh/config(或全局/etc/ssh/config或类似):

Host git.example.com
  StrictHostKeyChecking no
Run Code Online (Sandbox Code Playgroud)

或者您可以提前将密钥添加到~/.ssh/known_hosts(或/etc/ssh/ssh_known_hosts).例如:

ssh-keyscan -H git.example.com >> ~/.ssh/known_hosts
Run Code Online (Sandbox Code Playgroud)