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