我有包含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
但是当我从配置脚本中排除git clone ...
命令并在流浪盒中自己调用时,一切正常。
这是供应文件:
#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
登录我的盒子并尝试克隆一切正常。
答案 0 :(得分:17)
git服务器的SSH密钥未知/可信。当您在VM上手动克隆repo时,会收到一个提示,要求验证指纹,对吗?
您可以跳过~/.ssh/config
中的主机密钥验证(或全局/etc/ssh/config
或类似):
Host git.example.com
StrictHostKeyChecking no
或者您可以提前将密钥添加到~/.ssh/known_hosts
(或/etc/ssh/ssh_known_hosts
)。例如:
ssh-keyscan -H git.example.com >> ~/.ssh/known_hosts
答案 1 :(得分:1)
这对我有用..
尝试将此内容放入 provision.sh :
sudo -u vagrant git clone git@****.ru:brand.api.git
而不是:
git clone git@****.ru:brand.api.git