Compare file in other sever

Hi All,
I have totally two server. First server name is ABC which contains the file name is Sum.txt and Second server name is Sun here one file generate during the runtime.

Currently I am in First Server. Now, I need to compare the server one file (Sum.txt) with server two file.

If it doesn't match, i have to exit from the script.

Any help is really appreciated.

SCP the file from Server ABC to Second server..

scp Sum.txt username@Sun:/your/path/in/Sun/Server

Then in Second server, find the difference..

$ diff Sum.txt runtime-file
$ [ $? -ne 0 ] && echo "Not matching" || echo "Matching"

You need set keyless login by SSH first.

diff first.txt <(ssh username@Sun cat second.txt)