(Optional Mode Line): Document the new form of line+column numbers,
[bpt/emacs.git] / man / tramp.texi
1 \input texinfo @c -*-texinfo-*-
2 @c %**start of header
3 @setfilename ../info/tramp
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 Macros for formatting a filename.
21 @c trampfn is for a full filename, trampfnmhp means method, host, localname
22 @c were given, and so on.
23 @macro trampfn(method, user, host, localname)
24 @value{prefix}@value{method}@value{user}@@@value{host}@value{postfix}@value{localname}
25 @end macro
26
27 @copying
28 Copyright @copyright{} 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
29 Free Software Foundation, Inc.
30
31 @quotation
32 Permission is granted to copy, distribute and/or modify this document
33 under the terms of the GNU Free Documentation License, Version 1.2 or
34 any later version published by the Free Software Foundation; with no
35 Invariant Sections, with the Front-Cover texts being ``A GNU
36 Manual'', and with the Back-Cover Texts as in (a) below. A copy of the
37 license is included in the section entitled ``GNU Free Documentation
38 License'' in the Emacs manual.
39
40 (a) The FSF's Back-Cover Text is: ``You have freedom to copy and modify
41 this GNU Manual, like GNU software. Copies published by the Free
42 Software Foundation raise funds for GNU development.''
43
44 This document is part of a collection distributed under the GNU Free
45 Documentation License. If you want to distribute this document
46 separately from the collection, you can do so by adding a copy of the
47 license to the document, as described in section 6 of the license.
48 @end quotation
49 @end copying
50
51 @c Entries for @command{install-info} to use
52 @dircategory @value{emacsname}
53 @direntry
54 * TRAMP: (tramp). Transparent Remote Access, Multiple Protocol
55 @value{emacsname} remote file access via rsh and rcp.
56 @end direntry
57
58 @tex
59
60 @titlepage
61 @title @value{tramp} version @value{trampver} User Manual
62
63 @author by Daniel Pittman
64 @author based on documentation by Kai Gro@ss{}johann
65
66 @page
67 @insertcopying
68
69 @end titlepage
70 @page
71
72 @end tex
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 * Concept Index:: An item for each concept.
155
156 For the developer:
157
158 * Version Control:: The inner workings of remote version control.
159 * Files directories and localnames:: How file names, directories and localnames are mangled and managed.
160 * Issues:: Debatable Issues and What Was Decided.
161
162 * GNU Free Documentation License:: The license for this documentation.
163
164 @detailmenu
165 --- The Detailed Node Listing ---
166 @c
167 @ifset installchapter
168 Installing @value{tramp} with your @value{emacsname}
169
170 * Installation parameters:: Parameters in order to control installation.
171 * Load paths:: How to plug-in @value{tramp} into your environment.
172 * Japanese manual:: Japanese manual.
173
174 @end ifset
175
176 Configuring @value{tramp} for use
177
178 * Connection types:: Types of connections made to remote machines.
179 * Inline methods:: Inline methods.
180 * External transfer methods:: External transfer methods.
181 * Multi-hop Methods:: Connecting to a remote host using multiple hops.
182 * Default Method:: Selecting a default method.
183 * Customizing Methods:: Using Non-Standard Methods.
184 * Customizing Completion:: Selecting config files for user/host name completion.
185 * Password caching:: Reusing passwords for several connections.
186 * Remote Programs:: How @value{tramp} finds and uses programs on the remote machine.
187 * Remote shell setup:: Remote shell setup hints.
188 * Windows setup hints:: Issues with Cygwin ssh.
189 * Auto-save and Backup:: Auto-save and Backup.
190
191 Using @value{tramp}
192
193 * Filename Syntax:: @value{tramp} filename conventions.
194 * Multi-hop filename syntax:: Multi-hop filename conventions.
195 * Filename completion:: Filename completion.
196 * Dired:: Dired.
197 * Compilation:: Compile remote files.
198
199 The inner workings of remote version control
200
201 * Version Controlled Files:: Determining if a file is under version control.
202 * Remote Commands:: Executing the version control commands on the remote machine.
203 * Changed workfiles:: Detecting if the working file has changed.
204 * Checking out files:: Bringing the workfile out of the repository.
205 * Miscellaneous Version Control:: Things related to Version Control that don't fit elsewhere.
206
207 Things related to Version Control that don't fit elsewhere
208
209 * Remote File Ownership:: How VC determines who owns a workfile.
210 * Back-end Versions:: How VC determines what release your RCS is.
211
212 How file names, directories and localnames are mangled and managed
213
214 * Localname deconstruction:: Breaking a localname into its components.
215
216 @end detailmenu
217 @end menu
218
219 @node Overview
220 @chapter An overview of @value{tramp}
221 @cindex overview
222
223 After the installation of @value{tramp} into your @value{emacsname},
224 you will be able to access files on remote machines as though they
225 were local. Access to the remote file system for editing files,
226 version control, and @code{dired} are transparently enabled.
227
228 Your access to the remote machine can be with the @command{rsh},
229 @command{rlogin}, @command{telnet} programs or with any similar
230 connection method. This connection must pass @acronym{ASCII}
231 successfully to be usable but need not be 8-bit clean.
232
233 The package provides support for @command{ssh} connections out of the
234 box, one of the more common uses of the package. This allows
235 relatively secure access to machines, especially if @command{ftp}
236 access is disabled.
237
238 The majority of activity carried out by @value{tramp} requires only that
239 the remote login is possible and is carried out at the terminal. In
240 order to access remote files @value{tramp} needs to transfer their content
241 to the local machine temporarily.
242
243 @value{tramp} can transfer files between the machines in a variety of ways.
244 The details are easy to select, depending on your needs and the
245 machines in question.
246
247 The fastest transfer methods (for large files) rely on a remote file
248 transfer package such as @command{rcp}, @command{scp} or
249 @command{rsync}.
250
251 If the remote copy methods are not suitable for you, @value{tramp} also
252 supports the use of encoded transfers directly through the shell.
253 This requires that the @command{mimencode} or @command{uuencode} tools
254 are available on the remote machine. These methods are generally
255 faster for small files.
256
257 Within these limitations, @value{tramp} is quite powerful. It is worth
258 noting that, as of the time of writing, it is far from a polished
259 end-user product. For a while yet you should expect to run into rough
260 edges and problems with the code now and then.
261
262 It is finished enough that the developers use it for day to day work but
263 the installation and setup can be a little difficult to master, as can
264 the terminology.
265
266 @value{tramp} is still under active development and any problems you encounter,
267 trivial or major, should be reported to the @value{tramp} developers.
268 @xref{Bug Reports}.
269
270
271 @subsubheading Behind the scenes
272 @cindex behind the scenes
273 @cindex details of operation
274 @cindex how it works
275
276 This section tries to explain what goes on behind the scenes when you
277 access a remote file through @value{tramp}.
278
279 Suppose you type @kbd{C-x C-f} and enter part of an @value{tramp} file name,
280 then hit @kbd{@key{TAB}} for completion. Suppose further that this is
281 the first time that @value{tramp} is invoked for the host in question. Here's
282 what happens:
283
284 @itemize
285 @item
286 @value{tramp} discovers that it needs a connection to the host. So it
287 invokes @samp{telnet @var{host}} or @samp{rsh @var{host} -l
288 @var{user}} or a similar tool to connect to the remote host.
289 Communication with this process happens through an
290 @value{emacsname} buffer, that is, the output from the remote end
291 goes into a buffer.
292
293 @item
294 The remote host may prompt for a login name (for @command{telnet}).
295 The login name is given in the file name, so @value{tramp} sends the
296 login name and a newline.
297
298 @item
299 The remote host may prompt for a password or pass phrase (for
300 @command{rsh} or for @command{telnet} after sending the login name).
301 @value{tramp} displays the prompt in the minibuffer, asking you for the
302 password or pass phrase.
303
304 You enter the password or pass phrase. @value{tramp} sends it to the remote
305 host, followed by a newline.
306
307 @item
308 @value{tramp} now waits for the shell prompt or for a message that the login
309 failed.
310
311 If @value{tramp} sees neither of them after a certain period of time (a minute,
312 say), then it issues an error message saying that it couldn't find the
313 remote shell prompt and shows you what the remote host has sent.
314
315 If @value{tramp} sees a @samp{login failed} message, it tells you so,
316 aborts the login attempt and allows you to try again.
317
318 @item
319 Suppose that the login was successful and @value{tramp} sees the shell prompt
320 from the remote host. Now @value{tramp} invokes @command{/bin/sh} because
321 Bourne shells and C shells have different command
322 syntaxes.@footnote{Invoking @command{/bin/sh} will fail if your login
323 shell doesn't recognize @samp{exec /bin/sh} as a valid command.
324 Maybe you use the Scheme shell @command{scsh}@dots{}}
325
326 After the Bourne shell has come up, @value{tramp} sends a few commands to
327 ensure a good working environment. It turns off echoing, it sets the
328 shell prompt, and a few other things.
329
330 @item
331 Now the remote shell is up and it good working order. Remember, what
332 was supposed to happen is that @value{tramp} tries to find out what files exist
333 on the remote host so that it can do filename completion.
334
335 So, @value{tramp} basically issues @command{cd} and @command{ls} commands and
336 also sometimes @command{echo} with globbing. Another command that is
337 often used is @command{test} to find out whether a file is writable or a
338 directory or the like. The output of each command is parsed for the
339 necessary operation.
340
341 @item
342 Suppose you are finished with filename completion, have entered @kbd{C-x
343 C-f}, a full file name and hit @kbd{@key{RET}}. Now comes the time to
344 transfer the file contents from the remote host to the local host so
345 that you can edit them.
346
347 See above for an explanation of how @value{tramp} transfers the file contents.
348
349 For inline transfers, @value{tramp} issues a command like @samp{mimencode -b
350 /path/to/remote/file}, waits until the output has accumulated in the
351 buffer that's used for communication, then decodes that output to
352 produce the file contents.
353
354 For out-of-band transfers, @value{tramp} issues a command like the following:
355 @example
356 rcp user@@host:/path/to/remote/file /tmp/tramp.4711
357 @end example
358 It then reads the local temporary file @file{/tmp/tramp.4711} into a
359 buffer and deletes the temporary file.
360
361 @item
362 You now edit the buffer contents, blithely unaware of what has happened
363 behind the scenes. (Unless you have read this section, that is.) When
364 you are finished, you type @kbd{C-x C-s} to save the buffer.
365
366 @item
367 Again, @value{tramp} transfers the file contents to the remote host either
368 inline or out-of-band. This is the reverse of what happens when reading
369 the file.
370 @end itemize
371
372 I hope this has provided you with a basic overview of what happens
373 behind the scenes when you open a file with @value{tramp}.
374
375
376 @c For the end user
377 @node Obtaining Tramp
378 @chapter Obtaining Tramp.
379 @cindex obtaining Tramp
380
381 @value{tramp} is freely available on the Internet and the latest
382 release may be downloaded from
383 @uref{ftp://ftp.gnu.org/gnu/tramp/}. This release includes the full
384 documentation and code for @value{tramp}, suitable for installation.
385 But GNU Emacs (22 or later) includes @value{tramp} already, and there
386 is a @value{tramp} package for XEmacs, as well. So maybe it is easier
387 to just use those. But if you want the bleeding edge, read
388 on@dots{...}
389
390 For the especially brave, @value{tramp} is available from CVS. The CVS
391 version is the latest version of the code and may contain incomplete
392 features or new issues. Use these versions at your own risk.
393
394 Instructions for obtaining the latest development version of @value{tramp}
395 from CVS can be found by going to the Savannah project page at the
396 following URL and then clicking on the CVS link in the navigation bar
397 at the top.
398
399 @noindent
400 @uref{http://savannah.gnu.org/projects/tramp/}
401
402 @noindent
403 Or follow the example session below:
404
405 @example
406 ] @strong{cd ~/@value{emacsdir}}
407 ] @strong{export CVS_RSH="ssh"}
408 ] @strong{cvs -z3 -d:ext:anoncvs@@savannah.gnu.org:/cvsroot/tramp co tramp}
409 @end example
410
411 @noindent
412 You should now have a directory @file{~/@value{emacsdir}/tramp}
413 containing the latest version of @value{tramp}. You can fetch the latest
414 updates from the repository by issuing the command:
415
416 @example
417 ] @strong{cd ~/@value{emacsdir}/tramp}
418 ] @strong{export CVS_RSH="ssh"}
419 ] @strong{cvs update -d}
420 @end example
421
422 @noindent
423 Once you've got updated files from the CVS repository, you need to run
424 @command{autoconf} in order to get an up-to-date @file{configure}
425 script:
426
427 @example
428 ] @strong{cd ~/@value{emacsdir}/tramp}
429 ] @strong{autoconf}
430 @end example
431
432
433 @node History
434 @chapter History of @value{tramp}
435 @cindex history
436 @cindex development history
437
438 Development was started end of November 1998. The package was called
439 @file{rssh.el}, back then. It only provided one method to access a
440 file, using @command{ssh} to log in to a remote host and using
441 @command{scp} to transfer the file contents. After a while, the name
442 was changed to @file{rcp.el}, and now it's @value{tramp}. Along the way,
443 many more methods for getting a remote shell and for transferring the
444 file contents were added. Support for VC was added.
445
446 The most recent addition of major features were the multi-hop methods
447 added in April 2000 and the unification of @value{tramp} and Ange-FTP
448 filenames in July 2002.
449
450 @c Installation chapter is necessary only in case of standalone
451 @c installation. Text taken from trampinst.texi.
452 @ifset installchapter
453 @include trampinst.texi
454 @end ifset
455
456 @node Configuration
457 @chapter Configuring @value{tramp} for use
458 @cindex configuration
459
460 @cindex default configuration
461 @value{tramp} is (normally) fully functional when it is initially
462 installed. It is initially configured to use the @command{scp}
463 program to connect to the remote host. So in the easiest case, you
464 just type @kbd{C-x C-f} and then enter the filename
465 @file{@value{prefix}@var{user}@@@var{machine}@value{postfix}@var{/path/to.file}}.
466
467 On some hosts, there are problems with opening a connection. These are
468 related to the behavior of the remote shell. See @xref{Remote shell
469 setup}, for details on this.
470
471 If you do not wish to use these commands to connect to the remote
472 host, you should change the default connection and transfer method
473 that @value{tramp} uses. There are several different methods that @value{tramp}
474 can use to connect to remote machines and transfer files
475 (@pxref{Connection types}).
476
477 If you don't know which method is right for you, see @xref{Default
478 Method}.
479
480
481 @menu
482 * Connection types:: Types of connections made to remote machines.
483 * Inline methods:: Inline methods.
484 * External transfer methods:: External transfer methods.
485 * Multi-hop Methods:: Connecting to a remote host using multiple hops.
486 * Default Method:: Selecting a default method.
487 Here we also try to help those who
488 don't have the foggiest which method
489 is right for them.
490 * Customizing Methods:: Using Non-Standard Methods.
491 * Customizing Completion:: Selecting config files for user/host name completion.
492 * Password caching:: Reusing passwords for several connections.
493 * Remote Programs:: How @value{tramp} finds and uses programs on the remote machine.
494 * Remote shell setup:: Remote shell setup hints.
495 * Windows setup hints:: Issues with Cygwin ssh.
496 * Auto-save and Backup:: Auto-save and Backup.
497 @end menu
498
499
500 @node Connection types
501 @section Types of connections made to remote machines.
502 @cindex connection types, overview
503
504 There are two basic types of transfer methods, each with its own
505 advantages and limitations. Both types of connection make use of a
506 remote shell access program such as @command{rsh}, @command{ssh} or
507 @command{telnet} to connect to the remote machine.
508
509 This connection is used to perform many of the operations that @value{tramp}
510 requires to make the remote file system transparently accessible from
511 the local machine. It is only when visiting files that the methods
512 differ.
513
514 @cindex inline methods
515 @cindex external transfer methods
516 @cindex external methods
517 @cindex out-of-band methods
518 @cindex methods, inline
519 @cindex methods, external transfer
520 @cindex methods, out-of-band
521 Loading or saving a remote file requires that the content of the file
522 be transfered between the two machines. The content of the file can be
523 transfered over the same connection used to log in to the remote
524 machine or the file can be transfered through another connection using
525 a remote copy program such as @command{rcp}, @command{scp} or
526 @command{rsync}. The former are called @dfn{inline methods}, the
527 latter are called @dfn{out-of-band methods} or @dfn{external transfer
528 methods} (@dfn{external methods} for short).
529
530 The performance of the external transfer methods is generally better
531 than that of the inline methods, at least for large files. This is
532 caused by the need to encode and decode the data when transferring
533 inline.
534
535 The one exception to this rule are the @command{scp} based transfer
536 methods. While these methods do see better performance when actually
537 transferring files, the overhead of the cryptographic negotiation at
538 startup may drown out the improvement in file transfer times.
539
540 External transfer methods should be configured such a way that they
541 don't require a password (with @command{ssh-agent}, or such alike).
542 If it isn't possible, you should consider @ref{Password caching},
543 otherwise you will be prompted for a password every copy action.
544
545 @cindex multi-hop methods
546 @cindex methods, multi-hop
547 A variant of the inline methods are the @dfn{multi-hop methods}.
548 These methods allow you to connect a remote host using a number `hops',
549 each of which connects to a different host. This is useful if you are
550 in a secured network where you need to go through a bastion host to
551 connect to the outside world.
552
553
554 @node Inline methods
555 @section Inline methods
556 @cindex inline methods
557 @cindex methods, inline
558
559 The inline methods in @value{tramp} are quite powerful and can work in
560 situations where you cannot use an external transfer program to connect.
561 Inline methods are the only methods that work when connecting to the
562 remote machine via telnet. (There are also strange inline methods which
563 allow you to transfer files between @emph{user identities} rather than
564 hosts, see below.)
565
566 These methods depend on the existence of a suitable encoding and
567 decoding command on remote machine. Locally, @value{tramp} may be able to
568 use features of @value{emacsname} to decode and encode the files or
569 it may require access to external commands to perform that task.
570
571 @cindex uuencode
572 @cindex mimencode
573 @cindex base-64 encoding
574 @value{tramp} checks the availability and usability of commands like
575 @command{mimencode} (part of the @command{metamail} package) or
576 @command{uuencode} on the remote host. The first reliable command
577 will be used. The search path can be customized, see @ref{Remote
578 Programs}.
579
580 If both commands aren't available on the remote host, @value{tramp}
581 transfers a small piece of Perl code to the remote host, and tries to
582 apply it for encoding and decoding.
583
584
585 @table @asis
586 @item @option{rsh}
587 @cindex method rsh
588 @cindex rsh method
589
590 Connect to the remote host with @command{rsh}. Due to the unsecure
591 connection it is recommended for very local host topology only.
592
593 On operating systems which provide the command @command{remsh} instead
594 of @command{rsh}, you can use the method @option{remsh}. This is true
595 for HP-UX or Cray UNICOS, for example.
596
597
598 @item @option{ssh}
599 @cindex method ssh
600 @cindex ssh method
601
602 Connect to the remote host with @command{ssh}. This is identical to
603 the previous option except that the @command{ssh} package is used,
604 making the connection more secure.
605
606 There are also two variants, @option{ssh1} and @option{ssh2}, that
607 call @samp{ssh -1} and @samp{ssh -2}, respectively. This way, you can
608 explicitly select whether you want to use the SSH protocol version 1
609 or 2 to connect to the remote host. (You can also specify in
610 @file{~/.ssh/config}, the SSH configuration file, which protocol
611 should be used, and use the regular @option{ssh} method.)
612
613 Two other variants, @option{ssh1_old} and @option{ssh2_old}, use the
614 @command{ssh1} and @command{ssh2} commands explicitly. If you don't
615 know what these are, you do not need these options.
616
617 All the methods based on @command{ssh} have an additional kludgy
618 feature: you can specify a host name which looks like @file{host#42}
619 (the real host name, then a hash sign, then a port number). This
620 means to connect to the given host but to also pass @code{-p 42} as
621 arguments to the @command{ssh} command.
622
623
624 @item @option{telnet}
625 @cindex method telnet
626 @cindex telnet method
627
628 Connect to the remote host with @command{telnet}. This is as unsecure
629 as the @option{rsh} method.
630
631
632 @item @option{su}
633 @cindex method su
634 @cindex su method
635
636 This method does not connect to a remote host at all, rather it uses
637 the @command{su} program to allow you to edit files as another user.
638
639
640 @item @option{sudo}
641 @cindex method sudo
642 @cindex sudo method
643
644 This is similar to the @option{su} method, but it uses @command{sudo}
645 rather than @command{su} to become a different user.
646
647 Note that @command{sudo} must be configured to allow you to start a
648 shell as the user. It would be nice if it was sufficient if
649 @command{ls} and @command{mimencode} were allowed, but that is not
650 easy to implement, so I haven't got around to it, yet.
651
652
653 @item @option{sshx}
654 @cindex method sshx
655 @cindex sshx method
656
657 As you would expect, this is similar to @option{ssh}, only a little
658 different. Whereas @option{ssh} opens a normal interactive shell on
659 the remote host, this option uses @samp{ssh -t -t @var{host} -l
660 @var{user} /bin/sh} to open a connection. This is useful for users
661 where the normal login shell is set up to ask them a number of
662 questions when logging in. This procedure avoids these questions, and
663 just gives @value{tramp} a more-or-less `standard' login shell to work
664 with.
665
666 Note that this procedure does not eliminate questions asked by
667 @command{ssh} itself. For example, @command{ssh} might ask ``Are you
668 sure you want to continue connecting?'' if the host key of the remote
669 host is not known. @value{tramp} does not know how to deal with such a
670 question (yet), therefore you will need to make sure that you can log
671 in without such questions.
672
673 This is also useful for Windows users where @command{ssh}, when
674 invoked from an @value{emacsname} buffer, tells them that it is not
675 allocating a pseudo tty. When this happens, the login shell is wont
676 to not print any shell prompt, which confuses @value{tramp} mightily.
677 For reasons unknown, some Windows ports for @command{ssh} require the
678 doubled @samp{-t} option.
679
680 This supports the @samp{-p} kludge.
681
682
683 @item @option{krlogin}
684 @cindex method krlogin
685 @cindex km krlogin
686 @cindex Kerberos (with krlogin method)
687
688 This method is also similar to @option{ssh}. It only uses the
689 @command{krlogin -x} command to log in to the remote host.
690
691
692 @item @option{plink}
693 @cindex method plink
694 @cindex plink method
695
696 This method is mostly interesting for Windows users using the PuTTY
697 implementation of SSH. It uses @samp{plink -ssh} to log in to the
698 remote host.
699
700 Additionally, the method @option{plink1} is provided, which calls
701 @samp{plink -1 -ssh} in order to use SSH protocol version 1
702 explicitly.
703
704 CCC: Do we have to connect to the remote host once from the command
705 line to accept the SSH key? Maybe this can be made automatic?
706
707 CCC: Does @command{plink} support the @samp{-p} option? @value{tramp} will
708 support that, anyway.
709
710 @end table
711
712
713
714 @node External transfer methods
715 @section External transfer methods
716 @cindex methods, external transfer
717 @cindex methods, out-of-band
718 @cindex external transfer methods
719 @cindex out-of-band methods
720
721 The external transfer methods operate through multiple channels, using
722 the remote shell connection for many actions while delegating file
723 transfers to an external transfer utility.
724
725 This saves the overhead of encoding and decoding that multiplexing the
726 transfer through the one connection has with the inline methods.
727
728 If you want to use an external transfer method you should be able to
729 execute the transfer utility to copy files to and from the remote
730 machine without any interaction.
731
732 @cindex ssh-agent
733 This means that you will need to use @command{ssh-agent} if you use the
734 @command{scp} program for transfers, or maybe your version of
735 @command{scp} accepts a password on the command line.@footnote{PuTTY's
736 @command{pscp} allows you to specify the password on the command line.}
737 If you use @command{rsync} via @command{ssh} then the same rule must
738 apply to that connection.
739
740 If you cannot get an external method to run without asking for a
741 password you should consider @ref{Password caching}.
742
743
744 @table @asis
745 @item @option{rcp} --- @command{rsh} and @command{rcp}
746 @cindex method rcp
747 @cindex rcp method
748 @cindex rcp (with rcp method)
749 @cindex rsh (with rcp method)
750
751 This method uses the @command{rsh} and @command{rcp} commands to connect
752 to the remote machine and transfer files. This is probably the fastest
753 connection method available.
754
755 The alternative method @option{remcp} uses the @command{remsh} and
756 @command{rcp} commands. It should be applied on machines where
757 @command{remsh} is used instead of @command{rsh}.
758
759
760 @item @option{scp} --- @command{ssh} and @command{scp}
761 @cindex method scp
762 @cindex scp method
763 @cindex scp (with scp method)
764 @cindex ssh (with scp method)
765
766 Using @command{ssh} to connect to the remote host and @command{scp} to
767 transfer files between the machines is the best method for securely
768 connecting to a remote machine and accessing files.
769
770 The performance of this option is also quite good. It may be slower than
771 the inline methods when you often open and close small files however.
772 The cost of the cryptographic handshake at the start of an @command{scp}
773 session can begin to absorb the advantage that the lack of encoding and
774 decoding presents.
775
776 There are also two variants, @option{scp1} and @option{scp2}, that
777 call @samp{ssh -1} and @samp{ssh -2}, respectively. This way, you can
778 explicitly select whether you want to use the SSH protocol version 1
779 or 2 to connect to the remote host. (You can also specify in
780 @file{~/.ssh/config}, the SSH configuration file, which protocol
781 should be used, and use the regular @option{scp} method.)
782
783 Two other variants, @option{scp1_old} and @option{scp2_old}, use the
784 @command{ssh1} and @command{ssh2} commands explicitly. If you don't
785 know what these are, you do not need these options.
786
787 All the @command{ssh} based methods support the kludgy @samp{-p}
788 feature where you can specify a port number to connect to in the host
789 name. For example, the host name @file{host#42} tells @value{tramp} to
790 specify @samp{-p 42} in the argument list for @command{ssh}.
791
792
793 @item @option{rsync} --- @command{ssh} and @command{rsync}
794 @cindex method rsync
795 @cindex rsync method
796 @cindex rsync (with rsync method)
797 @cindex ssh (with rsync method)
798
799 Using the @command{ssh} command to connect securely to the remote
800 machine and the @command{rsync} command to transfer files is almost
801 identical to the @option{scp} method.
802
803 While @command{rsync} performs much better than @command{scp} when
804 transferring files that exist on both hosts, this advantage is lost if
805 the file exists only on one side of the connection.
806
807 The @command{rsync} based method may be considerably faster than the
808 @command{rcp} based methods when writing to the remote system. Reading
809 files to the local machine is no faster than with a direct copy.
810
811 This method supports the @samp{-p} hack.
812
813
814 @item @option{scpx} --- @command{ssh} and @command{scp}
815 @cindex method scpx
816 @cindex scpx method
817 @cindex scp (with scpx method)
818 @cindex ssh (with scpx method)
819
820 As you would expect, this is similar to @option{scp}, only a little
821 different. Whereas @option{scp} opens a normal interactive shell on
822 the remote host, this option uses @samp{ssh -t -t @var{host} -l
823 @var{user} /bin/sh} to open a connection. This is useful for users
824 where the normal login shell is set up to ask them a number of
825 questions when logging in. This procedure avoids these questions, and
826 just gives @value{tramp} a more-or-less `standard' login shell to work
827 with.
828
829 This is also useful for Windows users where @command{ssh}, when
830 invoked from an @value{emacsname} buffer, tells them that it is not
831 allocating a pseudo tty. When this happens, the login shell is wont
832 to not print any shell prompt, which confuses @value{tramp} mightily.
833
834 This method supports the @samp{-p} hack.
835
836
837 @item @option{scpc} --- @command{ssh} and @command{scp}
838 @cindex method scpx
839 @cindex scpx method
840 @cindex scp (with scpx method)
841 @cindex ssh (with scpx method)
842
843 Newer versions of @option{ssh} (for example OpenSSH 4) offer an option
844 @option{ControlMaster}. This allows @option{scp} to reuse an existing
845 @option{ssh} channel, which increases performance.
846
847 Before you use this method, you shall check whether your @option{ssh}
848 implementation does support this option. Try from the command line
849
850 @example
851 ssh localhost -o ControlMaster=yes
852 @end example
853
854 This method supports the @samp{-p} hack.
855
856
857 @item @option{pscp} --- @command{plink} and @command{pscp}
858 @cindex method pscp
859 @cindex pscp method
860 @cindex pscp (with pscp method)
861 @cindex plink (with pscp method)
862 @cindex PuTTY (with pscp method)
863
864 This method is similar to @option{scp}, but it uses the
865 @command{plink} command to connect to the remote host, and it uses
866 @command{pscp} for transferring the files. These programs are part
867 of PuTTY, an SSH implementation for Windows.
868
869 CCC: Does @command{plink} support the @samp{-p} hack?
870
871
872 @item @option{fcp} --- @command{fsh} and @command{fcp}
873 @cindex method fcp
874 @cindex fcp method
875 @cindex fsh (with fcp method)
876 @cindex fcp (with fcp method)
877
878 This method is similar to @option{scp}, but it uses the @command{fsh}
879 command to connect to the remote host, and it uses @command{fcp} for
880 transferring the files. @command{fsh/fcp} are a front-end for
881 @command{ssh} which allow for reusing the same @command{ssh} session
882 for submitting several commands. This avoids the startup overhead of
883 @command{scp} (which has to establish a secure connection whenever it
884 is called). Note, however, that you can also use one of the inline
885 methods to achieve a similar effect.
886
887 This method uses the command @samp{fsh @var{host} -l @var{user}
888 /bin/sh -i} to establish the connection, it does not work to just say
889 @command{fsh @var{host} -l @var{user}}.
890
891 @cindex method fsh
892 @cindex fsh method
893
894 There is no inline method using @command{fsh} as the multiplexing
895 provided by the program is not very useful in our context. @value{tramp}
896 opens just one connection to the remote host and then keeps it open,
897 anyway.
898
899
900 @item @option{ftp}
901 @cindex method ftp
902 @cindex ftp method
903
904 This is not a native @value{tramp} method. Instead of, it forwards all
905 requests to @value{ftppackagename}.
906 @ifset xemacs
907 This works only for unified filenames, see @ref{Issues}.
908 @end ifset
909
910
911 @item @option{smb} --- @command{smbclient}
912 @cindex method smb
913 @cindex smb method
914
915 This is another not natural @value{tramp} method. It uses the
916 @command{smbclient} command on different Unices in order to connect to
917 an SMB server. An SMB server might be a Samba (or CIFS) server on
918 another UNIX host or, more interesting, a host running MS Windows. So
919 far, it is tested towards MS Windows NT, MS Windows 2000, and MS
920 Windows XP.
921
922 The first directory in the localname must be a share name on the remote
923 host. Remember, that the @code{$} character in which default shares
924 usually end, must be written @code{$$} due to environment variable
925 substitution in file names. If no share name is given (i.e. remote
926 directory @code{/}), all available shares are listed.
927
928 Since authorization is done on share level, you will be prompted
929 always for a password if you access another share on the same host.
930 This can be suppressed by @ref{Password caching}.
931
932 MS Windows uses for authorization both a user name and a domain name.
933 Because of this, the @value{tramp} syntax has been extended: you can
934 specify a user name which looks like @code{user%domain} (the real user
935 name, then a percent sign, then the domain name). So, to connect to
936 the machine @code{melancholia} as user @code{daniel} of the domain
937 @code{BIZARRE}, and edit @file{.emacs} in the home directory (share
938 @code{daniel$}) I would specify the filename
939 @file{@value{prefix}smb@value{postfixsinglehop}daniel%BIZARRE@@melancholia@value{postfix}/daniel$$/.emacs}.
940
941 The domain name as well as the user name are optional. If no user
942 name is specified at all, the anonymous user (without password
943 prompting) is assumed. This is different from all other @value{tramp}
944 methods, where in such a case the local user name is taken.
945
946 The @option{smb} method supports the @samp{-p} hack.
947
948 @strong{Please note:} If @value{emacsname} runs locally under MS
949 Windows, this method isn't available. Instead of, you can use UNC
950 file names like @file{//melancholia/daniel$$/.emacs}. The only
951 disadvantage is that there's no possibility to specify another user
952 name.
953
954 @end table
955
956 @node Multi-hop Methods
957 @section Connecting to a remote host using multiple hops
958 @cindex multi-hop methods
959 @cindex methods, multi-hop
960
961 Sometimes, the methods described before are not sufficient. Sometimes,
962 it is not possible to connect to a remote host using a simple command.
963 For example, if you are in a secured network, you might have to log in
964 to a `bastion host' first before you can connect to the outside world.
965 Of course, the target host may also require a bastion host. The format
966 of multi-hop filenames is slightly different than the format of normal
967 @value{tramp} methods.
968
969 @cindex method multi
970 @cindex multi method
971 A multi-hop file name specifies a method, a number of hops, and a
972 localname (path name on the remote system). The method name is always
973 @option{multi}.
974
975 Each hop consists of a @dfn{hop method} specification, a user name and
976 a host name. The hop method can be an inline method only. The
977 following hop methods are (currently) available:
978
979 @table @option
980 @item telnet
981 @cindex hop method telnet
982 @cindex telnet hop method
983
984 Uses the well-known @command{telnet} program to connect to the host.
985 Whereas user name and host name are supplied in the file name, the
986 user is queried for the password.
987
988 @item rsh
989 @cindex hop method rsh
990 @cindex rsh hop method
991
992 This uses @command{rsh} to connect to the host. You do not need to
993 enter a password unless @command{rsh} explicitly asks for it.
994
995 The variant @option{remsh} uses the @command{remsh} command. It
996 should be applied on machines where @command{remsh} is used instead of
997 @command{rsh}.
998
999 @item ssh
1000 @cindex hop method ssh
1001 @cindex ssh hop method
1002
1003 This uses @command{ssh} to connect to the host. You might have to enter
1004 a password or a pass phrase.
1005
1006 @item su
1007 @cindex hop method su
1008 @cindex su hop method
1009
1010 This method does not actually contact a different host, but it allows
1011 you to become a different user on the host you're currently on. This
1012 might be useful if you want to edit files as root, but the remote host
1013 does not allow remote root logins. In this case you can use
1014 @option{telnet}, @option{rsh} or @option{ssh} to connect to the
1015 remote host as a non-root user, then use an @option{su} hop to become
1016 root. But @option{su} need not be the last hop in a sequence, you could
1017 also use it somewhere in the middle, if the need arises.
1018
1019 Even though you @emph{must} specify both user and host with an
1020 @option{su} hop, the host name is ignored and only the user name is
1021 used.
1022
1023 @item sudo
1024 @cindex hop method sudo
1025 @cindex sudo hop method
1026
1027 This is similar to the @option{su} hop, except that it uses
1028 @command{sudo} rather than @command{su} to become a different user.
1029
1030 @end table
1031
1032 Some people might wish to use port forwarding with @command{ssh} or
1033 maybe they have to use a nonstandard port. This can be accomplished
1034 by putting a stanza in @file{~/.ssh/config} for the account which
1035 specifies a different port number for a certain host name. But it can
1036 also be accomplished within @value{tramp}, by adding a multi-hop method.
1037 For example:
1038
1039 @lisp
1040 (add-to-list
1041 'tramp-multi-connection-function-alist
1042 '("sshf" tramp-multi-connect-rlogin "ssh %h -l %u -p 4400%n"))
1043 @end lisp
1044
1045 Now you can use an @option{sshf} hop which connects to port 4400 instead of
1046 the standard port.
1047
1048
1049 @node Default Method
1050 @section Selecting a default method
1051 @cindex default method
1052
1053 @vindex tramp-default-method
1054 When you select an appropriate transfer method for your typical usage
1055 you should set the variable @code{tramp-default-method} to reflect that
1056 choice. This variable controls which method will be used when a method
1057 is not specified in the @value{tramp} file name. For example:
1058
1059 @lisp
1060 (setq tramp-default-method "ssh")
1061 @end lisp
1062
1063 @vindex tramp-default-method-alist
1064 You can also specify different methods for certain user/host
1065 combinations, via the variable @code{tramp-default-method-alist}. For
1066 example, the following two lines specify to use the @option{ssh}
1067 method for all user names matching @samp{john} and the @option{rsync}
1068 method for all host names matching @samp{lily}. The third line
1069 specifies to use the @option{su} method for the user @samp{root} on
1070 the machine @samp{localhost}.
1071
1072 @lisp
1073 (add-to-list 'tramp-default-method-alist '("" "john" "ssh"))
1074 (add-to-list 'tramp-default-method-alist '("lily" "" "rsync"))
1075 (add-to-list 'tramp-default-method-alist
1076 '("\\`localhost\\'" "\\`root\\'" "su"))
1077 @end lisp
1078
1079 @noindent
1080 See the documentation for the variable
1081 @code{tramp-default-method-alist} for more details.
1082
1083 External transfer methods are normally preferable to inline transfer
1084 methods, giving better performance.
1085
1086 @xref{Inline methods}.
1087 @xref{External transfer methods}.
1088 @xref{Multi-hop Methods}.
1089
1090 Another consideration with the selection of transfer methods is the
1091 environment you will use them in and, especially when used over the
1092 Internet, the security implications of your preferred method.
1093
1094 The @option{rsh} and @option{telnet} methods send your password as
1095 plain text as you log in to the remote machine, as well as
1096 transferring the files in such a way that the content can easily be
1097 read from other machines.
1098
1099 If you need to connect to remote systems that are accessible from the
1100 Internet, you should give serious thought to using @option{ssh} based
1101 methods to connect. These provide a much higher level of security,
1102 making it a non-trivial exercise for someone to obtain your password
1103 or read the content of the files you are editing.
1104
1105
1106 @subsection Which method is the right one for me?
1107 @cindex choosing the right method
1108
1109 Given all of the above, you are probably thinking that this is all fine
1110 and good, but it's not helping you to choose a method! Right you are.
1111 As a developer, we don't want to boss our users around but give them
1112 maximum freedom instead. However, the reality is that some users would
1113 like to have some guidance, so here I'll try to give you this guidance
1114 without bossing you around. You tell me whether it works @dots{}
1115
1116 My suggestion is to use an inline method. For large files, out-of-band
1117 methods might be more efficient, but I guess that most people will want
1118 to edit mostly small files.
1119
1120 I guess that these days, most people can access a remote machine by
1121 using @command{ssh}. So I suggest that you use the @option{ssh}
1122 method. So, type @kbd{C-x C-f
1123 @value{prefix}ssh@value{postfixsinglehop}root@@otherhost@value{postfix}/etc/motd
1124 @key{RET}} to edit the @file{/etc/motd} file on the other host.
1125
1126 If you can't use @option{ssh} to log in to the remote host, then
1127 select a method that uses a program that works. For instance, Windows
1128 users might like the @option{plink} method which uses the PuTTY
1129 implementation of @command{ssh}. Or you use Kerberos and thus like
1130 @option{krlogin}.
1131
1132 For the special case of editing files on the local host as another
1133 user, see the @option{su} or @option{sudo} methods. They offer
1134 shortened syntax for the @samp{root} account, like
1135 @file{@value{prefix}su@value{postfixsinglehop}@value{postfix}/etc/motd}.
1136
1137 People who edit large files may want to consider @option{scp} instead
1138 of @option{ssh}, or @option{pscp} instead of @option{plink}. These
1139 out-of-band methods are faster than inline methods for large files.
1140 Note, however, that out-of-band methods suffer from some limitations.
1141 Please try first whether you really get a noticeable speed advantage
1142 from using an out-of-band method! Maybe even for large files, inline
1143 methods are fast enough.
1144
1145
1146 @node Customizing Methods
1147 @section Using Non-Standard Methods
1148 @cindex customizing methods
1149 @cindex using non-standard methods
1150 @cindex create your own methods
1151
1152 There is a variable @code{tramp-methods} which you can change if the
1153 predefined methods don't seem right.
1154
1155 For the time being, I'll refer you to the Lisp documentation of that
1156 variable, accessible with @kbd{C-h v tramp-methods @key{RET}}.
1157
1158
1159 @node Customizing Completion
1160 @section Selecting config files for user/host name completion
1161 @cindex customizing completion
1162 @cindex selecting config files
1163 @vindex tramp-completion-function-alist
1164
1165 The variable @code{tramp-completion-function-alist} is intended to
1166 customize which files are taken into account for user and host name
1167 completion (@pxref{Filename completion}). For every method, it keeps
1168 a set of configuration files, accompanied by a Lisp function able to
1169 parse that file. Entries in @code{tramp-completion-function-alist}
1170 have the form (@var{method} @var{pair1} @var{pair2} ...).
1171
1172 Each @var{pair} is composed of (@var{function} @var{file}).
1173 @var{function} is responsible to extract user names and host names
1174 from @var{file} for completion. There are two functions which access
1175 this variable:
1176
1177 @defun tramp-get-completion-function method
1178 This function returns the list of completion functions for @var{method}.
1179
1180 Example:
1181 @example
1182 (tramp-get-completion-function "rsh")
1183
1184 @result{} ((tramp-parse-rhosts "/etc/hosts.equiv")
1185 (tramp-parse-rhosts "~/.rhosts"))
1186 @end example
1187 @end defun
1188
1189 @defun tramp-set-completion-function method function-list
1190 This function sets @var{function-list} as list of completion functions
1191 for @var{method}.
1192
1193 Example:
1194 @example
1195 (tramp-set-completion-function "ssh"
1196 '((tramp-parse-sconfig "/etc/ssh_config")
1197 (tramp-parse-sconfig "~/.ssh/config")))
1198
1199 @result{} ((tramp-parse-sconfig "/etc/ssh_config")
1200 (tramp-parse-sconfig "~/.ssh/config"))
1201 @end example
1202 @end defun
1203
1204 The following predefined functions parsing configuration files exist:
1205
1206 @table @asis
1207 @item @code{tramp-parse-rhosts}
1208 @findex tramp-parse-rhosts
1209
1210 This function parses files which are syntactical equivalent to
1211 @file{~/.rhosts}. It returns both host names and user names, if
1212 specified.
1213
1214 @item @code{tramp-parse-shosts}
1215 @findex tramp-parse-shosts
1216
1217 This function parses files which are syntactical equivalent to
1218 @file{~/.ssh/known_hosts}. Since there are no user names specified
1219 in such files, it can return host names only.
1220
1221 @item @code{tramp-parse-sconfig}
1222 @findex tramp-parse-shosts
1223
1224 This function returns the host nicknames defined by @code{Host} entries
1225 in @file{~/.ssh/config} style files.
1226
1227 @item @code{tramp-parse-shostkeys}
1228 @findex tramp-parse-shostkeys
1229
1230 SSH2 parsing of directories @file{/etc/ssh2/hostkeys/*} and
1231 @file{~/ssh2/hostkeys/*}. Hosts are coded in file names
1232 @file{hostkey_@var{portnumber}_@var{host-name}.pub}. User names
1233 are always @code{nil}.
1234
1235 @item @code{tramp-parse-sknownhosts}
1236 @findex tramp-parse-shostkeys
1237
1238 Another SSH2 style parsing of directories like
1239 @file{/etc/ssh2/knownhosts/*} and @file{~/ssh2/knownhosts/*}. This
1240 case, hosts names are coded in file names
1241 @file{@var{host-name}.@var{algorithm}.pub}. User names are always @code{nil}.
1242
1243 @item @code{tramp-parse-hosts}
1244 @findex tramp-parse-hosts
1245
1246 A function dedicated to @file{/etc/hosts} style files. It returns
1247 host names only.
1248
1249 @item @code{tramp-parse-passwd}
1250 @findex tramp-parse-passwd
1251
1252 A function which parses @file{/etc/passwd} like files. Obviously, it
1253 can return user names only.
1254
1255 @item @code{tramp-parse-netrc}
1256 @findex tramp-parse-netrc
1257
1258 Finally, a function which parses @file{~/.netrc} like files.
1259 @end table
1260
1261 If you want to keep your own data in a file, with your own structure,
1262 you might provide such a function as well. This function must meet
1263 the following conventions:
1264
1265 @defun my-tramp-parse file
1266 @var{file} must be either a file name on your host, or @code{nil}. The
1267 function must return a list of (@var{user} @var{host}), which are
1268 taken as candidates for user and host name completion.
1269
1270 Example:
1271 @example
1272 (my-tramp-parse "~/.my-tramp-hosts")
1273
1274 @result{} ((nil "toto") ("daniel" "melancholia"))
1275 @end example
1276 @end defun
1277
1278
1279 @node Password caching
1280 @section Reusing passwords for several connections.
1281 @cindex passwords
1282
1283 Sometimes it is necessary to connect to the same remote host several
1284 times. Reentering passwords again and again would be annoying, when
1285 the chosen method does not support access without password prompt
1286 through own configuration.
1287
1288 By default, @value{tramp} caches the passwords entered by you. They will
1289 be reused next time if a connection needs them for the same user name
1290 and host name, independently of the connection method.
1291
1292 @vindex password-cache-expiry
1293 Passwords are not saved permanently, that means the password caching
1294 is limited to the lifetime of your @value{emacsname} session. You
1295 can influence the lifetime of password caching by customizing the
1296 variable @code{password-cache-expiry}. The value is the number of
1297 seconds how long passwords are cached. Setting it to @code{nil}
1298 disables the expiration.
1299
1300 @findex tramp-clear-passwd
1301 A password is removed from the cache if a connection isn't established
1302 successfully. You can remove a password from the cache also by
1303 executing @kbd{M-x tramp-clear-passwd} in a buffer containing a
1304 related remote file or directory.
1305
1306 @vindex password-cache
1307 If you don't like this feature for security reasons, password caching
1308 can be disabled totally by customizing the variable
1309 @code{password-cache} (setting it to @code{nil}).
1310
1311 Implementation Note: password caching is based on the package
1312 password.el in No Gnus. For the time being, it is activated only when
1313 this package is seen in the @code{load-path} while loading @value{tramp}.
1314 @ifset installchapter
1315 If you don't use No Gnus, you can take password.el from the @value{tramp}
1316 @file{contrib} directory, see @ref{Installation parameters}.
1317 @end ifset
1318 It will be activated mandatory once No Gnus has found its way into
1319 @value{emacsname}.
1320
1321
1322 @node Remote Programs
1323 @section How @value{tramp} finds and uses programs on the remote machine.
1324
1325 @value{tramp} depends on a number of programs on the remote host in order to
1326 function, including @command{ls}, @command{test}, @command{find} and
1327 @command{cat}.
1328
1329 In addition to these required tools, there are various tools that may be
1330 required based on the connection method. See @ref{Inline methods} and
1331 @ref{External transfer methods} for details on these.
1332
1333 Certain other tools, such as @command{perl} (or @command{perl5}) and
1334 @command{grep} will be used if they can be found. When they are
1335 available, they are used to improve the performance and accuracy of
1336 remote file access.
1337
1338 @vindex tramp-remote-path
1339 When @value{tramp} connects to the remote machine, it searches for the
1340 programs that it can use. The variable @var{tramp-remote-path} controls
1341 the directories searched on the remote machine.
1342
1343 By default, this is set to a reasonable set of defaults for most
1344 machines. It is possible, however, that your local (or remote ;) system
1345 administrator has put the tools you want in some obscure local
1346 directory.
1347
1348 In this case, you can still use them with @value{tramp}. You simply need to
1349 add code to your @file{.emacs} to add the directory to the remote path.
1350 This will then be searched by @value{tramp} when you connect and the software
1351 found.
1352
1353 To add a directory to the remote search path, you could use code such
1354 as:
1355
1356 @lisp
1357 @i{;; We load @value{tramp} to define the variable.}
1358 (require 'tramp)
1359 @i{;; We have @command{perl} in "/usr/local/perl/bin"}
1360 (add-to-list 'tramp-remote-path "/usr/local/perl/bin")
1361 @end lisp
1362
1363
1364 @node Remote shell setup
1365 @comment node-name, next, previous, up
1366 @section Remote shell setup hints
1367 @cindex remote shell setup
1368 @cindex @file{.profile} file
1369 @cindex @file{.login} file
1370 @cindex shell init files
1371
1372 As explained in the @ref{Overview} section, @value{tramp} connects to the
1373 remote host and talks to the shell it finds there. Of course, when you
1374 log in, the shell executes its init files. Suppose your init file
1375 requires you to enter the birth date of your mother; clearly @value{tramp}
1376 does not know this and hence fails to log you in to that host.
1377
1378 There are different possible strategies for pursuing this problem. One
1379 strategy is to enable @value{tramp} to deal with all possible situations.
1380 This is a losing battle, since it is not possible to deal with
1381 @emph{all} situations. The other strategy is to require you to set up
1382 the remote host such that it behaves like @value{tramp} expects. This might
1383 be inconvenient because you have to invest a lot of effort into shell
1384 setup before you can begin to use @value{tramp}.
1385
1386 The package, therefore, pursues a combined approach. It tries to
1387 figure out some of the more common setups, and only requires you to
1388 avoid really exotic stuff. For example, it looks through a list of
1389 directories to find some programs on the remote host. And also, it
1390 knows that it is not obvious how to check whether a file exists, and
1391 therefore it tries different possibilities. (On some hosts and
1392 shells, the command @command{test -e} does the trick, on some hosts
1393 the shell builtin doesn't work but the program @command{/usr/bin/test
1394 -e} or @command{/bin/test -e} works. And on still other hosts,
1395 @command{ls -d} is the right way to do this.)
1396
1397 Below you find a discussion of a few things that @value{tramp} does not deal
1398 with, and that you therefore have to set up correctly.
1399
1400 @table @asis
1401 @item @var{shell-prompt-pattern}
1402 @vindex shell-prompt-pattern
1403
1404 After logging in to the remote host, @value{tramp} has to wait for the remote
1405 shell startup to finish before it can send commands to the remote
1406 shell. The strategy here is to wait for the shell prompt. In order to
1407 recognize the shell prompt, the variable @code{shell-prompt-pattern} has
1408 to be set correctly to recognize the shell prompt on the remote host.
1409
1410 Note that @value{tramp} requires the match for @code{shell-prompt-pattern}
1411 to be at the end of the buffer. Many people have something like the
1412 following as the value for the variable: @code{"^[^>$][>$] *"}. Now
1413 suppose your shell prompt is @code{a <b> c $ }. In this case,
1414 @value{tramp} recognizes the @code{>} character as the end of the prompt,
1415 but it is not at the end of the buffer.
1416
1417 @item @var{tramp-shell-prompt-pattern}
1418 @vindex tramp-shell-prompt-pattern
1419
1420 This regular expression is used by @value{tramp} in the same way as
1421 @code{shell-prompt-pattern}, to match prompts from the remote shell.
1422 This second variable exists because the prompt from the remote shell
1423 might be different from the prompt from a local shell --- after all,
1424 the whole point of @value{tramp} is to log in to remote hosts as a
1425 different user. The default value of
1426 @code{tramp-shell-prompt-pattern} is the same as the default value of
1427 @code{shell-prompt-pattern}, which is reported to work well in many
1428 circumstances.
1429
1430 @item @command{tset} and other questions
1431 @cindex Unix command tset
1432 @cindex tset Unix command
1433
1434 Some people invoke the @command{tset} program from their shell startup
1435 scripts which asks the user about the terminal type of the shell.
1436 Maybe some shells ask other questions when they are started. @value{tramp}
1437 does not know how to answer these questions. There are two approaches
1438 for dealing with this problem. One approach is to take care that the
1439 shell does not ask any questions when invoked from @value{tramp}. You can
1440 do this by checking the @code{TERM} environment variable, it will be
1441 set to @code{dumb} when connecting.
1442
1443 @vindex tramp-terminal-type
1444 The variable @code{tramp-terminal-type} can be used to change this value
1445 to @code{dumb}.
1446
1447 The other approach is to teach @value{tramp} about these questions. See
1448 the variables @code{tramp-actions-before-shell} and
1449 @code{tramp-multi-actions} (for multi-hop connections).
1450
1451
1452 @item Environment variables named like users in @file{.profile}
1453
1454 If you have a user named frumple and set the variable @code{FRUMPLE} in
1455 your shell environment, then this might cause trouble. Maybe rename
1456 the variable to @code{FRUMPLE_DIR} or the like.
1457
1458 This weird effect was actually reported by a @value{tramp} user!
1459
1460
1461 @item Non-Bourne commands in @file{.profile}
1462
1463 After logging in to the remote host, @value{tramp} issues the command
1464 @command{exec /bin/sh}. (Actually, the command is slightly
1465 different.) When @command{/bin/sh} is executed, it reads some init
1466 files, such as @file{~/.shrc} or @file{~/.profile}.
1467
1468 Now, some people have a login shell which is not @code{/bin/sh} but a
1469 Bourne-ish shell such as bash or ksh. Some of these people might put
1470 their shell setup into the files @file{~/.shrc} or @file{~/.profile}.
1471 This way, it is possible for non-Bourne constructs to end up in those
1472 files. Then, @command{exec /bin/sh} might cause the Bourne shell to
1473 barf on those constructs.
1474
1475 As an example, imagine somebody putting @command{export FOO=bar} into
1476 the file @file{~/.profile}. The standard Bourne shell does not
1477 understand this syntax and will emit a syntax error when it reaches
1478 this line.
1479
1480 Another example is the tilde (@code{~}) character, say when adding
1481 @file{~/bin} to @code{$PATH}. Many Bourne shells will not expand this
1482 character, and since there is usually no directory whose name consists
1483 of the single character tilde, strange things will happen.
1484
1485 What can you do about this?
1486
1487 Well, one possibility is to make sure that everything in @file{~/.shrc}
1488 and @file{~/.profile} on all remote hosts is Bourne-compatible. In the
1489 above example, instead of @command{export FOO=bar}, you might use
1490 @command{FOO=bar; export FOO} instead.
1491
1492 The other possibility is to put your non-Bourne shell setup into some
1493 other files. For example, bash reads the file @file{~/.bash_profile}
1494 instead of @file{~/.profile}, if the former exists. So bash
1495 aficionados just rename their @file{~/.profile} to
1496 @file{~/.bash_profile} on all remote hosts, and Bob's your uncle.
1497
1498 The @value{tramp} developers would like to circumvent this problem, so
1499 if you have an idea about it, please tell us. However, we are afraid
1500 it is not that simple: before saying @command{exec /bin/sh},
1501 @value{tramp} does not know which kind of shell it might be talking
1502 to. It could be a Bourne-ish shell like ksh or bash, or it could be a
1503 csh derivative like tcsh, or it could be zsh, or even rc. If the
1504 shell is Bourne-ish already, then it might be prudent to omit the
1505 @command{exec /bin/sh} step. But how to find out if the shell is
1506 Bourne-ish?
1507
1508 @end table
1509
1510
1511 @node Auto-save and Backup
1512 @section Auto-save and Backup configuration
1513 @cindex auto-save
1514 @cindex backup
1515 @ifset emacs
1516 @vindex backup-directory-alist
1517 @end ifset
1518 @ifset xemacs
1519 @vindex bkup-backup-directory-info
1520 @end ifset
1521
1522 Normally, @value{emacsname} writes backup files to the same directory
1523 as the original files, but this behavior can be changed via the
1524 variable
1525 @ifset emacs
1526 @code{backup-directory-alist}.
1527 @end ifset
1528 @ifset xemacs
1529 @code{bkup-backup-directory-info}.
1530 @end ifset
1531 In connection with @value{tramp}, this can have unexpected side effects.
1532 Suppose that you specify that all backups should go to the directory
1533 @file{~/.emacs.d/backups/}, and then you edit the file
1534 @file{@value{prefix}su@value{postfixsinglehop}root@@localhost@value{postfix}/etc/secretfile}.
1535 The effect is that the backup file will be owned by you and not by
1536 root, thus possibly enabling others to see it even if they were not
1537 intended to see it.
1538
1539 When
1540 @ifset emacs
1541 @code{backup-directory-alist}
1542 @end ifset
1543 @ifset xemacs
1544 @code{bkup-backup-directory-info}
1545 @end ifset
1546 is @code{nil} (the default), such problems do not occur.
1547
1548 Therefore, it is useful to set special values for @value{tramp}
1549 files. For example, the following statement effectively `turns off'
1550 the effect of
1551 @ifset emacs
1552 @code{backup-directory-alist}
1553 @end ifset
1554 @ifset xemacs
1555 @code{bkup-backup-directory-info}
1556 @end ifset
1557 for @value{tramp} files:
1558
1559 @ifset emacs
1560 @lisp
1561 (add-to-list 'backup-directory-alist
1562 (cons tramp-file-name-regexp nil))
1563 @end lisp
1564 @end ifset
1565 @ifset xemacs
1566 @lisp
1567 (require 'backup-dir)
1568 (add-to-list 'bkup-backup-directory-info
1569 (list tramp-file-name-regexp ""))
1570 @end lisp
1571 @end ifset
1572
1573 Another possibility is to use the @value{tramp} variable
1574 @ifset emacs
1575 @code{tramp-backup-directory-alist}.
1576 @end ifset
1577 @ifset xemacs
1578 @code{tramp-bkup-backup-directory-info}.
1579 @end ifset
1580 This variable has the same meaning like
1581 @ifset emacs
1582 @code{backup-directory-alist}.
1583 @end ifset
1584 @ifset xemacs
1585 @code{bkup-backup-directory-info}.
1586 @end ifset
1587 If a @value{tramp} file is backed up, and DIRECTORY is an absolute
1588 local file name, DIRECTORY is prepended with the @value{tramp} file
1589 name prefix of the file to be backed up.
1590
1591 @noindent
1592 Example:
1593
1594 @ifset emacs
1595 @lisp
1596 (add-to-list 'backup-directory-alist
1597 (cons "." "~/.emacs.d/backups/"))
1598 (setq tramp-backup-directory-alist backup-directory-alist)
1599 @end lisp
1600 @end ifset
1601 @ifset xemacs
1602 @lisp
1603 (require 'backup-dir)
1604 (add-to-list 'bkup-backup-directory-info
1605 (list "." "~/.emacs.d/backups/" 'full-path))
1606 (setq tramp-bkup-backup-directory-info bkup-backup-directory-info)
1607 @end lisp
1608 @end ifset
1609
1610 @noindent
1611 The backup file name of
1612 @file{@value{prefix}su@value{postfixsinglehop}root@@localhost@value{postfix}/etc/secretfile}
1613 would be
1614 @ifset emacs
1615 @file{@value{prefix}su@value{postfixsinglehop}root@@localhost@value{postfix}~/.emacs.d/backups/!su:root@@localhost:!etc!secretfile~}
1616 @end ifset
1617 @ifset xemacs
1618 @file{@value{prefix}su@value{postfixsinglehop}root@@localhost@value{postfix}~/.emacs.d/backups/![su!root@@localhost]!etc!secretfile~}
1619 @end ifset
1620
1621 The same problem can happen with auto-saving files.
1622 @ifset emacs
1623 Since @value{emacsname} 21, the variable
1624 @code{auto-save-file-name-transforms} keeps information, on which
1625 directory an auto-saved file should go. By default, it is initialized
1626 for @value{tramp} files to the local temporary directory.
1627
1628 On some versions of @value{emacsname}, namely the version built for
1629 Debian GNU/Linux, the variable @code{auto-save-file-name-transforms}
1630 contains the directory where @value{emacsname} was built. A
1631 workaround is to manually set the variable to a sane value.
1632
1633 If auto-saved files should go into the same directory as the original
1634 files, @code{auto-save-file-name-transforms} should be set to @code{nil}.
1635
1636 Another possibility is to set the variable
1637 @code{tramp-auto-save-directory} to a proper value.
1638 @end ifset
1639 @ifset xemacs
1640 For this purpose you can set the variable @code{auto-save-directory}
1641 to a proper value.
1642 @end ifset
1643
1644
1645 @node Windows setup hints
1646 @section Issues with Cygwin ssh
1647 @cindex Cygwin, issues
1648
1649 This section needs a lot of work! Please help.
1650
1651 @cindex method sshx with Cygwin
1652 @cindex sshx method with Cygwin
1653 The recent Cygwin installation of @command{ssh} works only with a
1654 Cygwinized @value{emacsname}. You can check it by typing @kbd{M-x
1655 eshell}, and starting @kbd{ssh test.machine}. The problem is evident
1656 if you see a message like this:
1657
1658 @example
1659 Pseudo-terminal will not be allocated because stdin is not a terminal.
1660 @end example
1661
1662 Older @command{ssh} versions of Cygwin are told to cooperate with
1663 @value{tramp} selecting @option{sshx} as the connection method. You
1664 can find information about setting up Cygwin in their FAQ at
1665 @uref{http://cygwin.com/faq/}.
1666
1667 @cindex method scpx with Cygwin
1668 @cindex scpx method with Cygwin
1669 If you wish to use the @option{scpx} connection method, then you might
1670 have the problem that @value{emacsname} calls @command{scp} with a
1671 Windows filename such as @code{c:/foo}. The Cygwin version of
1672 @command{scp} does not know about Windows filenames and interprets this
1673 as a remote filename on the host @code{c}.
1674
1675 One possible workaround is to write a wrapper script for @option{scp}
1676 which converts the Windows filename to a Cygwinized filename.
1677
1678 @cindex Cygwin and ssh-agent
1679 @cindex SSH_AUTH_SOCK and @value{emacsname} on Windows
1680 If you want to use either @option{ssh} based method on Windows, then
1681 you might encounter problems with @command{ssh-agent}. Using this
1682 program, you can avoid typing the pass-phrase every time you log in.
1683 However, if you start @value{emacsname} from a desktop shortcut, then
1684 the environment variable @code{SSH_AUTH_SOCK} is not set and so
1685 @value{emacsname} and thus @value{tramp} and thus @command{ssh} and
1686 @command{scp} started from @value{tramp} cannot communicate with
1687 @command{ssh-agent}. It works better to start @value{emacsname} from
1688 the shell.
1689
1690 If anyone knows how to start @command{ssh-agent} under Windows in such a
1691 way that desktop shortcuts can profit, please holler. I don't really
1692 know anything at all about Windows@dots{}
1693
1694
1695 @node Usage
1696 @chapter Using @value{tramp}
1697 @cindex using @value{tramp}
1698
1699 Once you have installed @value{tramp} it will operate fairly transparently. You
1700 will be able to access files on any remote machine that you can log in
1701 to as though they were local.
1702
1703 Files are specified to @value{tramp} using a formalized syntax specifying the
1704 details of the system to connect to. This is similar to the syntax used
1705 by the @value{ftppackagename} package.
1706
1707 @cindex type-ahead
1708 Something that might happen which surprises you is that
1709 @value{emacsname} remembers all your keystrokes, so if you see a
1710 password prompt from @value{emacsname}, say, and hit @kbd{@key{RET}}
1711 twice instead of once, then the second keystroke will be processed by
1712 @value{emacsname} after @value{tramp} has done its thing. Why, this
1713 type-ahead is normal behavior, you say. Right you are, but be aware
1714 that opening a remote file might take quite a while, maybe half a
1715 minute when a connection needs to be opened. Maybe after half a
1716 minute you have already forgotten that you hit that key!
1717
1718 @menu
1719 * Filename Syntax:: @value{tramp} filename conventions.
1720 * Multi-hop filename syntax:: Multi-hop filename conventions.
1721 * Filename completion:: Filename completion.
1722 * Dired:: Dired.
1723 * Compilation:: Compile remote files.
1724 @end menu
1725
1726
1727 @node Filename Syntax
1728 @section @value{tramp} filename conventions
1729 @cindex filename syntax
1730 @cindex filename examples
1731
1732 To access the file @var{localname} on the remote machine @var{machine} you
1733 would specify the filename
1734 @file{@value{prefix}@var{machine}@value{postfix}@var{localname}}.
1735 This will connect to @var{machine} and transfer the file using the
1736 default method. @xref{Default Method}.
1737
1738 Some examples of @value{tramp} filenames are shown below.
1739
1740 @table @file
1741 @item @value{prefix}melancholia@value{postfix}.emacs
1742 Edit the file @file{.emacs} in your home directory on the machine
1743 @code{melancholia}.
1744
1745 @item @value{prefix}melancholia.danann.net@value{postfix}.emacs
1746 This edits the same file, using the fully qualified domain name of
1747 the machine.
1748
1749 @item @value{prefix}melancholia@value{postfix}~/.emacs
1750 This also edits the same file --- the @file{~} is expanded to your
1751 home directory on the remote machine, just like it is locally.
1752
1753 @item @value{prefix}melancholia@value{postfix}~daniel/.emacs
1754 This edits the file @file{.emacs} in the home directory of the user
1755 @code{daniel} on the machine @code{melancholia}. The @file{~<user>}
1756 construct is expanded to the home directory of that user on the remote
1757 machine.
1758
1759 @item @value{prefix}melancholia@value{postfix}/etc/squid.conf
1760 This edits the file @file{/etc/squid.conf} on the machine
1761 @code{melancholia}.
1762
1763 @end table
1764
1765 Unless you specify a different name to use, @value{tramp} will use the
1766 current local user name as the remote user name to log in with. If you
1767 need to log in as a different user, you can specify the user name as
1768 part of the filename.
1769
1770 To log in to the remote machine as a specific user, you use the syntax
1771 @file{@value{prefix}@var{user}@@@var{machine}@value{postfix}/@var{path/to.file}}.
1772 That means that connecting to @code{melancholia} as @code{daniel} and
1773 editing @file{.emacs} in your home directory you would specify
1774 @file{@value{prefix}daniel@@melancholia@value{postfix}.emacs}.
1775
1776 It is also possible to specify other file transfer methods
1777 (@pxref{Default Method}) as part of the filename.
1778 @ifset emacs
1779 This is done by putting the method before the user and host name, as
1780 in
1781 @file{@value{prefix}@var{method}@value{postfixsinglehop}}
1782 (Note the trailing colon).
1783 @end ifset
1784 @ifset xemacs
1785 This is done by replacing the initial
1786 @file{@value{prefix}} with
1787 @file{@value{prefix}<method>@value{postfixsinglehop}}.
1788 (Note the trailing slash!).
1789 @end ifset
1790 The user, machine and file specification remain the same.
1791
1792 So, to connect to the machine @code{melancholia} as @code{daniel},
1793 using the @option{ssh} method to transfer files, and edit @file{.emacs}
1794 in my home directory I would specify the filename
1795 @file{@value{prefix}ssh@value{postfixsinglehop}daniel@@melancholia@value{postfix}.emacs}.
1796
1797
1798 @node Multi-hop filename syntax
1799 @section Multi-hop filename conventions
1800 @cindex filename syntax for multi-hop files
1801 @cindex multi-hop filename syntax
1802
1803 The syntax of multi-hop file names is necessarily slightly different
1804 than the syntax of other @value{tramp} file names. Here's an example
1805 multi-hop file name:
1806
1807 @example
1808 @value{prefix}multi@value{postfixsinglehop}rsh@value{postfixmultihop}out@@gate@value{postfixsinglehop}telnet@value{postfixmultihop}kai@@real.host@value{postfix}/path/to.file
1809 @end example
1810
1811 This is quite a mouthful. So let's go through it step by step. The
1812 file name consists of three parts.
1813 @ifset emacs
1814 The parts are separated by colons
1815 @end ifset
1816 @ifset xemacs
1817 The parts are separated by slashes and square brackets.
1818 @end ifset
1819 The first part is @file{@value{prefix}multi}, the method
1820 specification. The second part is
1821 @file{rsh@value{postfixmultihop}out@@gate@value{postfixsinglehop}telnet@value{postfixmultihop}kai@@real.host}
1822 and specifies the hops. The final part is @file{/path/to.file} and
1823 specifies the file name on the remote host.
1824
1825 The first part and the final part should be clear. See @ref{Multi-hop
1826 Methods}, for a list of alternatives for the method specification.
1827
1828 The second part can be subdivided again into components, so-called
1829 hops. In the above file name, there are two hops,
1830 @file{rsh@value{postfixmultihop}out@@gate} and
1831 @file{telnet@value{postfixmultihop}kai@@real.host}.
1832
1833 Each hop can @emph{again} be subdivided into (three) components, the
1834 @dfn{hop method}, the @dfn{user name} and the @dfn{host name}. The
1835 meaning of the second and third component should be clear, and the hop
1836 method says what program to use to perform that hop.
1837
1838 The first hop, @file{rsh@value{postfixmultihop}out@@gate},
1839 says to use @command{rsh} to log in as user @code{out} to the host
1840 @code{gate}. Starting at that host, the second hop,
1841 @file{telnet@value{postfixmultihop}kai@@real.host}, says to
1842 use @command{telnet} to log in as user @code{kai} to host
1843 @code{real.host}.
1844
1845 @xref{Multi-hop Methods}, for a list of possible hop method values.
1846 The variable @code{tramp-multi-connection-function-alist} contains the
1847 list of possible hop methods and information on how to execute them,
1848 should you want to add your own.
1849
1850
1851 @node Filename completion
1852 @section Filename completion
1853 @cindex filename completion
1854
1855 Filename completion works with @value{tramp} for completion of method
1856 names, of user names and of machine names (except multi-hop methods)
1857 as well as for completion of file names on remote machines.
1858 @ifset emacs
1859 In order to enable this, Partial Completion mode must be set on.
1860 @ifinfo
1861 @xref{Completion Options, , , @value{emacsdir}}.
1862 @end ifinfo
1863 @end ifset
1864
1865 If you, for example, type @kbd{C-x C-f @value{prefix}t
1866 @key{TAB}}, @value{tramp} might give you as result the choice for
1867
1868 @example
1869 @ifset emacs
1870 @value{prefixsinglehop}telnet@value{postfixsinglehop} tmp/
1871 @value{prefixsinglehop}toto@value{postfix}
1872 @end ifset
1873 @ifset xemacs
1874 @value{prefixsinglehop}telnet@value{postfixsinglehop} @value{prefixsinglehop}toto@value{postfix}
1875 @end ifset
1876 @end example
1877
1878 @samp{@value{prefixsinglehop}telnet@value{postfixsinglehop}}
1879 is a possible completion for the respective method,
1880 @ifset emacs
1881 @samp{tmp/} stands for the directory @file{/tmp} on your local
1882 machine,
1883 @end ifset
1884 and @samp{@value{prefixsinglehop}toto@value{postfix}}
1885 might be a host @value{tramp} has detected in your @file{~/.ssh/known_hosts}
1886 file (given you're using default method @option{ssh}).
1887
1888 If you go on to type @kbd{e @key{TAB}}, the minibuffer is completed to
1889 @samp{@value{prefix}telnet@value{postfixsinglehop}}.
1890 Next @kbd{@key{TAB}} brings you all machine names @value{tramp} detects in
1891 your @file{/etc/hosts} file, let's say
1892
1893 @example
1894 @value{prefixsinglehop}telnet@value{postfixsinglehop}127.0.0.1@value{postfix} @value{prefixsinglehop}telnet@value{postfixsinglehop}192.168.0.1@value{postfix}
1895 @value{prefixsinglehop}telnet@value{postfixsinglehop}localhost@value{postfix} @value{prefixsinglehop}telnet@value{postfixsinglehop}melancholia.danann.net@value{postfix}
1896 @value{prefixsinglehop}telnet@value{postfixsinglehop}melancholia@value{postfix}
1897 @end example
1898
1899 Now you can choose the desired machine, and you can continue to
1900 complete file names on that machine.
1901
1902 As filename completion needs to fetch the listing of files from the
1903 remote machine, this feature is sometimes fairly slow. As @value{tramp}
1904 does not yet cache the results of directory listing, there is no gain
1905 in performance the second time you complete filenames.
1906
1907 If the configuration files (@pxref{Customizing Completion}), which
1908 @value{tramp} uses for analysis of completion, offer user names, those user
1909 names will be taken into account as well.
1910
1911
1912 @node Dired
1913 @section Dired
1914 @cindex dired
1915
1916 @value{tramp} works transparently with dired, enabling you to use this powerful
1917 file management tool to manage files on any machine you have access to
1918 over the Internet.
1919
1920 If you need to browse a directory tree, Dired is a better choice, at
1921 present, than filename completion. Dired has its own cache mechanism
1922 and will only fetch the directory listing once.
1923
1924
1925 @node Compilation
1926 @section Compile remote files
1927 @cindex compile
1928 @cindex recompile
1929
1930 @value{tramp} provides commands for compilation of files on remote
1931 machines. In order to get them loaded, you need to require
1932 @file{tramp-util.el}:
1933
1934 @lisp
1935 (require 'tramp-util)
1936 @end lisp
1937
1938 Afterwards, you can use the commands @code{tramp-compile} and
1939 @code{tramp-recompile} instead of @code{compile} and @code{recompile},
1940 respectively; @inforef{Compilation, ,@value{emacsdir}}. This does not
1941 work for the @option{ftp} and @option{smb} methods.
1942
1943 The corresponding key bindings and menu entries calling these commands
1944 are redefined automatically for buffers associated with remote files.
1945
1946 After finishing the compilation, you can use the usual commands like
1947 @code{previous-error}, @code{next-error} and @code{first-error} for
1948 navigation in the @file{*Compilation*} buffer.
1949
1950
1951 @node Bug Reports
1952 @chapter Reporting Bugs and Problems
1953 @cindex bug reports
1954
1955 Bugs and problems with @value{tramp} are actively worked on by the
1956 development team. Feature requests and suggestions are also more than
1957 welcome.
1958
1959 The @value{tramp} mailing list is a great place to get information on
1960 working with @value{tramp}, solving problems and general discussion
1961 and advice on topics relating to the package. It is moderated so
1962 non-subscribers can post but messages will be delayed, possibly up to
1963 48 hours (or longer in case of holidays), until the moderator approves
1964 your message.
1965
1966 The mailing list is at @email{tramp-devel@@gnu.org}. Messages sent to
1967 this address go to all the subscribers. This is @emph{not} the address
1968 to send subscription requests to.
1969
1970 Subscribing to the list is performed via
1971 @uref{http://lists.gnu.org/mailman/listinfo/tramp-devel/,
1972 the @value{tramp} Mail Subscription Page}.
1973
1974 To report a bug in @value{tramp}, you should execute @kbd{M-x tramp-bug}. This
1975 will automatically generate a buffer with the details of your system and
1976 @value{tramp} version.
1977
1978 When submitting a bug report, please try to describe in excruciating
1979 detail the steps required to reproduce the problem, the setup of the
1980 remote machine and any special conditions that exist. You should also
1981 check that your problem is not described already in @xref{Frequently
1982 Asked Questions}.
1983
1984 If you can identify a minimal test case that reproduces the problem,
1985 include that with your bug report. This will make it much easier for the
1986 development team to analyze and correct the problem.
1987
1988 @node Frequently Asked Questions
1989 @chapter Frequently Asked Questions
1990 @cindex frequently asked questions
1991 @cindex FAQ
1992
1993 @itemize @bullet
1994 @item
1995 Where can I get the latest @value{tramp}?
1996
1997 @value{tramp} is available under the URL below.
1998
1999 @noindent
2000 @uref{ftp://ftp.gnu.org/gnu/tramp/}
2001
2002 @noindent
2003 There is also a Savannah project page.
2004
2005 @noindent
2006 @uref{http://savannah.gnu.org/projects/tramp/}
2007
2008
2009 @item
2010 Which systems does it work on?
2011
2012 The package has been used successfully on GNU Emacs 20, GNU Emacs 21
2013 and GNU Emacs 22, as well as XEmacs 21. XEmacs 20 is more
2014 problematic, see the notes in @file{tramp.el}. I don't think anybody
2015 has really tried it on GNU Emacs 19.
2016
2017 The package was intended to work on Unix, and it really expects a
2018 Unix-like system on the remote end (except the @option{smb} method),
2019 but some people seemed to have some success getting it to work on MS
2020 Windows NT/2000/XP @value{emacsname}.
2021
2022 There is some informations on @value{tramp} on NT at the following URL;
2023 many thanks to Joe Stoy for providing the information:
2024 @uref{ftp://ftp.comlab.ox.ac.uk/tmp/Joe.Stoy/}
2025
2026 @c The link is broken. I've contacted Tom for clarification. Michael.
2027 @ignore
2028 The above mostly contains patches to old ssh versions; Tom Roche has a
2029 Web page with instructions:
2030 @uref{http://www4.ncsu.edu/~tlroche/plinkTramp.html}
2031 @end ignore
2032
2033
2034 @item
2035 @value{tramp} does not connect to the remote host
2036
2037 When @value{tramp} does not connect to the remote host, there are two
2038 reasons heading the bug mailing list:
2039
2040 @itemize @minus
2041
2042 @item
2043 Unknown characters in the prompt
2044
2045 @value{tramp} needs to recognize the prompt on the remote machine
2046 after execution any command. This is not possible, when the prompt
2047 contains unknown characters like escape sequences for coloring. This
2048 should be avoided on the remote side. @xref{Remote shell setup}. for
2049 setting the regular expression detecting the prompt.
2050
2051 A special problem is the zsh, which uses left-hand side and right-hand
2052 side prompts in parallel. Therefore, it is necessary to disable the
2053 zsh line editor on the remote host. You shall add to @file{~/.zshrc}
2054 the following command:
2055
2056 @example
2057 [ $TERM = "dumb" ] && unsetopt zle && PS1='$ '
2058 @end example
2059
2060 @item
2061 @value{tramp} doesn't transfer strings with more than 500 characters
2062 correctly
2063
2064 On some few systems, the implementation of @code{process-send-string}
2065 seems to be broken for longer strings. This case, you should
2066 customize the variable @code{tramp-chunksize} to 500. For a
2067 description how to determine whether this is necessary see the
2068 documentation of @code{tramp-chunksize}.
2069 @end itemize
2070
2071
2072 @item
2073 File name completion does not work with @value{tramp}
2074
2075 When you log in to the remote machine, do you see the output of
2076 @command{ls} in color? If so, this may be the cause of your problems.
2077
2078 @command{ls} outputs @acronym{ANSI} escape sequences that your terminal
2079 emulator interprets to set the colors. These escape sequences will
2080 confuse @value{tramp} however.
2081
2082 In your @file{.bashrc}, @file{.profile} or equivalent on the remote
2083 machine you probably have an alias configured that adds the option
2084 @option{--color=yes} or @option{--color=auto}.
2085
2086 You should remove that alias and ensure that a new login @emph{does not}
2087 display the output of @command{ls} in color. If you still cannot use
2088 filename completion, report a bug to the @value{tramp} developers.
2089
2090
2091 @item
2092 File name completion does not work in large directories
2093
2094 @value{tramp} uses globbing for some operations. (Globbing means to use the
2095 shell to expand wildcards such as `*.c'.) This might create long
2096 command lines, especially in directories with many files. Some shells
2097 choke on long command lines, or don't cope well with the globbing
2098 itself.
2099
2100 If you have a large directory on the remote end, you may wish to execute
2101 a command like @samp{ls -d * ..?* > /dev/null} and see if it hangs.
2102 Note that you must first start the right shell, which might be
2103 @command{/bin/sh}, @command{ksh} or @command{bash}, depending on which
2104 of those supports tilde expansion.
2105
2106
2107 @item
2108 How can I get notified when @value{tramp} file transfers are complete?
2109
2110 The following snippet can be put in your @file{~/.emacs} file. It
2111 makes @value{emacsname} beep after reading from or writing to the
2112 remote host.
2113
2114 @lisp
2115 (defadvice tramp-handle-write-region
2116 (after tramp-write-beep-advice activate)
2117 " make tramp beep after writing a file."
2118 (interactive)
2119 (beep))
2120 (defadvice tramp-handle-do-copy-or-rename-file
2121 (after tramp-copy-beep-advice activate)
2122 " make tramp beep after copying a file."
2123 (interactive)
2124 (beep))
2125 (defadvice tramp-handle-insert-file-contents
2126 (after tramp-copy-beep-advice activate)
2127 " make tramp beep after copying a file."
2128 (interactive)
2129 (beep))
2130 @end lisp
2131
2132
2133 @item
2134 There's this @file{~/.sh_history} file on the remote host which keeps
2135 growing and growing. What's that?
2136
2137 Sometimes, @value{tramp} starts @command{ksh} on the remote host for
2138 tilde expansion. Maybe @command{ksh} saves the history by default.
2139 @value{tramp} tries to turn off saving the history, but maybe you have
2140 to help. For example, you could put this in your @file{.kshrc}:
2141
2142 @example
2143 if [ -f $HOME/.sh_history ] ; then
2144 /bin/rm $HOME/.sh_history
2145 fi
2146 if [ "$@{HISTFILE-unset@}" != "unset" ] ; then
2147 unset HISTFILE
2148 fi
2149 if [ "$@{HISTSIZE-unset@}" != "unset" ] ; then
2150 unset HISTSIZE
2151 fi
2152 @end example
2153
2154
2155 @item
2156 How can I disable @value{tramp}?
2157
2158 Shame on you, why did you read until now?
2159
2160 @ifset emacs
2161 If you just want to have @value{ftppackagename} as default remote
2162 files access package, you should apply the following code:
2163
2164 @lisp
2165 (setq tramp-default-method "ftp")
2166 @end lisp
2167 @end ifset
2168
2169 Unloading @value{tramp} can be achieved by applying @kbd{M-x
2170 tramp-unload-tramp}.
2171 @ifset emacs
2172 This resets also the @value{ftppackagename} plugins.
2173 @end ifset
2174 @end itemize
2175
2176
2177 @c For the developer
2178 @node Version Control
2179 @chapter The inner workings of remote version control
2180 @cindex Version Control
2181
2182 Unlike @value{ftppackagename}, @value{tramp} has full shell access to the
2183 remote machine. This makes it possible to provide version control for
2184 files accessed under @value{tramp}.
2185
2186 The actual version control binaries must be installed on the remote
2187 machine, accessible in the directories specified in
2188 @var{tramp-remote-path}.
2189
2190 This transparent integration with the version control systems is one of
2191 the most valuable features provided by @value{tramp}, but it is far from perfect.
2192 Work is ongoing to improve the transparency of the system.
2193
2194 @menu
2195 * Version Controlled Files:: Determining if a file is under version control.
2196 * Remote Commands:: Executing the version control commands on the remote machine.
2197 * Changed workfiles:: Detecting if the working file has changed.
2198 * Checking out files:: Bringing the workfile out of the repository.
2199 * Miscellaneous Version Control:: Things related to Version Control that don't fit elsewhere.
2200 @end menu
2201
2202
2203 @node Version Controlled Files
2204 @section Determining if a file is under version control
2205
2206 The VC package uses the existence of on-disk revision control master
2207 files to determine if a given file is under revision control. These file
2208 tests happen on the remote machine through the standard @value{tramp} mechanisms.
2209
2210
2211 @node Remote Commands
2212 @section Executing the version control commands on the remote machine
2213
2214 There are no hooks provided by VC to allow intercepting of the version
2215 control command execution. The calls occur through the
2216 @code{call-process} mechanism, a function that is somewhat more
2217 efficient than the @code{shell-command} function but that does not
2218 provide hooks for remote execution of commands.
2219
2220 To work around this, the functions @code{vc-do-command} and
2221 @code{vc-simple-command} have been advised to intercept requests for
2222 operations on files accessed via @value{tramp}.
2223
2224 In the case of a remote file, the @code{shell-command} interface is
2225 used, with some wrapper code, to provide the same functionality on the
2226 remote machine as would be seen on the local machine.
2227
2228
2229 @node Changed workfiles
2230 @section Detecting if the working file has changed
2231
2232 As there is currently no way to get access to the mtime of a file on a
2233 remote machine in a portable way, the @code{vc-workfile-unchanged-p}
2234 function is advised to call an @value{tramp} specific function for remote files.
2235
2236 The @code{tramp-vc-workfile-unchanged-p} function uses the functioning VC
2237 diff functionality to determine if any changes have occurred between the
2238 workfile and the version control master.
2239
2240 This requires that a shell command be executed remotely, a process that
2241 is notably heavier-weight than the mtime comparison used for local
2242 files. Unfortunately, unless a portable solution to the issue is found,
2243 this will remain the cost of remote version control.
2244
2245
2246 @node Checking out files
2247 @section Bringing the workfile out of the repository
2248
2249 VC will, by default, check for remote files and refuse to act on them
2250 when checking out files from the repository. To work around this
2251 problem, the function @code{vc-checkout} knows about @value{tramp} files and
2252 allows version control to occur.
2253
2254
2255 @node Miscellaneous Version Control
2256 @section Things related to Version Control that don't fit elsewhere
2257
2258 Minor implementation details, &c.
2259
2260 @menu
2261 * Remote File Ownership:: How VC determines who owns a workfile.
2262 * Back-end Versions:: How VC determines what release your RCS is.
2263 @end menu
2264
2265
2266 @node Remote File Ownership
2267 @subsection How VC determines who owns a workfile
2268
2269 @value{emacsname} provides the @code{user-full-name} function to
2270 return the login name of the current user as well as mapping from
2271 arbitrary user id values back to login names. The VC code uses this
2272 functionality to map from the uid of the owner of a workfile to the
2273 login name in some circumstances.
2274
2275 This will not, for obvious reasons, work if the remote system has a
2276 different set of logins. As such, it is necessary to delegate to the
2277 remote machine the job of determining the login name associated with a
2278 uid.
2279
2280 Unfortunately, with the profusion of distributed management systems such
2281 as @code{NIS}, @code{NIS+} and @code{NetInfo}, there is no simple,
2282 reliable and portable method for performing this mapping.
2283
2284 Thankfully, the only place in the VC code that depends on the mapping of
2285 a uid to a login name is the @code{vc-file-owner} function. This returns
2286 the login of the owner of the file as a string.
2287
2288 This function has been advised to use the output of @command{ls} on the
2289 remote machine to determine the login name, delegating the problem of
2290 mapping the uid to the login to the remote system which should know more
2291 about it than I do.
2292
2293
2294 @node Back-end Versions
2295 @subsection How VC determines what release your RCS is
2296
2297 VC needs to know what release your revision control binaries you are
2298 running as not all features VC supports are available with older
2299 versions of @command{rcs(1)}, @command{cvs(1)} or @command{sccs(1)}.
2300
2301 The default implementation of VC determines this value the first time it
2302 is needed and then stores the value globally to avoid the overhead of
2303 executing a process and parsing its output each time the information is
2304 needed.
2305
2306 Unfortunately, life is not quite so easy when remote version control
2307 comes into the picture. Each remote machine may have a different version
2308 of the version control tools and, while this is painful, we need to
2309 ensure that unavailable features are not used remotely.
2310
2311 To resolve this issue, @value{tramp} currently takes the sledgehammer
2312 approach of making the release values of the revision control tools
2313 local to each @value{tramp} buffer, forcing VC to determine these values
2314 again each time a new file is visited.
2315
2316 This has, quite obviously, some performance implications. Thankfully,
2317 most of the common operations performed by VC do not actually require
2318 that the remote version be known. This makes the problem far less
2319 apparent.
2320
2321 Eventually these values will be captured by @value{tramp} on a system by
2322 system basis and the results cached to improve performance.
2323
2324
2325 @node Files directories and localnames
2326 @chapter How file names, directories and localnames are mangled and managed.
2327
2328 @menu
2329 * Localname deconstruction:: Breaking a localname into its components.
2330 @end menu
2331
2332
2333 @node Localname deconstruction
2334 @section Breaking a localname into its components.
2335
2336 @value{tramp} file names are somewhat different, obviously, to ordinary file
2337 names. As such, the lisp functions @code{file-name-directory} and
2338 @code{file-name-nondirectory} are overridden within the @value{tramp}
2339 package.
2340
2341 Their replacements are reasonably simplistic in their approach. They
2342 dissect the filename, call the original handler on the localname and
2343 then rebuild the @value{tramp} file name with the result.
2344
2345 This allows the platform specific hacks in the original handlers to take
2346 effect while preserving the @value{tramp} file name information.
2347
2348
2349 @node Issues
2350 @chapter Debatable Issues and What Was Decided
2351
2352 @itemize @bullet
2353 @item The uuencode method does not always work.
2354
2355 Due to the design of @value{tramp}, the encoding and decoding programs
2356 need to read from stdin and write to stdout. On some systems,
2357 @command{uudecode -o -} will read stdin and write the decoded file to
2358 stdout, on other systems @command{uudecode -p} does the same thing.
2359 But some systems have uudecode implementations which cannot do this at
2360 all---it is not possible to call these uudecode implementations with
2361 suitable parameters so that they write to stdout.
2362
2363 Of course, this could be circumvented: the @code{begin foo 644} line
2364 could be rewritten to put in some temporary file name, then
2365 @command{uudecode} could be called, then the temp file could be
2366 printed and deleted.
2367
2368 But I have decided that this is too fragile to reliably work, so on some
2369 systems you'll have to do without the uuencode methods.
2370
2371 @item @value{tramp} does not work on XEmacs 20.
2372
2373 This is because it requires the macro @code{with-timeout} which does not
2374 appear to exist in XEmacs 20. I'm somewhat reluctant to add an
2375 emulation macro to @value{tramp}, but if somebody who uses XEmacs 20 steps
2376 forward and wishes to implement and test it, please contact me or the
2377 mailing list.
2378
2379 @item The @value{tramp} filename syntax differs between GNU Emacs and XEmacs.
2380
2381 The GNU Emacs maintainers wish to use a unified filename syntax for
2382 Ange-FTP and @value{tramp} so that users don't have to learn a new
2383 syntax. It is sufficient to learn some extensions to the old syntax.
2384
2385 For the XEmacs maintainers, the problems caused from using a unified
2386 filename syntax are greater than the gains. The XEmacs package system
2387 uses EFS for downloading new packages. So, obviously, EFS has to be
2388 installed from the start. If the filenames were unified, @value{tramp}
2389 would have to be installed from the start, too.
2390
2391 @ifset xemacs
2392 @strong{Note:} If you'd like to use a similar syntax like
2393 @value{ftppackagename}, you need the following settings in your init
2394 file:
2395
2396 @lisp
2397 (setq tramp-unified-filenames t)
2398 (require 'tramp)
2399 @end lisp
2400
2401 The autoload of the @value{emacsname} @value{tramp} package must be
2402 disabled. This can be achieved by setting file permissions @code{000}
2403 to the files @file{.../xemacs-packages/lisp/tramp/auto-autoloads.el*}.
2404
2405 In case of unified filenames, all @value{emacsname} download sites
2406 are added to @code{tramp-default-method-alist} with default method
2407 @option{ftp} @xref{Default Method}. These settings shouldn't be touched
2408 for proper working of the @value{emacsname} package system.
2409
2410 The syntax for unified filenames is described in the @value{tramp} manual
2411 for @value{emacsothername}.
2412 @end ifset
2413 @end itemize
2414
2415 @node GNU Free Documentation License
2416 @appendix GNU Free Documentation License
2417 @include doclicense.texi
2418
2419 @node Concept Index
2420 @comment node-name, next, previous, up
2421 @unnumbered Concept Index
2422 @printindex cp
2423 @contents
2424 @c End of tramp.texi - the TRAMP User Manual
2425 @bye
2426
2427 @c TODO
2428 @c
2429 @c * Say something about the .login and .profile files of the remote
2430 @c shells.
2431 @c * Explain how tramp.el works in principle: open a shell on a remote
2432 @c host and then send commands to it.
2433 @c * Mention that bookmarks are a cool feature to go along with Tramp.
2434 @c * Make terminology "inline" vs "out-of-band" consistent.
2435 @c It seems that "external" is also used instead of "out-of-band".
2436
2437 @c * M. Albinus
2438 @c ** Use `filename' resp. `file name' consistently.
2439 @c ** Use `host' resp. `machine' consistently.
2440 @c ** Consistent small or capitalized words especially in menues.
2441
2442 @ignore
2443 arch-tag: f96dd66e-6dd3-4c92-8d77-9c56205ba808
2444 @end ignore