I am running this command on shell CLI and it works
sudo -u apache /usr/bin/mysqldump -u root -p"password" --opt dbname | gzip -c | ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/path/to/.ssh/known_hosts -l deploy -i /path/to/.ssh/id_rsa user@somehost "/bin/cat > /path/to/backup_db/backup_08-20-2013.gz"
But this command does not work if I run from PHP.
I run this command using
system function of PHP
But in the
$retval the status is
255 and I get this error in the output of system
ssh: connect to host myhostname port 22: Permission denied
The command works even with
apache user when I put it directly in shell and it does not ask for password that means the command is able to read the RSA key and all. But if I run it from PHP it does not work. PHP script is also running with 'apache' user.
Please point me right direction.