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