Checking integrity copied from remote server using UNIX command

I am getting a file (abc.txt) using scp from remote server.

scp <connect string> -i $HOME/.ssh/id_dsa rem_id@hostname:/var/prod/abc.txt /var/prod/abc.out

Before loading I need to check if the file is indeed same , for that I thought of checking the line count but when I used ssh command it was prompting for password.
Is there any other method to check integrity?

Basically we load it in a table and we need to ensure record loaded matches with the the one present in file.

scp and ssh - for the same user - should use the same authentication method, so I can't see why ssh needs a password when scp doesn't.

Why can't you copy the file and then do the check?

steps are as below

  1. check the cksum on remote server
  2. copy the file on local server '
  3. check the cksum on local server and it should match

Ok let me check why ssh is not working

---------- Post updated at 06:36 AM ---------- Previous update was at 05:16 AM ----------

Hi it seems to able to connect and run the command , however in the file I get count as well as file name , is there way I can put some thing like count separator with only file name (not full path) and last modified date of remote server

 ssh id@hostname  'wc -l /var/uat/a.ctl ' > abc.txt
 cat abc.txt
1 /var/uat/a.ctl

Counting the number of lines isn't much of a check that the files are really the same - use an actual checksum (e.g. cksum or md5sum).

Something like:

scp -i $HOME/.ssh/id_dsa rem_id@hostname:/var/prod/abc.txt /var/prod/abc.out
diff -q <(ssh -i $HOME/.ssh/id_dsa rem_id@hostname 'cksum < /var/prod/abc.txt') <(cksum < /var/prod/abc.out)

should exit with 0 if the checksums are identical.

( <(stuff) is bash process substitution, but you could use temporary files instead. Feeding cksum from stdin rather than a file means you don't need to care what the filename is.)