Beyond compare remote with local file
Asked Answered
K

3

8

I want to compare two text files one on remote the other local. With diff I would do that with

ssh user@login "cat myfile.txt" | diff - local.txt

Is there a way to perform the same comparison using Beyond Compare? If I do

ssh user@login "cat myfile.txt" | bcompare - local.txt

I get only the local file displayed.

Kirman answered 6/6, 2017 at 9:31 Comment(0)
B
9

One neat trick that I use in such cases is to use sshfs to make the remote directory appear as a local one to beyond compare:

sshfs user@host:/opt/data /tmp/transfer

Then you can use any diffing tool to compare your local data with the remote one via diff -Nur /local/data/dir /tmp/transfer or with beyond compare as usual and you can copy files back and forth as needed.

Note, you might need to install sshfs via your package manager, e.g. on Debian/Ubuntu via apt-get install sshfs

Possible options:

  • -o PubkeyAuthentication=no: If you need password authentication, but ssh first tries too many private key authenticaitions, not needed if you use private key auth for this server or no private key auth at all
  • -o sshfs_debug: Print out more information if authentication/connection fails
  • -o idmap=user: Use the idmap=user option to translate the UID of the connecting user to the remote user
  • -o gid=1000: uid, gid - set reported ownership of files to given values; uid is the numeric user ID of your user, gid is the numeric group ID of your user.
  • -o nomap=error: Fail if user mapping cannot be done

See https://wiki.archlinux.org/index.php/SSHFS for more details.

Belonging answered 28/8, 2017 at 19:52 Comment(2)
Wow, your trick works great. Would you mind just explain what the options stand for. ThanksKirman
Done, I just happened to use these in one scenario, they are not mandatory, but often are useful, I explained a bit what they do and provided a link to some more information.Belonging
T
7

Beyond Compare Pro includes built-in SFTP support, so you can pass an SFTP URL directly to it as a command-line argument.

bcompare local.txt sftp://user:password@server/folder/file.txt

If you don't provide a password in the URL, Beyond Compare will prompt you for a password.

bcompare local.txt sftp://user@server/folder/file.txt
Turoff answered 6/6, 2017 at 20:46 Comment(6)
I am not sure if this is my case. I would like to compare a local file with a file I have on a cluster remote directory. I usually access it doing ssh [email protected] "cd my/directory/" Kirman
Many servers that support SSH also support SFTP. In your example, you'd use the command line: bcompare sftp://[email protected]/my/directory/file.extTuroff
@ChrisKennedy, does Beyond Compare Pro support SFT with private RSA key authentification (analog to -i option of ssh)? Or only password-based authentification?Coccus
Yes, Beyond Compare Pro supports private key authentication for SFTP. scootersoftware.com/support.php?zz=kb_sftp_privatekeyTuroff
Nice, but this does not seem to work with AWS CodeCommit, which only accepts urls starting with ssh://, not the default sftp:// used by BC. Is there any workaround for specifying a different protocol in the url? e.g. ssh:// or https://Bobbery
Sorry, Beyond Compare doesn't support ssh:// URLs.Turoff
G
0

BeyondCompare offers comparing files on local files system and remote. For accessing remote files e.g. on linux server, try Browse using profile which gives option of QuickConnect. Select FTP profile --> select protocol sftp (ssh2). Provide your host, port, user and password. Click save and connect. I t will show the remote file system to choose any remote file or folder.

Goar answered 22/8, 2022 at 23:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.