I am trying to connect from one linux box (machine1) to another linux box (machine2) via exec() or system() as a particular user (usr1) using ssh2.
I have...
..successfully set up and tested the ssh2 keys used to communicate from machine1 to machine2.
...successfully executed (and retrieved information) from the command line on machine1. But when I put the same command into the exec() or system() functions nothing happens.
The below example works from the shell prompt of machine1...
shell> ssh2 - l usr usr@machine2.com cat /path/to/information
But this does not work...
exec("ssh2 -l usr usr@machine2.com cat /path/to/information",$result)
while(list($info)=each($result)){
echo($info);
}
How can I tell apache or php to act as a particular user when connecting to another machine using exec() or the system() functions?
Can someone please help me? What I am doing wrong?