我有包含 shell 命令的 vagrant provision 脚本。当我尝试通过 git 和 private\public key 在此脚本中克隆私有(private) repo 时,出现错误:
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
但是当我从配置脚本中排除 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
有什么问题?
已更新
将 git repo host 添加到 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
但是如果我通过 vagrant ssh
登录到我的盒子并尝试克隆一切就OK了。
最佳答案
git 服务器的 SSH key 未知/不可信。当您在 VM 上手动克隆 repo 时,您会收到要求验证指纹的提示,对吗?
您可以在 ~/.ssh/config
中跳过主机 key 验证(或在 /etc/ssh/config
或类似的全局中):
Host git.example.com
StrictHostKeyChecking no
或者您可以预先将 key 添加到~/.ssh/known_hosts
(或/etc/ssh/ssh_known_hosts
)。例如:
ssh-keyscan -H git.example.com >> ~/.ssh/known_hosts
关于git - 无法从 Vagrant 配置文件克隆私有(private)仓库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23935138/