简体   繁体   中英

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. 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)

After I add ssh key to bitbucket ssh keys (not for deploying).

This error means that the host key for the domain you're connecting to (bitbucket, I assume, from your comment) has changed. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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