Thursday, January 22, 2009

Diff remote files using ssh in Linux

I have already discussed how we can edit a remote file using vi and scp in one of my previous post ; today we will see how we can find or show differences between a local file and a remote file using ssh.

Suppose we have to find the differences between local file "/tmp/" and remote file "/root/scripts/" located in remote host

This is how can do it:

$ ssh root@ "cat ~/scripts/" | diff - /tmp/

And using vimdiff:

$ vimdiff scp://root@ /tmp/

** We would need ssh to work using public key authentication so that we can do remote commands execution without being prompted for passwords.


David Milam said...

Thank you! That tip came in very handy today.

awkseeker said...

Hi Jadu,
I have few experienced with ssh from linux to unix. I want to know if I would do same from linux to windows, for example I want to send command to windows (dir, ipconfig, del, ren ...)


awkseeker said...

Could I do same from linux to Windows, such as send command del, ipconfig, ren ...

© Jadu Saikia