1. FAILED
project.allsmy.com_githook_index

FAILED Response 200

Headers

Content-Length: 891
Content-Type: text/html; charset=UTF-8
Date: Tue, 17 Apr 2018 12:54:33 GMT
Server: Apache/2.4.18 (Ubuntu)
Vary: Accept-Encoding

Body

校验成功,开始更新
/var/www/allsmy-project-site/bin/gitPush.sh
ssh-agent bash

/usr/bin/ssh-agent -s
SSH_AUTH_SOCK=/tmp/ssh-aferPLRuonUI/agent.7738; export SSH_AUTH_SOCK;
SSH_AGENT_PID=7739; export SSH_AGENT_PID;
echo Agent pid 7739;

ssh-add /var/www/.ssh/githubssh
Could not open a connection to your authentication agent.

ssh-add -l
Could not open a connection to your authentication agent.

cd /var/www/allsmy-project-site

git pull allsmy-project-site
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
pull allsmy-project-site ok

cd /var/www/PHPExample
git pull PHPExample
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

pull PHPExample ok
2018/04/17 20:54:33

2. SUCCESS

project.allsmy.com_githook_success


3. QUESTION & ANSWER
Q1. Could not open a connection to your authentication agent? The Most Important Error!
A1:
eval $(ssh-agent)
KEY POINT , START SSH-AGENT. IT IS THE PROBLEM.
1. IN CMD MODE
> ssh-agent bash
> ssh-add /path/privateKey
> cd repositoryDIR
> git pull
echo It WILL SUCCESS.END.

2. PHP EXEC('bash cmd');
Here is bash cmd content.
// begin
ssh-agent bash [2>&1]
eval $(ssh-agent) // KEY POINT , START SSH-AGENT. It IS THE PROBLEM.
ssh-add /path/privateKey
cd repositoryDIR
git pull
// end
echo It WILL SUCCESS.END.

Q2. Linux permissions
A2:
1. PHP OR APACHE USER IS NO ROOT , USE WWW-DATA/WWW OR OTHER
2. WWW DIR PERMISSION : chown www-data: www-data ...
3. NEW CLONE: git clone repository url

Q3. Forget ...



GOT LINK:
1、https://wiki.archlinux.org/index.php/SSH_keys_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)#ssh-agent