• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 798
  • Last Modified:

php, rsync and exec function

I need from a PHP script running ."script.sh"  that contain  :

SSH_AUTH_SOCK=/tmp/ssh-XXlFi8Jl/agent.3825; export SSH_AUTH_SOCK;
SSH_AGENT_PID=3826; export SSH_AGENT_PID;
echo Agent pid 3826;
/usr/bin/rsync --delete -ave ssh /data/AUDIO_FILES/ srv01:/data/AUDIO_FILES/

In my php script :

exec("/home/script.sh  2>&1",$return);

print_r($return) give me :

Array ( [0] => Agent pid 3826 [1] => Could not create directory '/.ssh'. [2] => Host key verification failed. [3] => unexpected EOF in read_timeout )

PLEASE HELP !!
0
eeolivier
Asked:
eeolivier
  • 4
  • 2
1 Solution
 
eeolivierAuthor Commented:
Maybe you could tell me how to execute a script with root rights, and with all PATH ok ? maybe it's the problem ?
0
 
hernst42Commented:
See http:Q_21108456.html how to setup sudo to work with the webserver user, so you can run that script as root.
0
 
eeolivierAuthor Commented:
no, nothing there that can help me
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
hernst42Commented:
add in /etc/sudoers:
wwwrun  ALL=(ALL) NOPASSWD: /home/script.sh

in php call exec('sudo /home/script.sh', $return);
Then your script will be run as root.

What do you want to do with that script exactly. Seems that you want to connect to an running ssh-agent. Are you sure that that agent still exists and under which user is thatagent running?
0
 
eeolivierAuthor Commented:
yes, that script run perfectly when I run it from the shell as root.

It let me to synchronize files over 5 different servers avec over SSH without having to type password.

When i do vi /etc/sudoers, under root user, i have "read only file".
0
 
eeolivierAuthor Commented:
it was "visudo". I am going to try the tip
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now