I am trying to create a cron job to perform backup of a server over the internet using sftp. But before the actual backup is performed, I would like to verify that the server is connecting to the correct backup machine as its IP address may change periodically.
My idea is to put a file containing a checksum say
abc123 in the sftp folder of the backup machine and let the server read and compare this checksum first before performing the backup transfer. I have already set up the ssh key to allow authentication without password. How do I go about performing this verification with sftp command?