12

I am using tramp via ssh to access remote files. For text files, this is working really well, but whenever I want to copy larger remote files to my local machine, tramp uses its slow inline method (encoding the file with gzip). This is much slower than using an external method like for example scp. How do I make emacs use scp when transfering large files?

Relevant information:

  • I use an ~/.ssh/config file to access the remote machine. The alias for that machine is hehi09 in the following. The access is password-less

  • Messages in message buffer when transferring:

    Copying /ssh:hehi09:/home/christian/big_file.dat to /home/christian/big_file.dat'...
    Tramp: Inserting `/ssh:hehi09:/home/christian/big_file.dat'...
    Tramp: Encoding remote file `/ssh:hehi09:/home/christian/big_file.dat' with `(gzip <%s | base64)'...
    
  • Values of:

    • tramp-copy-size-limit's value is 10240 (much smaller than tested file size)

    • tramp-default-method's value is "scp"

  • $ scp hehi09:/home/christian/big_file.dat ~/ works as expected from the command line and is much faster than the transfer in emacs

Any ideas why emacs is not using scp to copy large files? Any help is greatly appreciated!

18

When you are saying "I am using tramp via ssh" I suppose you open a file like /ssh:host:/path/to/file. This is supposed to use always the ssh method. If you want to use the scp method, you shall use /scp:host:/path/to/file. This uses automatically ssh for short files, and scp for large files. If you trust the default method set in tramp-default-method, you could use the shorter /host:/path/to/file.

| improve this answer | |
  • It would be nice that it always use both ssh and scp when copying files, regardless of whether /ssh or /scp.. Or at least gives some warning message when copying large binaries with /ssh. Before seeing your answer, i thought emacs is not ready for copying large files via tramp. (since i only used /ssh) – xwl Sep 5 '16 at 13:43
  • 2
    In that case, make scp your default method. Even then, Tramp copies small files via ssh, and large files via scp. You can customize the limit via tramp-copy-size-limit. – Michael Albinus Sep 6 '16 at 9:42
  • 5
    As of Emacs 26, a method is mandatory now in remote file names. You must always say /scp:host:/path/to/file or /ssh:host:/path/to/file . – Michael Albinus Jul 27 '17 at 15:21
0

Because you got to set it in ~/.emacs file. Despite that, Emacs is a text editor, not a SFTP or FTP client, it uses this base64 encoding while in ssh method that turns it too slow for file transfer.

| improve this answer | |
  • Sorry, but that is incorrect. As the accepted answer says you can either trust a default selection or make an explicit decision for every connection. If you do use ssh you are correct that a base64 conversion is taking it place which is slow for largish files. However, if you use scp that is not the case. Emacs is well capable to execute commands which do not deal with "text". Lastly, don't break it to Emacs users that their favorite OS is a text editor ;) – Chris Mar 18 at 14:12
  • Already set up it with scp and base64 conversion kept ocurring. Would be appreciable if it doesn't happens, once it likely would be main application for SFTP connections. Although it is used as main text editor and file manager. – Ronald71 Mar 20 at 23:38
  • You're right, somehow managed here to do it via scp method, without base64 conversion, turning it faster. – Ronald71 Mar 21 at 16:34
  • That is strange. I did not need any special settings for scp to not use base64 encoding. Could you quickly share what the problem was in your case for anybody dropping by here in the future? – Chris Mar 27 at 8:37
  • Already managed to do it, @Chris. Main problem was that the TRAMP dired connection was open via ssh, then was running scp command, which oblied the base64 conversion. When run both TRAMP dired connection and copy command itself both with scp method, it disregarded the base64 conversion and did faster. – Ronald71 Mar 27 at 16:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.