I’m trying to send an image file from one server to another using rsync. The sending server’s public key has been placed into the receiving server’s /root/.ssh/authorized_keys . (I’ll not use root later on. Just trying to keep things as simple as possible for now.)
I can get an image copied successfully to the receiving server from the command line.
rsync -va /var/www/html/nameofimage.jpg root@111.222.333.444:/images/
However, I do not know how to write this into a PHP file. I thought this would work.
<?php
exec('rsync -va /var/www/html/nameofimage.jpg root@111.222.333.444:/images/');
?>
But when this file is invoked from the command line, I receive the message … rsync: link_stat “/home/myusername/ssh” failed: No such file or directory (2) rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1183) [sender=3.1.0]
Thanks for any direction with this.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
This question was answered by @TonyTsang:
Late reply, no notification for comment reply.
Seems you are missing the identity file (private key), you have three methods to specify the identity file
Copy your key to
/var/www/.ssh/id_rsa (id.dsa or id_ecdsa)& chmod 0600 /var/www/.ssh/id_rsa. Then let ssh search for it.Specify it with -i option:
rsync -e "ssh -o StrictHostKeyChecking=no,UserKnownHostsFile=/dev/null -i /path/to/your/private/key" --other-options-here
- Specify in config file /var/www/.ssh/config (chown www-data & chmod 0600 may be required) Edit it with following content:
Host name_of_your_choice Hostname 45.55.136.175 Port 22 User your_user_name_at_remote_machine PreferredAuthentications publickey IdentityFile /path/to/your/private/key
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.