I’m trying to fetch a file and send a command to another server.
I’m trying to do the following:
system('scp root@xxx.xxx.xxx.xxx:/etc/something.conf /tmp/',$ret);
But the file isn’t copied. If I echo $ret it outputs 1. If I log to the server through SSH and execute the same command it does well.
What could be wrong?
PS: The access to the other server is made with a public key stored in the server.
Assuming you are using ssh keys to do the scp, you need to add the servers public key for the user which is running php (typically the apache user at ‘www-data’ for ubuntu and ‘apache’ for CentOS)
As for debugging, the hint from Salman A should be useful
Using a different username than root (add some user without any privileges) for this is also good advice!