How do diff over ssh?

Solution 1:

You can do it with Bash's process substitution:

 diff foo <(ssh myServer 'cat foo')

Or, if both are on remote servers:

diff <(ssh myServer1 'cat foo') <(ssh myServer2 'cat foo')

Solution 2:

Finally I've found great solution: vimdiff

vimdiff /path/to/file scp://remotehost//path/to/file

thanks to http://linux.spiney.org/remote_diff_with_vim_and_ssh see also http://www.vim.org/scripts/script.php?script_id=1075 .

Solution 3:

If you just want to see what files are different, rather than a diff of the actual files, then you can use rsync --dry-run

Solution 4:

Here's another quick and dirty command line recipe. Unlike the chosen answer, it works inside of makefiles:

ssh [login]@[host] "cat [remote file]" | diff - "[local file]"

Solution 5:

Use scp to bring the files to a common machine and diff them there?

Or, if you just want to know if the files are different or not, hash them with md5sum on each machine.

You could also look into something like SSHFS, but I don't know how well an algorithm like diff performs over that.