I have setup ssh keys without a passphrase (Ubuntu) and copied them to my remote server (Centos6). I can login with ssh without a password successfully under my username.
When I execute the following script in a terminal under my username (not root) it works. When I execute it through cron under my user name it fails with response:
Permission denied, please try again. Permission denied, please try again. Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).
Here is the script:
#!/bin/bash export PATH=/home/<username>/git/kodi-playercorefactory/bash-scripts:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin rsync -rvzO -e 'ssh -p 6135 -i /home/<username>/.ssh/id_rsa.pub' <username>@xx.xxx.xx.xx:<filename> <filename>
Any help will be greatly appreciated