When you select an appropriate transfer method for your typical usage
you should set the variable
tramp-default-method to reflect that
choice. This variable controls which method will be used when a method
is not specified in the tramp file name. For example:
(setq tramp-default-method "ssh")
You can also specify different methods for certain user/host
combinations, via the variable
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"))
See the documentation for the variable
tramp-default-method-alist for more details.
External methods are normally preferable to inline methods, giving better performance.
See Inline methods. See External methods.
Another consideration with the selection of transfer methods is the environment you will use them in and, especially when used over the Internet, the security implications of your preferred method.
The rsh and telnet methods send your password as plain text as you log in to the remote host, as well as transferring the files in such a way that the content can easily be read from other hosts.
If you need to connect to remote systems that are accessible from the Internet, you should give serious thought to using ssh based methods to connect. These provide a much higher level of security, making it a non-trivial exercise for someone to obtain your password or read the content of the files you are editing.
Given all of the above, you are probably thinking that this is all fine and good, but it's not helping you to choose a method! Right you are. As a developer, we don't want to boss our users around but give them maximum freedom instead. However, the reality is that some users would like to have some guidance, so here I'll try to give you this guidance without bossing you around. You tell me whether it works ...
My suggestion is to use an inline method. For large files, external methods might be more efficient, but I guess that most people will want to edit mostly small files. And if you access large text files, compression (driven by tramp-inline-compress-start-size) shall still result in good performance.
I guess that these days, most people can access a remote host by using ssh. So I suggest that you use the ssh method. So, type C-x C-f /ssh:root@otherhost:/etc/motd <RET> to edit the /etc/motd file on the other host.
If you can't use ssh to log in to the remote host, then select a method that uses a program that works. For instance, Windows users might like the plink method which uses the PuTTY implementation of ssh. Or you use Kerberos and thus like krlogin.
For the special case of editing files on the local host as another user, see the su or sudo methods. They offer shortened syntax for the ‘root’ account, like /su::/etc/motd.
People who edit large files may want to consider scp instead of ssh, or pscp instead of plink. These external methods are faster than inline methods for large files. Note, however, that external methods suffer from some limitations. Please try first whether you really get a noticeable speed advantage from using an external method! Maybe even for large files, inline methods are fast enough.