I am trying to auto update a website from remote git repo. As it's on a shared hosting i use a webhook on github & phpseclib 1.0. Here is my code:
$ssh = new Net_SSH2(SITE_DOMAIN);
$key = new Crypt_RSA();
$key->loadKey(file_get_contents('/home/'.SSH_USERNAME.'/.ssh/'.KEYPAIR_NAME));
if (!$ssh->login(SSH_USERNAME, $key)) {
throw new Exception('Failed to login');
exit('Login Failed');
}
echo $ssh->write("cd ~/source\n");
echo $ssh->write("git pull origin master\n");
the git command won't run. but when i do a git pull manually from terminal it works Thanks for your help