简体   繁体   English

git push php和主机密钥验证失败

[英]git push php and host key verification failed

$commitMessage = 'Auto commit from admin panel '.date('d.m.Y H:i:s', time());

chdir(__DIR__.'/../../../..');
$res[] = shell_exec('git add --all 2>&1');
$res[] = shell_exec('git commit -a -m "'.$commitMessage.'" 2>&1');
$res[] = shell_exec('git push origin master 2>&1');
$res[] = shell_exec('git status 2>&1');

Output after git push command: Host key verification failed. git push命令后输出: 主机密钥验证失败。 fatal: Could not read from remote repository. 致命:无法从远程存储库读取。 Please make sure you have the correct access rights and the repository exists. 请确保您具有正确的访问权限,并且存储库存在。

But before i run follow commands: 但是在我运行之前,请遵循以下命令:

sudo -u www-data ssh-keygen -t rsa
sudo chown www-data:www-data -R ~/.ssh/known_hosts
sudo chown www-data:www-data -R /project

(where locate .git directory) (在.git目录中找到)

After I add ssh key to bitbucket ssh keys (not for deploying). 将SSH密钥添加到bitbucket SSH密钥之后(不适用于部署)。

This error means that the host key for the domain you're connecting to (bitbucket, I assume, from your comment) has changed. 此错误意味着您要连接的域的主机密钥(我认为是Bitbucket,根据您的评论)。 It's their key that's different, not yours. 是他们的钥匙,而不是您的钥匙。

I'd check to see if they've changed their host key recently, and, if they have, you can remove the old key with 我会检查他们最近是否更改了主机密钥,如果有,可以使用以下命令删除旧密钥:

$ ssh-keygen -R bitbucket.org

Be careful though, an unknown host key could mean a man-in-the-middle attack. 但是要小心,未知的主机密钥可能意味着中间人攻击。 So be sure it's really bitbucket's key before doing this. 因此,在执行此操作之前,请确保它确实是bitbucket的关键。

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

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