If I run the command via php exec(): It does not work. But if I use bash, it runs perfect. Any idea what the problem might be.? I was thinking maybe it is executing rsync as
PHP generally runs in Apache under mod_php. Usually Apache is running as its own user account, independent from the real-world people who use the server.
So, the ~/.ssh files which store the passwordless-SSH key under your user account's home directory are not available to PHP inside Apache, since it doesn't have your homedir. Even if Apache shared your home directory, it still wouldn't have permissions to read those files.