Rsync uses ssh to sync files between two machines and usually it will use default identity file present in ~/.ssh/ directory on Linux. In case you want to use a custom rsync file you can use -e or –rsh option of rsync. Another option is to change ~/.ssh/config file to specify identity file for a specific host. For this article we will be using Ubuntu Linux.
To use specific identity file using -e, use the following command:
rsync -v -az --exclude="_norsync*" -e "ssh -l USERID -i /idfilepath/id_rsa" /srcpath DESTHOST:/destpath/
You can replace DESTHOST and USERID appropriately.
Other approach is to add the following entry in ~/.ssh/config
host DESTHOST IdentityFile /idfilepath/id_rsa
You can replace DESTHOST, idfilepath and USERID appropriately. This tell ssh that for DESTHOST use the specified identity file.