4.6 Selecting a default method

In a remote file name, the use of a default method is indicated by the pseudo method -, TRAMP file name conventions.

User Option: tramp-default-method

Default method is for transferring files. The user option tramp-default-method sets it. TRAMP uses this user option to determine the default method for remote file names that do not have one specified.

(customize-set-variable 'tramp-default-method "ssh")
User Option: tramp-default-method-alist

Default methods for transferring files can be customized for specific user and host combinations through the user option tramp-default-method-alist.

For example, the following two lines specify to use the ssh method for all user names matching ‘john’ and the rsync method for all host names matching ‘lily’. The third line specifies to use the su method for the user ‘root’ on the host ‘localhost’.

(add-to-list 'tramp-default-method-alist '("" "john" "ssh"))
(add-to-list 'tramp-default-method-alist '("lily" "" "rsync"))
(add-to-list 'tramp-default-method-alist
             '("\\`localhost\\'" "\\`root\\'" "su"))

External methods performance faster for large files. see Inline methods. see External methods.

Choosing the access method also depends on the security environment. For example, rsh and telnet methods that use clear text password transfers are inappropriate for over the Internet connections. Secure remote connections should use ssh that provide encryption.

4.6.1 Which method to use?

TRAMP provides maximum number of choices for maximum flexibility. Choosing which method depends on the hosts, clients, network speeds, and the security context.

Start by using an inline method.

External methods might be more efficient for large files, but most TRAMP users edit small files more often than large files.

Enable compression, tramp-inline-compress-start-size, for a performance boost for large files with inline methods.

Since ssh has become the most common method of remote host access and it has the most reasonable security protocols, use ssh method. Typical ssh usage to edit the /etc/motd file on the otherhost:

C-x C-f /ssh:root@otherhost:/etc/motd RET

If ssh is unavailable for whatever reason, look for other obvious options. For MS Windows, try the plink method1. For Kerberos, try krlogin.

For editing local files as su or sudo methods, try the shortened syntax of ‘root’:

C-x C-f /su::/etc/motd RET

For editing large files, scp is faster than ssh. pscp is faster than plink. But this speed improvement is not always true.

When copying large files between two different remote hosts via scp, set tramp-use-scp-direct-remote-copying to non-nil.


Footnotes

(1)

This shouldn’t be needed with recent OpenSSH versions for MS Windows. Use method sshx.