rsync bash php


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting rsync bash php
# 1  
Old 05-10-2008
rsync bash php

Hello,
I have a bash script update.sh that contains
Code:
rsync --delete -avz -e ssh ${files} root@64.XX.XX.XX:/websites/red/

when I use that script ./update.sh as root, it works like a charm as I set up the private/public key properly.
When run from a php script through the apache webserver
Code:
<?php
exec("update.sh");
?>

The rsync line is ignored. What could I do to have that setup work?
Thank you

Last edited by Yogesh Sawant; 12-10-2010 at 05:59 AM.. Reason: added code tags
# 2  
Old 05-10-2008
apache runs php->bash->rsync as a different user => you must setup this user's ssh keys/dir.

BTW: Allowing root to connect over ssh is not recommended for security reasons. It is even less recommended to expose bash skripts, which do not check any environment variables, to the internet. It's an invitation for hackers and crackers.
# 3  
Old 05-10-2008
What would be the right way to create a key for the apache user? Thanks.
# 4  
Old 05-10-2008
i) because bash does not check i.e. environment variables calling bash from php is highly risky

ii) regarding keys: copy the keys from root's home to the home of the apache user and give apache user rights to read them. If someone takes over your apache he that way had root access to your remote backup machine (no difference to your current practice), which is not really what one wants. Better create a user on the backup machine with restricted rights which is more or less only allowed to write some files to one location and nothing more.
# 5  
Old 05-11-2008
It is unclear to me what's the "home of the apache user". Is that the DocumentRoot as set in the httpd.conf file? should I copy the whole .ssh folder there?
Thank you for your help.
# 6  
Old 05-12-2008
I have tried to put the keys in Document Root directory, changing the permissions, but nothing has worked so far. Thanks in advance for any help.
# 7  
Old 05-13-2008
home of the apache user:

i) find out as which user your apache processes are working. top or ps will be helpful

ii) find out that user's home directory. finger or a look into /etc/passwd will help
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Terminal running bash/rsync script does not close with exit (MacOS High SIerra)

Hello, I am running a bash script to do an rsync back on a computer running MacOS High Sierra. This is the script I am using, #!/bin/bash # main backup location, trailing slash included backup_loc="/Volumes/Archive_Volume/00_macos_backup/" # generic backup function function backup {... (12 Replies)
Discussion started by: LMHmedchem
12 Replies

2. Shell Programming and Scripting

Rsync Error: rsync: link_stat failed: No such file or directory (2)

I wish to copy all the files & folder under /web/Transfer_Files/data/ on mymac1 (Linux) to remote server mybank.intra.com (Solaris 10) /tmp/ location I am using Ansible tool synchronize module which triggers the unix rsync command as below:rsync --delay-updates -F --compress --archive --rsh=ssh... (2 Replies)
Discussion started by: mohtashims
2 Replies

3. Shell Programming and Scripting

Email Notifications on Cron Bash Error Only cp mv rsync

Wondering if anyone can point me to an example of how to setup a bash script that executes cp mv and rsync commands and only sends an email if there were errors with any of those commands and what the errors are. In addition it should email if the cron event to execute the script fails, or in... (1 Reply)
Discussion started by: consultant
1 Replies

4. Shell Programming and Scripting

Rsync in bash script doesn't work even after placing pub key in target server

Hello Friends, My bash script is like this #!/bin/bash # request Bourne shell as shell for job #$ -S /bin/bash # assume current working directory as paths #$ -cwd #$ -N rsync-copy # # print date and time date rsync -rltD --progress "ssh -i /home/myname/.ssh/id_rsa"... (4 Replies)
Discussion started by: jacobs.smith
4 Replies

5. Shell Programming and Scripting

Rsync script to rewrite suffix - BASH, awk, sed, perl?

trying to write up a script to put the suffix back. heres what I have but can't get it to do anything :( would like it to be name.date.suffix rsync -zrlpoDtub --suffix=".`date +%Y%m%d%k%M%S`.~" --bwlimit=1024 /mymounts/test1/ /mymounts/test2/ while IFS=. read -r -u 9 -d '' name... (1 Reply)
Discussion started by: jmituzas
1 Replies

6. Shell Programming and Scripting

bash script + php

Hello, I want to move some of my bash scripts to php ( add samba user, add new PC in dhcp and etc. ).With Google, I found some articles for bash and php, but there is only simple examples, nothing for variables. Example: #!/bin/bash status=`/usr/local/etc/rc.d/isc-dhcpd status` ############... (1 Reply)
Discussion started by: mrowcp
1 Replies

7. Shell Programming and Scripting

[BASH] rsync - error on destination

Hi everyone, and thanks to all for your assistance. I have a problem with the rsync command. I want to make a backup of a "source" directory in a "destination" directory. I want to specify: "absolute path of destination" (identified by a ~): ~/Destination or a "relative path of... (0 Replies)
Discussion started by: PaganoM
0 Replies

8. Shell Programming and Scripting

Bash script to back up with rsync

I'm trying to write a script to back up with rsync, the script I am posting below: nomServer="shiva horus isis" dirshiva="/etc /faturamento" shivaListExc="/usr/local/bin/shivaListExclRsync" dumpDir="$dumpFile/Shiva" dateBkp=`date +%A` for nServer in ${nomServer} do ... (3 Replies)
Discussion started by: ajmoreti
3 Replies

9. Shell Programming and Scripting

can't executed bash from PHP..

dear list, i've just write a simple php script to add user to my iptables, but some times it works and it dosn't work,, here's my script for my adduser.php <?php exec('/var/www/html/backup.sh'); $hash = "# $_POST\n"; $ip = "-A INPUT -p tcp -m tcp -s $_POST -d 10.10.105.18 --dport 8080 -j... (2 Replies)
Discussion started by: ridwanfi
2 Replies

10. Shell Programming and Scripting

Bash rsync but move not delete

There might be an easy solution to my problem, or maybe not, but here it is. I am trying to rsync a Volume with 1.5 terabytes of data and send it via fibre channel to a raid array. Now normally when I rsync it scans through everything and, before copying anything, deletes any files that have... (1 Reply)
Discussion started by: Movomito
1 Replies
Login or Register to Ask a Question