Почему не использовать ssh2?
примерно так:
//Connect first
if (!($con = @ssh2_connect('192.168.0.1', 22))) {
echo "[FAILED_CONNECT]\n";
exit(1);
}
if (!@ssh2_auth_password($con, "your_user", "your_password")) {
echo "[FAILED_AUTH_DENIED]\n";
exit(1);
}
echo "[OK]\n CONNECTED!";
// the command line
$stdout_stream = ssh2_exec($con, "/usr/bin/latex ...");
// close connection
fclose($stdout_stream);