php - Github authentication failed with user www-data -
i'm setting hook between github , server, can auto pull new commits when script triggered github requests.
it's setting finished, ssh-keys, git origin. can pull new commit private repo hosted on github running git pull origin master. it's works fine shell.
but when write command deploy.php file, can triggered github, error message.
host key verification failed. fatal: not read remote repository. please make sure have correct access rights , repository exists. after that, run command whoami through php file, returns user www-data.
actually, generate key www-data user, , put them in /var/www/.ssh, copied id_rsa.pub , pasted github, still have authentication failure.
- nginx
- all files set belong
www-data:www-data - i have add
www-data's public key repo's deploy keys.
deploy.php command shell_exec("cd /var/www/html/tinfo/; git pull origin master 2>&1;"); my question
- how create key
www-data? - is
www-data's.sshdirectory/var/www/.ssh? - if i'm not wrong, why github refuse connection? guess it's related user
www-dataexecutedeploy.phpfile , run commands through php. - when talk github server,
www-datanot sent private key server?
thank much.
this problem solved adding github known hosts according benyi's comment.
ssh-keyscan -t rsa github.com >> /var/www/.ssh/known_hosts you should specify ssh key firstly. after that, should git tasks want.
1-) ssh keys not user specific. can create rsa key pair everywhere. public key should copied github. private key should placed on host.
2-) in linux environment, default .ssh folder path under users home directory. if not specify user's home folder, should in /home/www-data/.ssh. if can not access folder should specify ssh key have written in example.
3-) in linux environment, deploy.php runned user executing nginx process. commonly apache2 , nginx processes executed www-data user.
4-) should specify ssh key path sending key file authorization when talk github server.
Comments
Post a Comment