PHP项目在coding使用WebHook自动部署时,git pull出现了下面的问题
Host key verification failed.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
一开始在网上查了,基本都是说删除~/.ssh/known_hosts
文件,
然而并没有用,因为我删除的并不是执行git pull用户的known_hosts文件
搞了我两天,原来是用户的问题,下面是我的解决方法:
由于对linux不太熟悉,我都快给搞炸了,会linux的应该都是小意思。
1.查看执行git pull命令的用户
//PHP代码
exec("cd ~ && cd - && cd -", $output);//跳到用户目录,再回刚刚的目录,然后跳到用户目录
print_r($output);//输出
//cd -命令是返回刚刚目录并输出
//不要使用who命令,因为并不一定是它执行git pull的
//反正我就是给它搞晕了,看用户目录就可以知道是哪个用户执行的了
//我的who命令是root用户,而cd -命令的用户目录是www用户
输出的信息是:
Array ( [0] => /home/wwwroot/apche/web,
[1]&