069359f1a6307af0b0fdfa05c37c2bc6ec521538
[bpt/emacs.git] / doc / misc / tramp.texi
1 \input texinfo @c -*-texinfo-*-
2 @setfilename ../../info/tramp
3 @c %**start of header
4 @settitle TRAMP User Manual
5 @c %**end of header
6
7 @c This is *so* much nicer :)
8 @footnotestyle end
9
10 @c In the Tramp CVS, the version number is auto-frobbed from
11 @c configure.ac, so you should edit that file and run
12 @c "autoconf && ./configure" to change the version number.
13
14 @c Additionally, flags are set with respect to the Emacs flavor; and
15 @c depending whether Tramp is packaged into (X)Emacs, or standalone.
16
17 @include trampver.texi
18
19 @c Macro for formatting a filename according to the repective syntax.
20 @c xxx and yyy are auxiliary macros in order to omit leading and
21 @c trailing whitespace. Not very elegant, but I don't know it better.
22
23 @macro xxx {one}@c
24 @set \one\@c
25 @end macro
26
27 @macro yyy {one, two}@c
28 @xxx{x\one\}@c
29 @ifclear x@c
30 \one\@w{}\two\@c
31 @end ifclear
32 @clear x\one\@c
33 @end macro
34
35 @macro trampfn {method, user, host, localname}@c
36 @value{prefix}@yyy{\method\,@value{postfixhop}}@yyy{\user\,@@}\host\@value{postfix}\localname\@c
37 @end macro
38
39 @copying
40 Copyright @copyright{} 1999, 2000, 2001, 2002, 2003, 2004, 2005,
41 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
42
43 @quotation
44 Permission is granted to copy, distribute and/or modify this document
45 under the terms of the GNU Free Documentation License, Version 1.3 or
46 any later version published by the Free Software Foundation; with no
47 Invariant Sections, with the Front-Cover texts being ``A GNU Manual'',
48 and with the Back-Cover Texts as in (a) below. A copy of the license
49 is included in the section entitled ``GNU Free Documentation License''.
50
51 (a) The FSF's Back-Cover Text is: ``You have the freedom to
52 copy and modify this GNU manual. Buying copies from the FSF
53 supports it in developing GNU and promoting software freedom.''
54 @end quotation
55 @end copying
56
57 @c Entries for @command{install-info} to use
58 @dircategory @value{emacsname}
59 @direntry
60 * TRAMP: (tramp). Transparent Remote Access, Multiple Protocol
61 @value{emacsname} remote file access via rsh and rcp.
62 @end direntry
63
64 @titlepage
65 @title @value{tramp} version @value{trampver} User Manual
66 @author by Daniel Pittman
67 @author based on documentation by Kai Gro@ss{}johann
68 @page
69 @insertcopying
70 @end titlepage
71
72 @contents
73
74 @ifnottex
75 @node Top, Overview, (dir), (dir)
76 @top @value{tramp} version @value{trampver} User Manual
77
78 This file documents @value{tramp} version @value{trampver}, a remote file
79 editing package for @value{emacsname}.
80
81 @value{tramp} stands for `Transparent Remote (file) Access, Multiple
82 Protocol'. This package provides remote file editing, similar to
83 @value{ftppackagename}.
84
85 The difference is that @value{ftppackagename} uses FTP to transfer
86 files between the local and the remote host, whereas @value{tramp} uses a
87 combination of @command{rsh} and @command{rcp} or other work-alike
88 programs, such as @command{ssh}/@command{scp}.
89
90 You can find the latest version of this document on the web at
91 @uref{http://www.gnu.org/software/tramp/}.
92
93 @c Pointer to the other Emacs flavor is necessary only in case of
94 @c standalone installation.
95 @ifset installchapter
96 The manual has been generated for @value{emacsname}.
97 @ifinfo
98 If you want to read the info pages for @value{emacsothername}, you
99 should read in @ref{Installation} how to create them.
100 @end ifinfo
101 @ifhtml
102 If you're using the other Emacs flavor, you should read the
103 @uref{@value{emacsotherfilename}, @value{emacsothername}} pages.
104 @end ifhtml
105 @end ifset
106
107 @ifhtml
108 @ifset jamanual
109 This manual is also available as a @uref{@value{japanesemanual},
110 Japanese translation}.
111 @end ifset
112
113 The latest release of @value{tramp} is available for
114 @uref{ftp://ftp.gnu.org/gnu/tramp/, download}, or you may see
115 @ref{Obtaining Tramp} for more details, including the CVS server
116 details.
117
118 @value{tramp} also has a @uref{http://savannah.gnu.org/projects/tramp/,
119 Savannah Project Page}.
120 @end ifhtml
121
122 There is a mailing list for @value{tramp}, available at
123 @email{tramp-devel@@gnu.org}, and archived at
124 @uref{http://lists.gnu.org/archive/html/tramp-devel/, the
125 @value{tramp} Mail Archive}.
126 @ifhtml
127 Older archives are located at
128 @uref{http://sourceforge.net/mailarchive/forum.php?forum=tramp-devel,
129 SourceForge Mail Archive} and
130 @uref{http://www.mail-archive.com/emacs-rcp@@ls6.cs.uni-dortmund.de/,
131 The Mail Archive}.
132 @c in HTML output, there's no new paragraph.
133 @*@*
134 @end ifhtml
135
136 @insertcopying
137
138 @end ifnottex
139
140 @menu
141 * Overview:: What @value{tramp} can and cannot do.
142
143 For the end user:
144
145 * Obtaining Tramp:: How to obtain @value{tramp}.
146 * History:: History of @value{tramp}.
147 @ifset installchapter
148 * Installation:: Installing @value{tramp} with your @value{emacsname}.
149 @end ifset
150 * Configuration:: Configuring @value{tramp} for use.
151 * Usage:: An overview of the operation of @value{tramp}.
152 * Bug Reports:: Reporting Bugs and Problems.
153 * Frequently Asked Questions:: Questions and answers from the mailing list.
154 * Function Index:: @value{tramp} functions.
155 * Variable Index:: User options and variables.
156 * Concept Index:: An item for each concept.
157
158 For the developer:
159
160 * Version Control:: The inner workings of remote version control.
161 * Files directories and localnames:: How file names, directories and localnames are mangled and managed.
162 * Traces and Profiles:: How to Customize Traces.
163 * Issues:: Debatable Issues and What Was Decided.
164
165 * GNU Free Documentation License:: The license for this documentation.
166
167 @detailmenu
168 --- The Detailed Node Listing ---
169 @c
170 @ifset installchapter
171 Installing @value{tramp} with your @value{emacsname}
172
173 * Installation parameters:: Parameters in order to control installation.
174 * Load paths:: How to plug-in @value{tramp} into your environment.
175 * Japanese manual:: Japanese manual.
176
177 @end ifset
178
179 Configuring @value{tramp} for use
180
181 * Connection types:: Types of connections made to remote machines.
182 * Inline methods:: Inline methods.
183 * External methods:: External methods.
184 @ifset emacsgw
185 * Gateway methods:: Gateway methods.
186 @end ifset
187 * Default Method:: Selecting a default method.
188 * Default User:: Selecting a default user.
189 * Default Host:: Selecting a default host.
190 * Multi-hops:: Connecting to a remote host using multiple hops.
191 * Customizing Methods:: Using Non-Standard Methods.
192 * Customizing Completion:: Selecting config files for user/host name completion.
193 * Password handling:: Reusing passwords for several connections.
194 * Connection caching:: Reusing connection related information.
195 * Remote Programs:: How @value{tramp} finds and uses programs on the remote machine.
196 * Remote shell setup:: Remote shell setup hints.
197 * Windows setup hints:: Issues with Cygwin ssh.
198 * Auto-save and Backup:: Auto-save and Backup.
199
200 Using @value{tramp}
201
202 * Filename Syntax:: @value{tramp} filename conventions.
203 * Alternative Syntax:: URL-like filename syntax.
204 * Filename completion:: Filename completion.
205 * Remote processes:: Integration with other @value{emacsname} packages.
206 * Cleanup remote connections:: Cleanup remote connections.
207
208 The inner workings of remote version control
209
210 * Version Controlled Files:: Determining if a file is under version control.
211 * Remote Commands:: Executing the version control commands on the remote machine.
212 * Changed workfiles:: Detecting if the working file has changed.
213 * Checking out files:: Bringing the workfile out of the repository.
214 * Miscellaneous Version Control:: Things related to Version Control that don't fit elsewhere.
215
216 Things related to Version Control that don't fit elsewhere
217
218 * Remote File Ownership:: How VC determines who owns a workfile.
219 * Back-end Versions:: How VC determines what release your RCS is.
220
221 How file names, directories and localnames are mangled and managed
222
223 * Localname deconstruction:: Breaking a localname into its components.
224 @ifset emacs
225 * External packages:: Integration with external Lisp packages.
226 @end ifset
227
228 @end detailmenu
229 @end menu
230
231 @node Overview
232 @chapter An overview of @value{tramp}
233 @cindex overview
234
235 After the installation of @value{tramp} into your @value{emacsname}, you
236 will be able to access files on remote machines as though they were
237 local. Access to the remote file system for editing files, version
238 control, and @code{dired} are transparently enabled.
239
240 Your access to the remote machine can be with the @command{rsh},
241 @command{rlogin}, @command{telnet} programs or with any similar
242 connection method. This connection must pass @acronym{ASCII}
243 successfully to be usable but need not be 8-bit clean.
244
245 The package provides support for @command{ssh} connections out of the
246 box, one of the more common uses of the package. This allows
247 relatively secure access to machines, especially if @command{ftp}
248 access is disabled.
249
250 Under Windows, @value{tramp} is integrated with the PuTTY package,
251 using the @command{plink} program.
252
253 The majority of activity carried out by @value{tramp} requires only that
254 the remote login is possible and is carried out at the terminal. In
255 order to access remote files @value{tramp} needs to transfer their content
256 to the local machine temporarily.
257
258 @value{tramp} can transfer files between the machines in a variety of ways.
259 The details are easy to select, depending on your needs and the
260 machines in question.
261
262 The fastest transfer methods for large files rely on a remote file
263 transfer package such as @command{rcp}, @command{scp}, @command{rsync}
264 or (under Windows) @command{pscp}.
265
266 If the remote copy methods are not suitable for you, @value{tramp} also
267 supports the use of encoded transfers directly through the shell.
268 This requires that the @command{mimencode} or @command{uuencode} tools
269 are available on the remote machine. These methods are generally
270 faster for small files.
271
272 @value{tramp} is still under active development and any problems you encounter,
273 trivial or major, should be reported to the @value{tramp} developers.
274 @xref{Bug Reports}.
275
276
277 @subsubheading Behind the scenes
278 @cindex behind the scenes
279 @cindex details of operation
280 @cindex how it works
281
282 This section tries to explain what goes on behind the scenes when you
283 access a remote file through @value{tramp}.
284
285 Suppose you type @kbd{C-x C-f} and enter part of an @value{tramp} file name,
286 then hit @kbd{@key{TAB}} for completion. Suppose further that this is
287 the first time that @value{tramp} is invoked for the host in question. Here's
288 what happens:
289
290 @itemize
291 @item
292 @value{tramp} discovers that it needs a connection to the host. So it
293 invokes @samp{telnet @var{host}} or @samp{rsh @var{host} -l
294 @var{user}} or a similar tool to connect to the remote host.
295 Communication with this process happens through an
296 @value{emacsname} buffer, that is, the output from the remote end
297 goes into a buffer.
298
299 @item
300 The remote host may prompt for a login name (for @command{telnet}).
301 The login name is given in the file name, so @value{tramp} sends the
302 login name and a newline.
303
304 @item
305 The remote host may prompt for a password or pass phrase (for
306 @command{rsh} or for @command{telnet} after sending the login name).
307 @value{tramp} displays the prompt in the minibuffer, asking you for the
308 password or pass phrase.
309
310 You enter the password or pass phrase. @value{tramp} sends it to the remote
311 host, followed by a newline.
312
313 @item
314 @value{tramp} now waits for the shell prompt or for a message that the login
315 failed.
316
317 If @value{tramp} sees neither of them after a certain period of time
318 (a minute, say), then it issues an error message saying that it
319 couldn't find the remote shell prompt and shows you what the remote
320 host has sent.
321
322 If @value{tramp} sees a @samp{login failed} message, it tells you so,
323 aborts the login attempt and allows you to try again.
324
325 @item
326 Suppose that the login was successful and @value{tramp} sees the shell prompt
327 from the remote host. Now @value{tramp} invokes @command{/bin/sh} because
328 Bourne shells and C shells have different command
329 syntaxes.@footnote{Invoking @command{/bin/sh} will fail if your login
330 shell doesn't recognize @samp{exec /bin/sh} as a valid command.
331 Maybe you use the Scheme shell @command{scsh}@dots{}}
332
333 After the Bourne shell has come up, @value{tramp} sends a few commands to
334 ensure a good working environment. It turns off echoing, it sets the
335 shell prompt, and a few other things.
336
337 @item
338 Now the remote shell is up and it good working order. Remember, what
339 was supposed to happen is that @value{tramp} tries to find out what files exist
340 on the remote host so that it can do filename completion.
341
342 So, @value{tramp} basically issues @command{cd} and @command{ls} commands and
343 also sometimes @command{echo} with globbing. Another command that is
344 often used is @command{test} to find out whether a file is writable or a
345 directory or the like. The output of each command is parsed for the
346 necessary operation.
347
348 @item
349 Suppose you are finished with filename completion, have entered @kbd{C-x
350 C-f}, a full file name and hit @kbd{@key{RET}}. Now comes the time to
351 transfer the file contents from the remote host to the local host so
352 that you can edit them.
353
354 See above for an explanation of how @value{tramp} transfers the file contents.
355
356 For inline transfers, @value{tramp} issues a command like @samp{mimencode -b
357 /path/to/remote/file}, waits until the output has accumulated in the
358 buffer that's used for communication, then decodes that output to
359 produce the file contents.
360
361 For external transfers, @value{tramp} issues a command like the
362 following:
363 @example
364 rcp user@@host:/path/to/remote/file /tmp/tramp.4711
365 @end example
366 It then reads the local temporary file @file{/tmp/tramp.4711} into a
367 buffer and deletes the temporary file.
368
369 @item
370 You now edit the buffer contents, blithely unaware of what has happened
371 behind the scenes. (Unless you have read this section, that is.) When
372 you are finished, you type @kbd{C-x C-s} to save the buffer.
373
374 @item
375 Again, @value{tramp} transfers the file contents to the remote host
376 either inline or external. This is the reverse of what happens when
377 reading the file.
378 @end itemize
379
380 I hope this has provided you with a basic overview of what happens
381 behind the scenes when you open a file with @value{tramp}.
382
383
384 @c For the end user
385 @node Obtaining Tramp
386 @chapter Obtaining Tramp.
387 @cindex obtaining Tramp
388
389 @value{tramp} is freely available on the Internet and the latest
390 release may be downloaded from
391 @uref{ftp://ftp.gnu.org/gnu/tramp/}. This release includes the full
392 documentation and code for @value{tramp}, suitable for installation.
393 But GNU Emacs (22 or later) includes @value{tramp} already, and there
394 is a @value{tramp} package for XEmacs, as well. So maybe it is easier
395 to just use those. But if you want the bleeding edge, read
396 on@dots{...}
397
398 For the especially brave, @value{tramp} is available from CVS. The CVS
399 version is the latest version of the code and may contain incomplete
400 features or new issues. Use these versions at your own risk.
401
402 Instructions for obtaining the latest development version of @value{tramp}
403 from CVS can be found by going to the Savannah project page at the
404 following URL and then clicking on the CVS link in the navigation bar
405 at the top.
406
407 @noindent
408 @uref{http://savannah.gnu.org/projects/tramp/}
409
410 @noindent
411 Or follow the example session below:
412
413 @example
414 ] @strong{cd ~/@value{emacsdir}}
415 ] @strong{export CVS_RSH="ssh"}
416 ] @strong{cvs -z3 -d:ext:anoncvs@@savannah.gnu.org:/cvsroot/tramp co tramp}
417 @end example
418
419 @noindent
420 You should now have a directory @file{~/@value{emacsdir}/tramp}
421 containing the latest version of @value{tramp}. You can fetch the latest
422 updates from the repository by issuing the command:
423
424 @example
425 ] @strong{cd ~/@value{emacsdir}/tramp}
426 ] @strong{export CVS_RSH="ssh"}
427 ] @strong{cvs update -d}
428 @end example
429
430 @noindent
431 Once you've got updated files from the CVS repository, you need to run
432 @command{autoconf} in order to get an up-to-date @file{configure}
433 script:
434
435 @example
436 ] @strong{cd ~/@value{emacsdir}/tramp}
437 ] @strong{autoconf}
438 @end example
439
440 People who have no direct CVS access (maybe because sitting behind a
441 blocking firewall), can try the
442 @uref{http://savannah.gnu.org/cvs-backup/tramp-sources.tar.gz, Nightly
443 CVS Tree Tarball} instead of.
444
445
446 @node History
447 @chapter History of @value{tramp}
448 @cindex history
449 @cindex development history
450
451 Development was started end of November 1998. The package was called
452 @file{rssh.el}, back then. It only provided one method to access a
453 file, using @command{ssh} to log in to a remote host and using
454 @command{scp} to transfer the file contents. After a while, the name
455 was changed to @file{rcp.el}, and now it's @value{tramp}. Along the way,
456 many more methods for getting a remote shell and for transferring the
457 file contents were added. Support for VC was added.
458
459 The most recent addition of major features were the multi-hop methods
460 added in April 2000 and the unification of @value{tramp} and Ange-FTP
461 filenames in July 2002. In July 2004, multi-hop methods have been
462 replaced by proxy hosts. Running commands on remote hosts was
463 introduced in December 2005.
464 @ifset emacsgw
465 Support of gateways exists since April 2007.
466 @end ifset
467 @ifset emacsgvfs
468 GVFS integration started in February 2009.
469 @end ifset
470
471 In December 2001, @value{tramp} has been added to the XEmacs package
472 repository. Being part of the GNU Emacs repository happened in June
473 2002, the first release including @value{tramp} was GNU Emacs 22.1.
474
475 @value{tramp} is also a GNU/Linux Debian package since February 2001.
476
477
478 @c Installation chapter is necessary only in case of standalone
479 @c installation. Text taken from trampinst.texi.
480 @ifset installchapter
481 @include trampinst.texi
482 @end ifset
483
484 @node Configuration
485 @chapter Configuring @value{tramp} for use
486 @cindex configuration
487
488 @cindex default configuration
489 @value{tramp} is (normally) fully functional when it is initially
490 installed. It is initially configured to use the @command{scp}
491 program to connect to the remote host. So in the easiest case, you
492 just type @kbd{C-x C-f} and then enter the filename
493 @file{@trampfn{, user, machine, /path/to.file}}.
494
495 On some hosts, there are problems with opening a connection. These are
496 related to the behavior of the remote shell. See @xref{Remote shell
497 setup}, for details on this.
498
499 If you do not wish to use these commands to connect to the remote
500 host, you should change the default connection and transfer method
501 that @value{tramp} uses. There are several different methods that @value{tramp}
502 can use to connect to remote machines and transfer files
503 (@pxref{Connection types}).
504
505 If you don't know which method is right for you, see @xref{Default
506 Method}.
507
508
509 @menu
510 * Connection types:: Types of connections made to remote machines.
511 * Inline methods:: Inline methods.
512 * External methods:: External methods.
513 @ifset emacsgw
514 * Gateway methods:: Gateway methods.
515 @end ifset
516 * Default Method:: Selecting a default method.
517 Here we also try to help those who
518 don't have the foggiest which method
519 is right for them.
520 * Default User:: Selecting a default user.
521 * Default Host:: Selecting a default host.
522 * Multi-hops:: Connecting to a remote host using multiple hops.
523 * Customizing Methods:: Using Non-Standard Methods.
524 * Customizing Completion:: Selecting config files for user/host name completion.
525 * Password handling:: Reusing passwords for several connections.
526 * Connection caching:: Reusing connection related information.
527 * Remote Programs:: How @value{tramp} finds and uses programs on the remote machine.
528 * Remote shell setup:: Remote shell setup hints.
529 * Windows setup hints:: Issues with Cygwin ssh.
530 * Auto-save and Backup:: Auto-save and Backup.
531 @end menu
532
533
534 @node Connection types
535 @section Types of connections made to remote machines.
536 @cindex connection types, overview
537
538 There are two basic types of transfer methods, each with its own
539 advantages and limitations. Both types of connection make use of a
540 remote shell access program such as @command{rsh}, @command{ssh} or
541 @command{telnet} to connect to the remote machine.
542
543 This connection is used to perform many of the operations that @value{tramp}
544 requires to make the remote file system transparently accessible from
545 the local machine. It is only when visiting files that the methods
546 differ.
547
548 @cindex inline methods
549 @cindex external methods
550 @cindex methods, inline
551 @cindex methods, external
552 Loading or saving a remote file requires that the content of the file
553 be transfered between the two machines. The content of the file can
554 be transfered using one of two methods: the @dfn{inline method} over
555 the same connection used to log in to the remote machine, or the
556 @dfn{external method} through another connection using a remote copy
557 program such as @command{rcp}, @command{scp} or @command{rsync}.
558
559 The performance of the external methods is generally better than that
560 of the inline methods, at least for large files. This is caused by
561 the need to encode and decode the data when transferring inline.
562
563 The one exception to this rule are the @command{scp} based transfer
564 methods. While these methods do see better performance when actually
565 transferring files, the overhead of the cryptographic negotiation at
566 startup may drown out the improvement in file transfer times.
567
568 External methods should be configured such a way that they don't
569 require a password (with @command{ssh-agent}, or such alike). Modern
570 @command{scp} implementations offer options to reuse existing
571 @command{ssh} connections, see method @command{scpc}. If it isn't
572 possible, you should consider @ref{Password handling}, otherwise you
573 will be prompted for a password every copy action.
574
575
576 @node Inline methods
577 @section Inline methods
578 @cindex inline methods
579 @cindex methods, inline
580
581 The inline methods in @value{tramp} are quite powerful and can work in
582 situations where you cannot use an external transfer program to connect.
583 Inline methods are the only methods that work when connecting to the
584 remote machine via telnet. (There are also strange inline methods which
585 allow you to transfer files between @emph{user identities} rather than
586 hosts, see below.)
587
588 These methods depend on the existence of a suitable encoding and
589 decoding command on remote machine. Locally, @value{tramp} may be able to
590 use features of @value{emacsname} to decode and encode the files or
591 it may require access to external commands to perform that task.
592
593 @cindex uuencode
594 @cindex mimencode
595 @cindex base-64 encoding
596 @value{tramp} checks the availability and usability of commands like
597 @command{mimencode} (part of the @command{metamail} package) or
598 @command{uuencode} on the remote host. The first reliable command
599 will be used. The search path can be customized, see @ref{Remote
600 Programs}.
601
602 If both commands aren't available on the remote host, @value{tramp}
603 transfers a small piece of Perl code to the remote host, and tries to
604 apply it for encoding and decoding.
605
606
607 @table @asis
608 @item @option{rsh}
609 @cindex method rsh
610 @cindex rsh method
611
612 Connect to the remote host with @command{rsh}. Due to the unsecure
613 connection it is recommended for very local host topology only.
614
615 On operating systems which provide the command @command{remsh} instead
616 of @command{rsh}, you can use the method @option{remsh}. This is true
617 for HP-UX or Cray UNICOS, for example.
618
619
620 @item @option{ssh}
621 @cindex method ssh
622 @cindex ssh method
623
624 Connect to the remote host with @command{ssh}. This is identical to
625 the previous option except that the @command{ssh} package is used,
626 making the connection more secure.
627
628 There are also two variants, @option{ssh1} and @option{ssh2}, that
629 call @samp{ssh -1} and @samp{ssh -2}, respectively. This way, you can
630 explicitly select whether you want to use the SSH protocol version 1
631 or 2 to connect to the remote host. (You can also specify in
632 @file{~/.ssh/config}, the SSH configuration file, which protocol
633 should be used, and use the regular @option{ssh} method.)
634
635 Two other variants, @option{ssh1_old} and @option{ssh2_old}, use the
636 @command{ssh1} and @command{ssh2} commands explicitly. If you don't
637 know what these are, you do not need these options.
638
639 All the methods based on @command{ssh} have an additional kludgy
640 feature: you can specify a host name which looks like @file{host#42}
641 (the real host name, then a hash sign, then a port number). This
642 means to connect to the given host but to also pass @code{-p 42} as
643 arguments to the @command{ssh} command.
644
645
646 @item @option{telnet}
647 @cindex method telnet
648 @cindex telnet method
649
650 Connect to the remote host with @command{telnet}. This is as unsecure
651 as the @option{rsh} method.
652
653
654 @item @option{su}
655 @cindex method su
656 @cindex su method
657
658 This method does not connect to a remote host at all, rather it uses
659 the @command{su} program to allow you to edit files as another user.
660 That means, the specified host name in the file name must be either
661 @samp{localhost} or the host name as returned by the function
662 @command{(system-name)}. For an exception of this rule see
663 @ref{Multi-hops}.
664
665
666 @item @option{sudo}
667 @cindex method sudo
668 @cindex sudo method
669
670 This is similar to the @option{su} method, but it uses @command{sudo}
671 rather than @command{su} to become a different user.
672
673 Note that @command{sudo} must be configured to allow you to start a
674 shell as the user. It would be nice if it was sufficient if
675 @command{ls} and @command{mimencode} were allowed, but that is not
676 easy to implement, so I haven't got around to it, yet.
677
678
679 @item @option{sshx}
680 @cindex method sshx
681 @cindex sshx method
682
683 As you would expect, this is similar to @option{ssh}, only a little
684 different. Whereas @option{ssh} opens a normal interactive shell on
685 the remote host, this option uses @samp{ssh -t -t @var{host} -l
686 @var{user} /bin/sh} to open a connection. This is useful for users
687 where the normal login shell is set up to ask them a number of
688 questions when logging in. This procedure avoids these questions, and
689 just gives @value{tramp} a more-or-less `standard' login shell to work
690 with.
691
692 Note that this procedure does not eliminate questions asked by
693 @command{ssh} itself. For example, @command{ssh} might ask ``Are you
694 sure you want to continue connecting?'' if the host key of the remote
695 host is not known. @value{tramp} does not know how to deal with such a
696 question (yet), therefore you will need to make sure that you can log
697 in without such questions.
698
699 This is also useful for Windows users where @command{ssh}, when
700 invoked from an @value{emacsname} buffer, tells them that it is not
701 allocating a pseudo tty. When this happens, the login shell is wont
702 to not print any shell prompt, which confuses @value{tramp} mightily.
703 For reasons unknown, some Windows ports for @command{ssh} require the
704 doubled @samp{-t} option.
705
706 This supports the @samp{-p} argument.
707
708
709 @item @option{krlogin}
710 @cindex method krlogin
711 @cindex krlogin method
712 @cindex Kerberos (with krlogin method)
713
714 This method is also similar to @option{ssh}. It only uses the
715 @command{krlogin -x} command to log in to the remote host.
716
717
718 @item @option{plink}
719 @cindex method plink
720 @cindex plink method
721
722 This method is mostly interesting for Windows users using the PuTTY
723 implementation of SSH. It uses @samp{plink -ssh} to log in to the
724 remote host.
725
726 This supports the @samp{-P} argument.
727
728 Additionally, the methods @option{plink1} and @option{plink2} are
729 provided, which call @samp{plink -1 -ssh} or @samp{plink -2 -ssh} in
730 order to use SSH protocol version 1 or 2 explicitly.
731
732 CCC: Do we have to connect to the remote host once from the command
733 line to accept the SSH key? Maybe this can be made automatic?
734
735 CCC: Say something about the first shell command failing. This might
736 be due to a wrong setting of @code{tramp-rsh-end-of-line}.
737
738
739 @item @option{plinkx}
740 @cindex method plinkx
741 @cindex plinkx method
742
743 Another method using PuTTY on Windows. Instead of host names, it
744 expects PuTTY session names, calling @samp{plink -load @var{session}
745 -t"}. User names are relevant only in case the corresponding session
746 hasn't defined a user name. Different port numbers must be defined in
747 the session.
748
749
750 @item @option{fish}
751 @cindex method fish
752 @cindex fish method
753
754 This is an experimental implementation of the fish protocol, known from
755 the GNU Midnight Commander or the KDE Konqueror. @value{tramp} expects
756 the fish server implementation from the KDE kioslave. That means, the
757 file @file{~/.fishsrv.pl} is expected to reside on the remote host.
758
759 The implementation lacks good performance. The code is offered anyway,
760 maybe somebody can improve the performance.
761
762 @end table
763
764
765 @node External methods
766 @section External methods
767 @cindex methods, external
768 @cindex external methods
769
770 The external methods operate through multiple channels, using the
771 remote shell connection for many actions while delegating file
772 transfers to an external transfer utility.
773
774 This saves the overhead of encoding and decoding that multiplexing the
775 transfer through the one connection has with the inline methods.
776
777 Since external methods need their own overhead opening a new channel,
778 all files which are smaller than @var{tramp-copy-size-limit} are still
779 transferred with the corresponding inline method. It should provide a
780 fair trade-off between both approaches.
781
782 @table @asis
783 @item @option{rcp} --- @command{rsh} and @command{rcp}
784 @cindex method rcp
785 @cindex rcp method
786 @cindex rcp (with rcp method)
787 @cindex rsh (with rcp method)
788
789 This method uses the @command{rsh} and @command{rcp} commands to connect
790 to the remote machine and transfer files. This is probably the fastest
791 connection method available.
792
793 The alternative method @option{remcp} uses the @command{remsh} and
794 @command{rcp} commands. It should be applied on machines where
795 @command{remsh} is used instead of @command{rsh}.
796
797
798 @item @option{scp} --- @command{ssh} and @command{scp}
799 @cindex method scp
800 @cindex scp method
801 @cindex scp (with scp method)
802 @cindex ssh (with scp method)
803
804 Using @command{ssh} to connect to the remote host and @command{scp} to
805 transfer files between the machines is the best method for securely
806 connecting to a remote machine and accessing files.
807
808 The performance of this option is also quite good. It may be slower than
809 the inline methods when you often open and close small files however.
810 The cost of the cryptographic handshake at the start of an @command{scp}
811 session can begin to absorb the advantage that the lack of encoding and
812 decoding presents.
813
814 There are also two variants, @option{scp1} and @option{scp2}, that
815 call @samp{ssh -1} and @samp{ssh -2}, respectively. This way, you can
816 explicitly select whether you want to use the SSH protocol version 1
817 or 2 to connect to the remote host. (You can also specify in
818 @file{~/.ssh/config}, the SSH configuration file, which protocol
819 should be used, and use the regular @option{scp} method.)
820
821 Two other variants, @option{scp1_old} and @option{scp2_old}, use the
822 @command{ssh1} and @command{ssh2} commands explicitly. If you don't
823 know what these are, you do not need these options.
824
825 All the @command{ssh} based methods support the @samp{-p} feature
826 where you can specify a port number to connect to in the host name.
827 For example, the host name @file{host#42} tells @value{tramp} to
828 specify @samp{-p 42} in the argument list for @command{ssh}, and to
829 specify @samp{-P 42} in the argument list for @command{scp}.
830
831
832 @item @option{sftp} --- @command{ssh} and @command{sftp}
833 @cindex method sftp
834 @cindex sftp method
835 @cindex sftp (with sftp method)
836 @cindex ssh (with sftp method)
837
838 That is mostly the same method as @option{scp}, but using
839 @command{sftp} as transfer command. So the same remarks are valid.
840
841 This command does not work like @value{ftppackagename}, where
842 @command{ftp} is called interactively, and all commands are send from
843 within this session. Instead of, @command{ssh} is used for login.
844
845 This method supports the @samp{-p} argument.
846
847
848 @item @option{rsync} --- @command{ssh} and @command{rsync}
849 @cindex method rsync
850 @cindex rsync method
851 @cindex rsync (with rsync method)
852 @cindex ssh (with rsync method)
853
854 Using the @command{ssh} command to connect securely to the remote
855 machine and the @command{rsync} command to transfer files is almost
856 identical to the @option{scp} method.
857
858 While @command{rsync} performs much better than @command{scp} when
859 transferring files that exist on both hosts, this advantage is lost if
860 the file exists only on one side of the connection. A file can exists
861 on both the remote and local host, when you copy a file from/to a
862 remote host. When you just open a file from the remote host (or write
863 a file there), this is not the case, because on the local side
864 temporary files are used.
865
866 This method supports the @samp{-p} argument.
867
868
869 @item @option{scpx} --- @command{ssh} and @command{scp}
870 @cindex method scpx
871 @cindex scpx method
872 @cindex scp (with scpx method)
873 @cindex ssh (with scpx method)
874
875 As you would expect, this is similar to @option{scp}, only a little
876 different. Whereas @option{scp} opens a normal interactive shell on
877 the remote host, this option uses @samp{ssh -t -t @var{host} -l
878 @var{user} /bin/sh} to open a connection. This is useful for users
879 where the normal login shell is set up to ask them a number of
880 questions when logging in. This procedure avoids these questions, and
881 just gives @value{tramp} a more-or-less `standard' login shell to work
882 with.
883
884 This is also useful for Windows users where @command{ssh}, when
885 invoked from an @value{emacsname} buffer, tells them that it is not
886 allocating a pseudo tty. When this happens, the login shell is wont
887 to not print any shell prompt, which confuses @value{tramp} mightily.
888
889 This method supports the @samp{-p} argument.
890
891
892 @item @option{scpc} --- @command{ssh} and @command{scp}
893 @cindex method scpx
894 @cindex scpx method
895 @cindex scp (with scpx method)
896 @cindex ssh (with scpx method)
897
898 Newer versions of @option{ssh} (for example OpenSSH 4) offer an option
899 @option{ControlMaster}. This allows @option{scp} to reuse an existing
900 @option{ssh} channel, which increases performance.
901
902 Before you use this method, you shall check whether your @option{ssh}
903 implementation does support this option. Try from the command line
904
905 @example
906 ssh localhost -o ControlMaster=yes
907 @end example
908
909 This method supports the @samp{-p} argument.
910
911
912 @item @option{pscp} --- @command{plink} and @command{pscp}
913 @cindex method pscp
914 @cindex pscp method
915 @cindex pscp (with pscp method)
916 @cindex plink (with pscp method)
917 @cindex PuTTY (with pscp method)
918
919 This method is similar to @option{scp}, but it uses the
920 @command{plink} command to connect to the remote host, and it uses
921 @command{pscp} for transferring the files. These programs are part
922 of PuTTY, an SSH implementation for Windows.
923
924 This method supports the @samp{-P} argument.
925
926
927 @item @option{psftp} --- @command{plink} and @command{psftp}
928 @cindex method psftp
929 @cindex psftp method
930 @cindex psftp (with psftp method)
931 @cindex plink (with psftp method)
932 @cindex PuTTY (with psftp method)
933
934 As you would expect, this method is similar to @option{sftp}, but it
935 uses the @command{plink} command to connect to the remote host, and it
936 uses @command{psftp} for transferring the files. These programs are
937 part of PuTTY, an SSH implementation for Windows.
938
939 This method supports the @samp{-P} argument.
940
941
942 @item @option{fcp} --- @command{fsh} and @command{fcp}
943 @cindex method fcp
944 @cindex fcp method
945 @cindex fsh (with fcp method)
946 @cindex fcp (with fcp method)
947
948 This method is similar to @option{scp}, but it uses the @command{fsh}
949 command to connect to the remote host, and it uses @command{fcp} for
950 transferring the files. @command{fsh/fcp} are a front-end for
951 @command{ssh} which allow for reusing the same @command{ssh} session
952 for submitting several commands. This avoids the startup overhead of
953 @command{scp} (which has to establish a secure connection whenever it
954 is called). Note, however, that you can also use one of the inline
955 methods to achieve a similar effect.
956
957 This method uses the command @samp{fsh @var{host} -l @var{user}
958 /bin/sh -i} to establish the connection, it does not work to just say
959 @command{fsh @var{host} -l @var{user}}.
960
961 @cindex method fsh
962 @cindex fsh method
963
964 There is no inline method using @command{fsh} as the multiplexing
965 provided by the program is not very useful in our context. @value{tramp}
966 opens just one connection to the remote host and then keeps it open,
967 anyway.
968
969
970 @item @option{ftp}
971 @cindex method ftp
972 @cindex ftp method
973
974 This is not a native @value{tramp} method. Instead of, it forwards all
975 requests to @value{ftppackagename}.
976 @ifset xemacs
977 This works only for unified filenames, see @ref{Issues}.
978 @end ifset
979
980
981 @item @option{smb} --- @command{smbclient}
982 @cindex method smb
983 @cindex smb method
984
985 This is another not natural @value{tramp} method. It uses the
986 @command{smbclient} command on different Unices in order to connect to
987 an SMB server. An SMB server might be a Samba (or CIFS) server on
988 another UNIX host or, more interesting, a host running MS Windows. So
989 far, it is tested towards MS Windows NT, MS Windows 2000, and MS
990 Windows XP.
991
992 The first directory in the localname must be a share name on the remote
993 host. Remember, that the @code{$} character in which default shares
994 usually end, must be written @code{$$} due to environment variable
995 substitution in file names. If no share name is given (i.e. remote
996 directory @code{/}), all available shares are listed.
997
998 Since authorization is done on share level, you will be prompted
999 always for a password if you access another share on the same host.
1000 This can be suppressed by @ref{Password handling}.
1001
1002 MS Windows uses for authorization both a user name and a domain name.
1003 Because of this, the @value{tramp} syntax has been extended: you can
1004 specify a user name which looks like @code{user%domain} (the real user
1005 name, then a percent sign, then the domain name). So, to connect to
1006 the machine @code{melancholia} as user @code{daniel} of the domain
1007 @code{BIZARRE}, and edit @file{.emacs} in the home directory (share
1008 @code{daniel$}) I would specify the filename @file{@trampfn{smb,
1009 daniel%BIZARRE, melancholia, /daniel$$/.emacs}}.
1010
1011 Depending on the Windows domain configuration, a Windows user might be
1012 considered as domain user per default. In order to connect as local
1013 user, the WINS name of that machine must be given as domain name.
1014 Usually, it is the machine name in capital letters. In the example
1015 above, the local user @code{daniel} would be specified as
1016 @file{@trampfn{smb, daniel%MELANCHOLIA, melancholia, /daniel$$/.emacs}}.
1017
1018 The domain name as well as the user name are optional. If no user
1019 name is specified at all, the anonymous user (without password
1020 prompting) is assumed. This is different from all other @value{tramp}
1021 methods, where in such a case the local user name is taken.
1022
1023 The @option{smb} method supports the @samp{-p} argument.
1024
1025 @strong{Please note:} If @value{emacsname} runs locally under MS
1026 Windows, this method isn't available. Instead of, you can use UNC
1027 file names like @file{//melancholia/daniel$$/.emacs}. The only
1028 disadvantage is that there's no possibility to specify another user
1029 name.
1030
1031 @ifset emacsgvfs
1032 @item @option{dav}
1033 @cindex method dav
1034 @cindex dav method
1035
1036 This method provides access to WebDAV files and directories. It is
1037 available on systems only which run GVFS
1038 @uref{http://en.wikipedia.org/wiki/GVFS}. Via GVFS, the remote
1039 filesystem is mounted locally through FUSE. @value{tramp} uses
1040 internally this local mounted directory.
1041
1042 The communication with GVFS is implemented via D-Bus messages.
1043 Therefore, your @value{emacsname} must have D-Bus integration.
1044
1045 There exists also the external method @option{davs}, which uses SSL
1046 encryption for the access.
1047
1048 Both methods support the port number specification as discussed above.
1049
1050 @item @option{obex}
1051 @cindex method obex
1052 @cindex obex method
1053
1054 OBEX is an FTP-like access protocol for simple devices, like cell
1055 phones. Like @option{dav} and @option{davs}, it uses GVFS for
1056 mounting remote files and directories via FUSE. Until now
1057 @value{tramp} supports only OBEX over Bluetooth.
1058
1059 @item @option{synce}
1060 @cindex method synce
1061 @cindex synce method
1062
1063 SYNCE allows communication with Windows Mobile devices. Beside GVFS
1064 for mounting remote files and directories via FUSE, it needs also the
1065 SYNCE-GVFS plugin.
1066 @end ifset
1067 @end table
1068
1069 @ifset emacsgvfs
1070 @defopt tramp-gvfs-methods
1071 This customer option, a list, defines the external methods, which
1072 shall be used with GVFS. Per default, these are @option{dav},
1073 @option{davs}, @option{obex} and @option{synce}. Other possible
1074 values are @option{ftp}, @option{sftp} and @option{smb}.
1075 @end defopt
1076 @end ifset
1077
1078
1079 @ifset emacsgw
1080 @node Gateway methods
1081 @section Gateway methods
1082 @cindex methods, gateway
1083 @cindex gateway methods
1084
1085 Gateway methods are not methods to access a remote host directly.
1086 These methods are intended to pass firewalls or proxy servers.
1087 Therefore, they can be used for proxy host declarations
1088 (@pxref{Multi-hops}) only.
1089
1090 A gateway method must come always along with a method who supports
1091 port setting. This is because @value{tramp} targets the accompanied
1092 method to @file{localhost#random_port}, from where the firewall or
1093 proxy server is accessed to.
1094
1095 Gateway methods support user name and password declarations. These
1096 are used to authenticate towards the corresponding firewall or proxy
1097 server. They can be passed only if your friendly administrator has
1098 granted your access.
1099
1100 @table @asis
1101 @item @option{tunnel}
1102 @cindex method tunnel
1103 @cindex tunnel method
1104
1105 This method implements an HTTP tunnel via the @command{CONNECT}
1106 command (see RFC 2616, 2817). Any HTTP 1.1 compliant (proxy) server
1107 shall support this command.
1108
1109 As authentication method, only @option{Basic Authentication} (see RFC
1110 2617) is implemented so far. If no port number is given in the
1111 declaration, port @option{8080} is used for the proxy server.
1112
1113
1114 @item @option{socks}
1115 @cindex method socks
1116 @cindex socks method
1117
1118 The @command{socks} method provides access to SOCKSv5 servers (see
1119 RFC 1928). @option{Username/Password Authentication} according to RFC
1120 1929 is supported.
1121
1122 The default port number of the socks server is @option{1080}, if not
1123 specified otherwise.
1124
1125 @end table
1126 @end ifset
1127
1128
1129 @node Default Method
1130 @section Selecting a default method
1131 @cindex default method
1132
1133 @vindex tramp-default-method
1134 When you select an appropriate transfer method for your typical usage
1135 you should set the variable @code{tramp-default-method} to reflect that
1136 choice. This variable controls which method will be used when a method
1137 is not specified in the @value{tramp} file name. For example:
1138
1139 @lisp
1140 (setq tramp-default-method "ssh")
1141 @end lisp
1142
1143 @vindex tramp-default-method-alist
1144 You can also specify different methods for certain user/host
1145 combinations, via the variable @code{tramp-default-method-alist}. For
1146 example, the following two lines specify to use the @option{ssh}
1147 method for all user names matching @samp{john} and the @option{rsync}
1148 method for all host names matching @samp{lily}. The third line
1149 specifies to use the @option{su} method for the user @samp{root} on
1150 the machine @samp{localhost}.
1151
1152 @lisp
1153 (add-to-list 'tramp-default-method-alist '("" "john" "ssh"))
1154 (add-to-list 'tramp-default-method-alist '("lily" "" "rsync"))
1155 (add-to-list 'tramp-default-method-alist
1156 '("\\`localhost\\'" "\\`root\\'" "su"))
1157 @end lisp
1158
1159 @noindent
1160 See the documentation for the variable
1161 @code{tramp-default-method-alist} for more details.
1162
1163 External methods are normally preferable to inline methods, giving
1164 better performance.
1165
1166 @xref{Inline methods}.
1167 @xref{External methods}.
1168
1169 Another consideration with the selection of transfer methods is the
1170 environment you will use them in and, especially when used over the
1171 Internet, the security implications of your preferred method.
1172
1173 The @option{rsh} and @option{telnet} methods send your password as
1174 plain text as you log in to the remote machine, as well as
1175 transferring the files in such a way that the content can easily be
1176 read from other machines.
1177
1178 If you need to connect to remote systems that are accessible from the
1179 Internet, you should give serious thought to using @option{ssh} based
1180 methods to connect. These provide a much higher level of security,
1181 making it a non-trivial exercise for someone to obtain your password
1182 or read the content of the files you are editing.
1183
1184
1185 @subsection Which method is the right one for me?
1186 @cindex choosing the right method
1187
1188 Given all of the above, you are probably thinking that this is all fine
1189 and good, but it's not helping you to choose a method! Right you are.
1190 As a developer, we don't want to boss our users around but give them
1191 maximum freedom instead. However, the reality is that some users would
1192 like to have some guidance, so here I'll try to give you this guidance
1193 without bossing you around. You tell me whether it works @dots{}
1194
1195 My suggestion is to use an inline method. For large files, external
1196 methods might be more efficient, but I guess that most people will
1197 want to edit mostly small files.
1198
1199 I guess that these days, most people can access a remote machine by
1200 using @command{ssh}. So I suggest that you use the @option{ssh}
1201 method. So, type @kbd{C-x C-f @trampfn{ssh, root, otherhost,
1202 /etc/motd} @key{RET}} to edit the @file{/etc/motd} file on the other
1203 host.
1204
1205 If you can't use @option{ssh} to log in to the remote host, then
1206 select a method that uses a program that works. For instance, Windows
1207 users might like the @option{plink} method which uses the PuTTY
1208 implementation of @command{ssh}. Or you use Kerberos and thus like
1209 @option{krlogin}.
1210
1211 For the special case of editing files on the local host as another
1212 user, see the @option{su} or @option{sudo} methods. They offer
1213 shortened syntax for the @samp{root} account, like
1214 @file{@trampfn{su, , , /etc/motd}}.
1215
1216 People who edit large files may want to consider @option{scpc} instead
1217 of @option{ssh}, or @option{pscp} instead of @option{plink}. These
1218 external methods are faster than inline methods for large files.
1219 Note, however, that external methods suffer from some limitations.
1220 Please try first whether you really get a noticeable speed advantage
1221 from using an external method! Maybe even for large files, inline
1222 methods are fast enough.
1223
1224
1225 @node Default User
1226 @section Selecting a default user
1227 @cindex default user
1228
1229 The user part of a @value{tramp} file name can be omitted. Usually,
1230 it is replaced by the user name you are logged in. Often, this is not
1231 what you want. A typical use of @value{tramp} might be to edit some
1232 files with root permissions on the local host. This case, you should
1233 set the variable @code{tramp-default-user} to reflect that choice.
1234 For example:
1235
1236 @lisp
1237 (setq tramp-default-user "root")
1238 @end lisp
1239
1240 @code{tramp-default-user} is regarded as obsolete, and will be removed
1241 soon.
1242
1243 @vindex tramp-default-user-alist
1244 You can also specify different users for certain method/host
1245 combinations, via the variable @code{tramp-default-user-alist}. For
1246 example, if you always have to use the user @samp{john} in the domain
1247 @samp{somewhere.else}, you can specify the following:
1248
1249 @lisp
1250 (add-to-list 'tramp-default-user-alist
1251 '("ssh" ".*\\.somewhere\\.else\\'" "john"))
1252 @end lisp
1253
1254 @noindent
1255 See the documentation for the variable
1256 @code{tramp-default-user-alist} for more details.
1257
1258 One trap to fall in must be known. If @value{tramp} finds a default
1259 user, this user will be passed always to the connection command as
1260 parameter (for example @samp{ssh here.somewhere.else -l john}. If you
1261 have specified another user for your command in its configuration
1262 files, @value{tramp} cannot know it, and the remote access will fail.
1263 If you have specified in the given example in @file{~/.ssh/config} the
1264 lines
1265
1266 @example
1267 Host here.somewhere.else
1268 User lily
1269 @end example
1270
1271 @noindent
1272 than you must discard selecting a default user by @value{tramp}. This
1273 will be done by setting it to @code{nil} (or @samp{lily}, likewise):
1274
1275 @lisp
1276 (add-to-list 'tramp-default-user-alist
1277 '("ssh" "\\`here\\.somewhere\\.else\\'" nil))
1278 @end lisp
1279
1280 The last entry in @code{tramp-default-user-alist} could be your
1281 default user you'll apply predominantly. You shall @emph{append} it
1282 to that list at the end:
1283
1284 @lisp
1285 (add-to-list 'tramp-default-user-alist '(nil nil "jonas") t)
1286 @end lisp
1287
1288
1289 @node Default Host
1290 @section Selecting a default host
1291 @cindex default host
1292
1293 @vindex tramp-default-host
1294 Finally, it is even possible to omit the host name part of a
1295 @value{tramp} file name. This case, the value of the variable
1296 @code{tramp-default-host} is used. Per default, it is initialized
1297 with the host name your local @value{emacsname} is running.
1298
1299 If you, for example, use @value{tramp} mainly to contact the host
1300 @samp{target} as user @samp{john}, you can specify:
1301
1302 @lisp
1303 (setq tramp-default-user "john"
1304 tramp-default-host "target")
1305 @end lisp
1306
1307 Then the simple file name @samp{@trampfn{ssh, , ,}} will connect you
1308 to John's home directory on target.
1309 @ifset emacs
1310 Note, however, that the most simplification @samp{/::} won't work,
1311 because @samp{/:} is the prefix for quoted file names.
1312 @end ifset
1313
1314
1315 @node Multi-hops
1316 @section Connecting to a remote host using multiple hops
1317 @cindex multi-hop
1318 @cindex proxy hosts
1319
1320 Sometimes, the methods described before are not sufficient. Sometimes,
1321 it is not possible to connect to a remote host using a simple command.
1322 For example, if you are in a secured network, you might have to log in
1323 to a `bastion host' first before you can connect to the outside world.
1324 Of course, the target host may also require a bastion host.
1325
1326 @vindex tramp-default-proxies-alist
1327 In order to specify such multiple hops, it is possible to define a proxy
1328 host to pass through, via the variable
1329 @code{tramp-default-proxies-alist}. This variable keeps a list of
1330 triples (@var{host} @var{user} @var{proxy}).
1331
1332 The first matching item specifies the proxy host to be passed for a
1333 file name located on a remote target matching @var{user}@@@var{host}.
1334 @var{host} and @var{user} are regular expressions or @code{nil}, which
1335 is interpreted as a regular expression which always matches.
1336
1337 @var{proxy} must be a Tramp filename which localname part is ignored.
1338 Method and user name on @var{proxy} are optional, which is interpreted
1339 with the default values.
1340 @ifset emacsgw
1341 The method must be an inline or gateway method (@pxref{Inline
1342 methods}, @pxref{Gateway methods}).
1343 @end ifset
1344 @ifclear emacsgw
1345 The method must be an inline method (@pxref{Inline methods}).
1346 @end ifclear
1347 If @var{proxy} is @code{nil}, no additional hop is required reaching
1348 @var{user}@@@var{host}.
1349
1350 If you, for example, must pass the host @samp{bastion.your.domain} as
1351 user @samp{bird} for any remote host which is not located in your local
1352 domain, you can set
1353
1354 @lisp
1355 (add-to-list 'tramp-default-proxies-alist
1356 '("\\." nil "@trampfn{ssh, bird, bastion.your.domain,}"))
1357 (add-to-list 'tramp-default-proxies-alist
1358 '("\\.your\\.domain\\'" nil nil))
1359 @end lisp
1360
1361 Please note the order of the code. @code{add-to-list} adds elements at the
1362 beginning of a list. Therefore, most relevant rules must be added last.
1363
1364 Proxy hosts can be cascaded. If there is another host called
1365 @samp{jump.your.domain}, which is the only one in your local domain who
1366 is allowed connecting @samp{bastion.your.domain}, you can add another
1367 rule:
1368
1369 @lisp
1370 (add-to-list 'tramp-default-proxies-alist
1371 '("\\`bastion\\.your\\.domain\\'"
1372 "\\`bird\\'"
1373 "@trampfn{ssh, , jump.your.domain,}"))
1374 @end lisp
1375
1376 @var{proxy} can contain the patterns @code{%h} or @code{%u}. These
1377 patterns are replaced by the strings matching @var{host} or
1378 @var{user}, respectively.
1379
1380 If you, for example, wants to work as @samp{root} on hosts in the
1381 domain @samp{your.domain}, but login as @samp{root} is disabled for
1382 non-local access, you might add the following rule:
1383
1384 @lisp
1385 (add-to-list 'tramp-default-proxies-alist
1386 '("\\.your\\.domain\\'" "\\`root\\'" "@trampfn{ssh, , %h,}"))
1387 @end lisp
1388
1389 Opening @file{@trampfn{sudo, , randomhost.your.domain,}} would connect
1390 first @samp{randomhost.your.domain} via @code{ssh} under your account
1391 name, and perform @code{sudo -u root} on that host afterwards. It is
1392 important to know that the given method is applied on the host which
1393 has been reached so far. @code{sudo -u root}, applied on your local
1394 host, wouldn't be useful here.
1395
1396 @var{host}, @var{user} and @var{proxy} can also be Lisp forms. These
1397 forms are evaluated, and must return a string, or @code{nil}. The
1398 previous example could be generalized then: For all hosts except my
1399 local one connect via @code{ssh} first, and apply @code{sudo -u root}
1400 afterwards:
1401
1402 @lisp
1403 (add-to-list 'tramp-default-proxies-alist
1404 '(nil "\\`root\\'" "@trampfn{ssh, , %h,}"))
1405 (add-to-list 'tramp-default-proxies-alist
1406 '((regexp-quote (system-name)) nil nil))
1407 @end lisp
1408
1409 This is the recommended configuration to work as @samp{root} on remote
1410 Ubuntu hosts.
1411
1412 @ifset emacsgw
1413 Finally, @code{tramp-default-proxies-alist} can be used to pass
1414 firewalls or proxy servers. Imagine your local network has a host
1415 @samp{proxy.your.domain} which is used on port 3128 as HTTP proxy to
1416 the outer world. Your friendly administrator has granted you access
1417 under your user name to @samp{host.other.domain} on that proxy
1418 server.@footnote{HTTP tunnels are intended for secure SSL/TLS
1419 communication. Therefore, many proxy server restrict the tunnels to
1420 related target ports. You might need to run your ssh server on your
1421 target host @samp{host.other.domain} on such a port, like 443 (https).
1422 See @uref{http://savannah.gnu.org/maintenance/CvsFromBehindFirewall}
1423 for discussion of ethical issues.} You would need to add the
1424 following rule:
1425
1426 @lisp
1427 (add-to-list 'tramp-default-proxies-alist
1428 '("\\`host\\.other\\.domain\\'" nil
1429 "@trampfn{tunnel, , proxy.your.domain#3128,}"))
1430 @end lisp
1431
1432 Gateway methods can be declared as first hop only in a multiple hop
1433 chain.
1434 @end ifset
1435
1436
1437 @node Customizing Methods
1438 @section Using Non-Standard Methods
1439 @cindex customizing methods
1440 @cindex using non-standard methods
1441 @cindex create your own methods
1442
1443 There is a variable @code{tramp-methods} which you can change if the
1444 predefined methods don't seem right.
1445
1446 For the time being, I'll refer you to the Lisp documentation of that
1447 variable, accessible with @kbd{C-h v tramp-methods @key{RET}}.
1448
1449
1450 @node Customizing Completion
1451 @section Selecting config files for user/host name completion
1452 @cindex customizing completion
1453 @cindex selecting config files
1454 @vindex tramp-completion-function-alist
1455
1456 The variable @code{tramp-completion-function-alist} is intended to
1457 customize which files are taken into account for user and host name
1458 completion (@pxref{Filename completion}). For every method, it keeps
1459 a set of configuration files, accompanied by a Lisp function able to
1460 parse that file. Entries in @code{tramp-completion-function-alist}
1461 have the form (@var{method} @var{pair1} @var{pair2} ...).
1462
1463 Each @var{pair} is composed of (@var{function} @var{file}).
1464 @var{function} is responsible to extract user names and host names
1465 from @var{file} for completion. There are two functions which access
1466 this variable:
1467
1468 @defun tramp-get-completion-function method
1469 This function returns the list of completion functions for @var{method}.
1470
1471 Example:
1472 @example
1473 (tramp-get-completion-function "rsh")
1474
1475 @result{} ((tramp-parse-rhosts "/etc/hosts.equiv")
1476 (tramp-parse-rhosts "~/.rhosts"))
1477 @end example
1478 @end defun
1479
1480 @defun tramp-set-completion-function method function-list
1481 This function sets @var{function-list} as list of completion functions
1482 for @var{method}.
1483
1484 Example:
1485 @example
1486 (tramp-set-completion-function "ssh"
1487 '((tramp-parse-sconfig "/etc/ssh_config")
1488 (tramp-parse-sconfig "~/.ssh/config")))
1489
1490 @result{} ((tramp-parse-sconfig "/etc/ssh_config")
1491 (tramp-parse-sconfig "~/.ssh/config"))
1492 @end example
1493 @end defun
1494
1495 The following predefined functions parsing configuration files exist:
1496
1497 @table @asis
1498 @item @code{tramp-parse-rhosts}
1499 @findex tramp-parse-rhosts
1500
1501 This function parses files which are syntactical equivalent to
1502 @file{~/.rhosts}. It returns both host names and user names, if
1503 specified.
1504
1505 @item @code{tramp-parse-shosts}
1506 @findex tramp-parse-shosts
1507
1508 This function parses files which are syntactical equivalent to
1509 @file{~/.ssh/known_hosts}. Since there are no user names specified
1510 in such files, it can return host names only.
1511
1512 @item @code{tramp-parse-sconfig}
1513 @findex tramp-parse-shosts
1514
1515 This function returns the host nicknames defined by @code{Host} entries
1516 in @file{~/.ssh/config} style files.
1517
1518 @item @code{tramp-parse-shostkeys}
1519 @findex tramp-parse-shostkeys
1520
1521 SSH2 parsing of directories @file{/etc/ssh2/hostkeys/*} and
1522 @file{~/ssh2/hostkeys/*}. Hosts are coded in file names
1523 @file{hostkey_@var{portnumber}_@var{host-name}.pub}. User names
1524 are always @code{nil}.
1525
1526 @item @code{tramp-parse-sknownhosts}
1527 @findex tramp-parse-shostkeys
1528
1529 Another SSH2 style parsing of directories like
1530 @file{/etc/ssh2/knownhosts/*} and @file{~/ssh2/knownhosts/*}. This
1531 case, hosts names are coded in file names
1532 @file{@var{host-name}.@var{algorithm}.pub}. User names are always @code{nil}.
1533
1534 @item @code{tramp-parse-hosts}
1535 @findex tramp-parse-hosts
1536
1537 A function dedicated to @file{/etc/hosts} style files. It returns
1538 host names only.
1539
1540 @item @code{tramp-parse-passwd}
1541 @findex tramp-parse-passwd
1542
1543 A function which parses @file{/etc/passwd} like files. Obviously, it
1544 can return user names only.
1545
1546 @item @code{tramp-parse-netrc}
1547 @findex tramp-parse-netrc
1548
1549 Finally, a function which parses @file{~/.netrc} like files.
1550 @end table
1551
1552 If you want to keep your own data in a file, with your own structure,
1553 you might provide such a function as well. This function must meet
1554 the following conventions:
1555
1556 @defun my-tramp-parse file
1557 @var{file} must be either a file name on your host, or @code{nil}.
1558 The function must return a list of (@var{user} @var{host}), which are
1559 taken as candidates for user and host name completion.
1560
1561 Example:
1562 @example
1563 (my-tramp-parse "~/.my-tramp-hosts")
1564
1565 @result{} ((nil "toto") ("daniel" "melancholia"))
1566 @end example
1567 @end defun
1568
1569
1570 @node Password handling
1571 @section Reusing passwords for several connections.
1572 @cindex passwords
1573
1574 Sometimes it is necessary to connect to the same remote host several
1575 times. Reentering passwords again and again would be annoying, when
1576 the chosen method does not support access without password prompt
1577 through own configuration.
1578
1579 The best recommendation is to use the method's own mechanism for
1580 password handling. Consider @command{ssh-agent} for @option{ssh}-like
1581 methods, or @command{pageant} for @option{plink}-like methods.
1582
1583 However, if you cannot apply such native password handling,
1584 @value{tramp} offers altenatives.
1585
1586
1587 @anchor{auth-sources}
1588 @subsection Using an authentication file
1589
1590 @vindex auth-sources
1591 The package @file{auth-source.el}, originally developed in No Gnus,
1592 offers the possibility to read passwords from a file, like FTP does it
1593 from @file{~/.netrc}. The default authentication file is
1594 @file{~/.authinfo.gpg}, this can be changed via the variable
1595 @code{auth-sources}.
1596
1597 @noindent
1598 A typical entry in the authentication file would be
1599
1600 @example
1601 machine melancholia port scp login daniel password geheim
1602 @end example
1603
1604 The port can be any @value{tramp} method (@pxref{Inline methods},
1605 @pxref{External methods}), to match only this method. When you omit
1606 the port, you match all @value{tramp} methods.
1607
1608
1609 @anchor{password-cache}
1610 @subsection Caching passwords
1611
1612 If there is no authentication file, @value{tramp} caches the passwords
1613 entered by you. They will be reused next time if a connection needs
1614 them for the same user name and host name, independently of the
1615 connection method.
1616
1617 @vindex password-cache-expiry
1618 Passwords are not saved permanently, that means the password caching
1619 is limited to the lifetime of your @value{emacsname} session. You
1620 can influence the lifetime of password caching by customizing the
1621 variable @code{password-cache-expiry}. The value is the number of
1622 seconds how long passwords are cached. Setting it to @code{nil}
1623 disables the expiration.
1624
1625 @vindex password-cache
1626 If you don't like this feature for security reasons, password caching
1627 can be disabled totally by customizing the variable
1628 @code{password-cache} (setting it to @code{nil}).
1629
1630 Implementation Note: password caching is based on the package
1631 @file{password-cache.el}. For the time being, it is activated only
1632 when this package is seen in the @code{load-path} while loading
1633 @value{tramp}.
1634 @ifset installchapter
1635 If you don't use No Gnus, you can take @file{password.el} from the
1636 @value{tramp} @file{contrib} directory, see @ref{Installation
1637 parameters}.
1638 @end ifset
1639
1640
1641 @node Connection caching
1642 @section Reusing connection related information.
1643 @cindex caching
1644
1645 @vindex tramp-persistency-file-name
1646 In order to reduce initial connection time, @value{tramp} stores
1647 connection related information persistently. The variable
1648 @code{tramp-persistency-file-name} keeps the file name where these
1649 information are written. Its default value is
1650 @ifset emacs
1651 @file{~/.emacs.d/tramp}.
1652 @end ifset
1653 @ifset xemacs
1654 @file{~/.xemacs/tramp}.
1655 @end ifset
1656 It is recommended to choose a local file name.
1657
1658 @value{tramp} reads this file during startup, and writes it when
1659 exiting @value{emacsname}. You can simply remove this file if
1660 @value{tramp} shall be urged to recompute these information next
1661 @value{emacsname} startup time.
1662
1663 Using such persistent information can be disabled by setting
1664 @code{tramp-persistency-file-name} to @code{nil}.
1665
1666 Once consequence of reusing connection related information is that
1667 @var{tramp} needs to distinguish hosts. If you, for example, run a
1668 local @code{sshd} on port 3001, which tunnels @command{ssh} to another
1669 host, you could access both @file{@trampfn{ssh, , localhost,}} and
1670 @file{@trampfn{ssh, , localhost#3001,}}. @var{tramp} would use the
1671 same host related information (like paths, Perl variants, etc) for
1672 both connections, although the information is valid only for one of
1673 them.
1674
1675 In order to avoid trouble, you must use another host name for one of
1676 the connections, like introducing a @option{Host} section in
1677 @file{~/.ssh/config} (@pxref{Frequently Asked Questions}) or applying
1678 multiple hops (@pxref{Multi-hops}).
1679
1680 When @value{tramp} detects a changed operating system version on a
1681 remote host (via the command @command{uname -sr}), it flushes all
1682 connection related information for this host, and opens the
1683 connection, again.
1684
1685
1686 @node Remote Programs
1687 @section How @value{tramp} finds and uses programs on the remote machine.
1688
1689 @value{tramp} depends on a number of programs on the remote host in order to
1690 function, including @command{ls}, @command{test}, @command{find} and
1691 @command{cat}.
1692
1693 In addition to these required tools, there are various tools that may be
1694 required based on the connection method. See @ref{Inline methods} and
1695 @ref{External methods} for details on these.
1696
1697 Certain other tools, such as @command{perl} (or @command{perl5}) and
1698 @command{grep} will be used if they can be found. When they are
1699 available, they are used to improve the performance and accuracy of
1700 remote file access.
1701
1702 @vindex tramp-remote-path
1703 @vindex tramp-default-remote-path
1704 @vindex tramp-own-remote-path
1705 @defopt tramp-remote-path
1706 When @value{tramp} connects to the remote machine, it searches for the
1707 programs that it can use. The variable @code{tramp-remote-path}
1708 controls the directories searched on the remote machine.
1709
1710 By default, this is set to a reasonable set of defaults for most
1711 machines. The symbol @code{tramp-default-remote-path} is a place
1712 holder, it is replaced by the list of directories received via the
1713 command @command{getconf PATH} on your remote machine. For example,
1714 on GNU Debian this is @file{/bin:/usr/bin}, whereas on Solaris this is
1715 @file{/usr/xpg4/bin:/usr/ccs/bin:/usr/bin:/opt/SUNWspro/bin}. It is
1716 recommended to apply this symbol on top of @code{tramp-remote-path}.
1717
1718 It is possible, however, that your local (or remote ;) system
1719 administrator has put the tools you want in some obscure local
1720 directory.
1721
1722 In this case, you can still use them with @value{tramp}. You simply
1723 need to add code to your @file{.emacs} to add the directory to the
1724 remote path. This will then be searched by @value{tramp} when you
1725 connect and the software found.
1726
1727 To add a directory to the remote search path, you could use code such
1728 as:
1729
1730 @lisp
1731 @i{;; We load @value{tramp} to define the variable.}
1732 (require 'tramp)
1733 @i{;; We have @command{perl} in "/usr/local/perl/bin"}
1734 (add-to-list 'tramp-remote-path "/usr/local/perl/bin")
1735 @end lisp
1736
1737 Another possibility is to reuse the path settings of your remote
1738 account, when you log in. Usually, these settings are overwritten,
1739 because they might not be useful for @value{tramp}. The place holder
1740 @code{tramp-own-remote-path} preserves these settings. You can
1741 activate it via
1742
1743 @lisp
1744 (add-to-list 'tramp-remote-path 'tramp-own-remote-path)
1745 @end lisp
1746 @end defopt
1747
1748 @value{tramp} caches several information, like the Perl binary
1749 location. The changed remote search path wouldn't affect these
1750 settings. In order to force @value{tramp} to recompute these values,
1751 you must exit @value{emacsname}, remove your persistency file
1752 (@pxref{Connection caching}), and restart @value{emacsname}.
1753
1754
1755 @node Remote shell setup
1756 @section Remote shell setup hints
1757 @cindex remote shell setup
1758 @cindex @file{.profile} file
1759 @cindex @file{.login} file
1760 @cindex shell init files
1761
1762 As explained in the @ref{Overview} section, @value{tramp} connects to the
1763 remote host and talks to the shell it finds there. Of course, when you
1764 log in, the shell executes its init files. Suppose your init file
1765 requires you to enter the birth date of your mother; clearly @value{tramp}
1766 does not know this and hence fails to log you in to that host.
1767
1768 There are different possible strategies for pursuing this problem. One
1769 strategy is to enable @value{tramp} to deal with all possible situations.
1770 This is a losing battle, since it is not possible to deal with
1771 @emph{all} situations. The other strategy is to require you to set up
1772 the remote host such that it behaves like @value{tramp} expects. This might
1773 be inconvenient because you have to invest a lot of effort into shell
1774 setup before you can begin to use @value{tramp}.
1775
1776 The package, therefore, pursues a combined approach. It tries to
1777 figure out some of the more common setups, and only requires you to
1778 avoid really exotic stuff. For example, it looks through a list of
1779 directories to find some programs on the remote host. And also, it
1780 knows that it is not obvious how to check whether a file exists, and
1781 therefore it tries different possibilities. (On some hosts and
1782 shells, the command @command{test -e} does the trick, on some hosts
1783 the shell builtin doesn't work but the program @command{/usr/bin/test
1784 -e} or @command{/bin/test -e} works. And on still other hosts,
1785 @command{ls -d} is the right way to do this.)
1786
1787 Below you find a discussion of a few things that @value{tramp} does not deal
1788 with, and that you therefore have to set up correctly.
1789
1790 @table @asis
1791 @item @var{shell-prompt-pattern}
1792 @vindex shell-prompt-pattern
1793
1794 After logging in to the remote host, @value{tramp} has to wait for the remote
1795 shell startup to finish before it can send commands to the remote
1796 shell. The strategy here is to wait for the shell prompt. In order to
1797 recognize the shell prompt, the variable @code{shell-prompt-pattern} has
1798 to be set correctly to recognize the shell prompt on the remote host.
1799
1800 Note that @value{tramp} requires the match for @code{shell-prompt-pattern}
1801 to be at the end of the buffer. Many people have something like the
1802 following as the value for the variable: @code{"^[^>$][>$] *"}. Now
1803 suppose your shell prompt is @code{a <b> c $ }. In this case,
1804 @value{tramp} recognizes the @code{>} character as the end of the prompt,
1805 but it is not at the end of the buffer.
1806
1807 @item @var{tramp-shell-prompt-pattern}
1808 @vindex tramp-shell-prompt-pattern
1809
1810 This regular expression is used by @value{tramp} in the same way as
1811 @code{shell-prompt-pattern}, to match prompts from the remote shell.
1812 This second variable exists because the prompt from the remote shell
1813 might be different from the prompt from a local shell --- after all,
1814 the whole point of @value{tramp} is to log in to remote hosts as a
1815 different user. The default value of
1816 @code{tramp-shell-prompt-pattern} is the same as the default value of
1817 @code{shell-prompt-pattern}, which is reported to work well in many
1818 circumstances.
1819
1820 @item @var{tramp-password-prompt-regexp}
1821 @vindex tramp-password-prompt-regexp
1822 @vindex tramp-wrong-passwd-regexp
1823
1824 During login, @value{tramp} might be forced to enter a password or a
1825 passphrase. The difference between both is that a password is
1826 requested from the shell on the remote host, while a passphrase is
1827 needed for accessing local authentication information, like your ssh
1828 key.
1829
1830 @var{tramp-password-prompt-regexp} handles the detection of such
1831 requests for English environments. When you use another localization
1832 of your (local or remote) host, you might need to adapt this. Example:
1833
1834 @lisp
1835 (setq
1836 tramp-password-prompt-regexp
1837 (concat
1838 "^.*"
1839 (regexp-opt
1840 '("passphrase" "Passphrase"
1841 ;; English
1842 "password" "Password"
1843 ;; Deutsch
1844 "passwort" "Passwort"
1845 ;; Fran@,{c}ais
1846 "mot de passe" "Mot de passe") t)
1847 ".*: