If I have a file namely /etc/file.cfg on server A and server B. How can we check whether the file on Server A is newer than file on server B ?
If it was on a local machine then we would have used file1 -nt file2.
If you have ssh access you can try something like below. Note that there is no error checking, for instance if remote files do not exist this would fail.
Note that if you do not want to enter password everytime you can use the ssh-copy-id command to copy your public key to the remote server's authorized_keys files.