1.windows
本人在用windows上,用php7.2进行git操作时,总是在报错
Cloning into 'G:\tmp\repository\git_repository\chef-server.git'...
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 key和配置,发现没有任何错误,百思不得其解,最终使用php执行以下命令
cat ~/.ssh
发现php执行git命令时不是在系统用户目录,而是在以下目录
C:\Windows\System32\config\systemprofile\.ssh
之后将原来的id_rsa,id_rsa.pub,known_hosts移到该目录,之后便执行命令成功了
2.centos7
同样的问题在centos7上也出现了,原因是相似的,因为php所属用户不是root,通常为www,所以需为www配置ssh key,在/home/www/.ssh/目录下,添加config文件,内容如下:
#git的域名地址
Host gitlab.com
PubkeyAcceptedKeyTypes +ssh-rsa
HostName gitlab.com
IdentityFile
#你原ssh key所在位置
~/.ssh/id_rsa
#你的git email
User your.name@163.com
并把原ssh key地址的knwo_hosts拷贝过来就可以了