Revert @documentencoding changes in the docs.
[bpt/emacs.git] / doc / misc / tramp.texi
1 \input texinfo @c -*-texinfo-*-
2 @setfilename ../../info/tramp
3 @c %**start of header
4 @settitle TRAMP User Manual
5 @c %**end of header
6
7 @c This is *so* much nicer :)
8 @footnotestyle end
9
10 @c In the Tramp repository, the version number is auto-frobbed from
11 @c configure.ac, so you should edit that file and run
12 @c "autoconf && ./configure" to change the version number.
13
14 @c Additionally, flags are set with respect to the Emacs flavor; and
15 @c depending whether Tramp is packaged into (X)Emacs, or standalone.
16
17 @include trampver.texi
18
19 @c Macro for formatting a filename according to the respective syntax.
20 @c xxx and yyy are auxiliary macros in order to omit leading and
21 @c trailing whitespace. Not very elegant, but I don't know it better.
22
23 @c There are subtle differences between texinfo 4.13 and 5.0. We must
24 @c declare two versions of the macro. This will be improved, hopefully.
25
26 @c Texinfo 5.0.
27 @ifset txicommandconditionals
28 @macro xxx {one}
29 @set \one\
30 @end macro
31
32 @macro yyy {one, two}
33 @xxx{x\one\}@c
34 @ifclear x
35 \one\@w{}\two\@c
36 @end ifclear
37 @clear x\one\
38 @end macro
39
40 @macro trampfn {method, user, host, localname}
41 @value{prefix}@c
42 @yyy{\method\,@value{postfixhop}}@c
43 @yyy{\user\,@@}@c
44 \host\@value{postfix}\localname\
45 @end macro
46 @end ifset
47
48 @c Texinfo 4.13.
49 @ifclear txicommandconditionals
50 @macro xxx {one}@c
51 @set \one\@c
52 @end macro
53
54 @macro yyy {one, two}@c
55 @xxx{x\one\}@c
56 @ifclear x@c
57 \one\@w{}\two\@c
58 @end ifclear
59 @clear x\one\@c
60 @end macro
61
62 @macro trampfn {method, user, host, localname}@c
63 @value{prefix}@yyy{\method\,@value{postfixhop}}@yyy{\user\,@@}\host\@value{postfix}\localname\@c
64 @end macro
65 @end ifclear
66
67 @copying
68 Copyright @copyright{} 1999--2013 Free Software 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.3 or
73 any later version published by the Free Software Foundation; with no
74 Invariant Sections, with the Front-Cover texts being ``A GNU Manual'',
75 and with the Back-Cover Texts as in (a) below. A copy of the license
76 is included in the section entitled ``GNU Free Documentation License''.
77
78 (a) The FSF's Back-Cover Text is: ``You have the freedom to
79 copy and modify this GNU manual.''
80 @end quotation
81 @end copying
82
83 @c Entries for @command{install-info} to use
84 @dircategory @value{emacsname} network features
85 @direntry
86 * TRAMP: (tramp). Transparent Remote Access, Multiple Protocol
87 @value{emacsname} remote file access via ssh and scp.
88 @end direntry
89
90 @titlepage
91 @title @value{tramp} version @value{trampver} User Manual
92 @author by Daniel Pittman
93 @author based on documentation by Kai Gro@ss{}johann
94 @page
95 @insertcopying
96 @end titlepage
97
98 @contents
99
100 @ifnottex
101 @node Top, Overview, (dir), (dir)
102 @top @value{tramp} version @value{trampver} User Manual
103
104 This file documents @value{tramp} version @value{trampver}, a remote file
105 editing package for @value{emacsname}.
106
107 @value{tramp} stands for `Transparent Remote (file) Access, Multiple
108 Protocol'. This package provides remote file editing, similar to
109 @value{ftppackagename}.
110
111 The difference is that @value{ftppackagename} uses FTP to transfer
112 files between the local and the remote host, whereas @value{tramp} uses a
113 combination of @command{rsh} and @command{rcp} or other work-alike
114 programs, such as @command{ssh}/@command{scp}.
115
116 You can find the latest version of this document on the web at
117 @uref{http://www.gnu.org/software/tramp/}.
118
119 @c Pointer to the other Emacs flavor is necessary only in case of
120 @c standalone installation.
121 @ifset installchapter
122 The manual has been generated for @value{emacsname}.
123 @ifinfo
124 If you want to read the info pages for @value{emacsothername}, you
125 should read in @ref{Installation} how to create them.
126 @end ifinfo
127 @ifhtml
128 If you're using the other Emacs flavor, you should read the
129 @uref{@value{emacsotherfilename}, @value{emacsothername}} pages.
130 @end ifhtml
131 @end ifset
132
133 @ifhtml
134 The latest release of @value{tramp} is available for
135 @uref{ftp://ftp.gnu.org/gnu/tramp/, download}, or you may see
136 @ref{Obtaining Tramp} for more details, including the Git server
137 details.
138
139 @value{tramp} also has a @uref{http://savannah.gnu.org/projects/tramp/,
140 Savannah Project Page}.
141 @end ifhtml
142
143 There is a mailing list for @value{tramp}, available at
144 @email{tramp-devel@@gnu.org}, and archived at
145 @uref{http://lists.gnu.org/archive/html/tramp-devel/, the
146 @value{tramp} Mail Archive}.
147 @ifhtml
148 Older archives are located at
149 @uref{http://sourceforge.net/mailarchive/forum.php?forum=tramp-devel,
150 SourceForge Mail Archive} and
151 @uref{http://www.mail-archive.com/emacs-rcp@@ls6.cs.uni-dortmund.de/,
152 The Mail Archive}.
153 @c in HTML output, there's no new paragraph.
154 @*@*
155 @end ifhtml
156
157 @insertcopying
158
159 @end ifnottex
160
161 @menu
162 * Overview:: What @value{tramp} can and cannot do.
163
164 For the end user:
165
166 * Obtaining Tramp:: How to obtain @value{tramp}.
167 * History:: History of @value{tramp}.
168 @ifset installchapter
169 * Installation:: Installing @value{tramp} with your @value{emacsname}.
170 @end ifset
171 * Configuration:: Configuring @value{tramp} for use.
172 * Usage:: An overview of the operation of @value{tramp}.
173 * Bug Reports:: Reporting Bugs and Problems.
174 * Frequently Asked Questions:: Questions and answers from the mailing list.
175
176 For the developer:
177
178 * Files directories and localnames:: How file names, directories and localnames are mangled and managed.
179 * Traces and Profiles:: How to Customize Traces.
180 * Issues:: Debatable Issues and What Was Decided.
181
182 * GNU Free Documentation License:: The license for this documentation.
183 * Function Index:: @value{tramp} functions.
184 * Variable Index:: User options and variables.
185 * Concept Index:: An item for each concept.
186
187 @detailmenu
188 --- The Detailed Node Listing ---
189 @c
190 @ifset installchapter
191 Installing @value{tramp} with your @value{emacsname}
192
193 * Installation parameters:: Parameters in order to control installation.
194 * Load paths:: How to plug-in @value{tramp} into your environment.
195
196 @end ifset
197
198 Configuring @value{tramp} for use
199
200 * Connection types:: Types of connections made to remote machines.
201 * Inline methods:: Inline methods.
202 * External methods:: External methods.
203 @ifset emacsgvfs
204 * GVFS based methods:: GVFS based external methods.
205 @end ifset
206 @ifset emacsgw
207 * Gateway methods:: Gateway methods.
208 @end ifset
209 * Default Method:: Selecting a default method.
210 * Default User:: Selecting a default user.
211 * Default Host:: Selecting a default host.
212 * Multi-hops:: Connecting to a remote host using multiple hops.
213 * Customizing Methods:: Using Non-Standard Methods.
214 * Customizing Completion:: Selecting config files for user/host name completion.
215 * Password handling:: Reusing passwords for several connections.
216 * Connection caching:: Reusing connection related information.
217 * Predefined connection information::
218 Setting own connection related information.
219 * Remote Programs:: How @value{tramp} finds and uses programs on the remote machine.
220 * Remote shell setup:: Remote shell setup hints.
221 * Android shell setup:: Android shell setup hints.
222 * Auto-save and Backup:: Auto-save and Backup.
223 * Windows setup hints:: Issues with Cygwin ssh.
224
225 Using @value{tramp}
226
227 * Filename Syntax:: @value{tramp} filename conventions.
228 * Filename completion:: Filename completion.
229 * Ad-hoc multi-hops:: Declaring multiple hops in the file name.
230 * Remote processes:: Integration with other @value{emacsname} packages.
231 * Cleanup remote connections:: Cleanup remote connections.
232
233 How file names, directories and localnames are mangled and managed
234
235 * Localname deconstruction:: Breaking a localname into its components.
236 @ifset emacs
237 * External packages:: Integration with external Lisp packages.
238 @end ifset
239
240 @end detailmenu
241 @end menu
242
243
244 @node Overview
245 @chapter An overview of @value{tramp}
246 @cindex overview
247
248 After the installation of @value{tramp} into your @value{emacsname}, you
249 will be able to access files on remote machines as though they were
250 local. Access to the remote file system for editing files, version
251 control, and @code{dired} are transparently enabled.
252
253 Your access to the remote machine can be with the @command{rsh},
254 @command{rlogin}, @command{telnet} programs or with any similar
255 connection method. This connection must pass @acronym{ASCII}
256 successfully to be usable but need not be 8-bit clean.
257
258 The package provides support for @command{ssh} connections out of the
259 box, one of the more common uses of the package. This allows
260 relatively secure access to machines, especially if @command{ftp}
261 access is disabled.
262
263 Under Windows, @value{tramp} is integrated with the PuTTY package,
264 using the @command{plink} program.
265
266 The majority of activity carried out by @value{tramp} requires only that
267 the remote login is possible and is carried out at the terminal. In
268 order to access remote files @value{tramp} needs to transfer their content
269 to the local machine temporarily.
270
271 @value{tramp} can transfer files between the machines in a variety of ways.
272 The details are easy to select, depending on your needs and the
273 machines in question.
274
275 The fastest transfer methods for large files rely on a remote file
276 transfer package such as @command{rcp}, @command{scp}, @command{rsync}
277 or (under Windows) @command{pscp}.
278
279 If the remote copy methods are not suitable for you, @value{tramp} also
280 supports the use of encoded transfers directly through the shell.
281 This requires that the @command{mimencode} or @command{uuencode} tools
282 are available on the remote machine. These methods are generally
283 faster for small files.
284
285 @value{tramp} is still under active development and any problems you encounter,
286 trivial or major, should be reported to the @value{tramp} developers.
287 @xref{Bug Reports}.
288
289
290 @subsubheading Behind the scenes
291 @cindex behind the scenes
292 @cindex details of operation
293 @cindex how it works
294
295 This section tries to explain what goes on behind the scenes when you
296 access a remote file through @value{tramp}.
297
298 Suppose you type @kbd{C-x C-f} and enter part of an @value{tramp} file name,
299 then hit @kbd{@key{TAB}} for completion. Suppose further that this is
300 the first time that @value{tramp} is invoked for the host in question. Here's
301 what happens:
302
303 @itemize
304 @item
305 @value{tramp} discovers that it needs a connection to the host. So it
306 invokes @samp{telnet @var{host}} or @samp{rsh @var{host} -l
307 @var{user}} or a similar tool to connect to the remote host.
308 Communication with this process happens through an
309 @value{emacsname} buffer, that is, the output from the remote end
310 goes into a buffer.
311
312 @item
313 The remote host may prompt for a login name (for @command{telnet}).
314 The login name is given in the file name, so @value{tramp} sends the
315 login name and a newline.
316
317 @item
318 The remote host may prompt for a password or pass phrase (for
319 @command{rsh} or for @command{telnet} after sending the login name).
320 @value{tramp} displays the prompt in the minibuffer, asking you for the
321 password or pass phrase.
322
323 You enter the password or pass phrase. @value{tramp} sends it to the remote
324 host, followed by a newline.
325
326 @item
327 @value{tramp} now waits for the shell prompt or for a message that the login
328 failed.
329
330 If @value{tramp} sees neither of them after a certain period of time
331 (a minute, say), then it issues an error message saying that it
332 couldn't find the remote shell prompt and shows you what the remote
333 host has sent.
334
335 If @value{tramp} sees a @samp{login failed} message, it tells you so,
336 aborts the login attempt and allows you to try again.
337
338 @item
339 Suppose that the login was successful and @value{tramp} sees the shell prompt
340 from the remote host. Now @value{tramp} invokes @command{/bin/sh} because
341 Bourne shells and C shells have different command
342 syntaxes.@footnote{Invoking @command{/bin/sh} will fail if your login
343 shell doesn't recognize @samp{exec /bin/sh} as a valid command.
344 Maybe you use the Scheme shell @command{scsh}@dots{}}
345
346 After the Bourne shell has come up, @value{tramp} sends a few commands to
347 ensure a good working environment. It turns off echoing, it sets the
348 shell prompt, and a few other things.
349
350 @item
351 Now the remote shell is up and it good working order. Remember, what
352 was supposed to happen is that @value{tramp} tries to find out what files exist
353 on the remote host so that it can do filename completion.
354
355 So, @value{tramp} basically issues @command{cd} and @command{ls} commands and
356 also sometimes @command{echo} with globbing. Another command that is
357 often used is @command{test} to find out whether a file is writable or a
358 directory or the like. The output of each command is parsed for the
359 necessary operation.
360
361 @item
362 Suppose you are finished with filename completion, have entered @kbd{C-x
363 C-f}, a full file name and hit @kbd{@key{RET}}. Now comes the time to
364 transfer the file contents from the remote host to the local host so
365 that you can edit them.
366
367 See above for an explanation of how @value{tramp} transfers the file contents.
368
369 For inline transfers, @value{tramp} issues a command like @samp{mimencode -b
370 /path/to/remote/file}, waits until the output has accumulated in the
371 buffer that's used for communication, then decodes that output to
372 produce the file contents.
373
374 For external transfers, @value{tramp} issues a command like the
375 following:
376 @example
377 rcp user@@host:/path/to/remote/file /tmp/tramp.4711
378 @end example
379 It then reads the local temporary file @file{/tmp/tramp.4711} into a
380 buffer and deletes the temporary file.
381
382 @item
383 You now edit the buffer contents, blithely unaware of what has happened
384 behind the scenes. (Unless you have read this section, that is.) When
385 you are finished, you type @kbd{C-x C-s} to save the buffer.
386
387 @item
388 Again, @value{tramp} transfers the file contents to the remote host
389 either inline or external. This is the reverse of what happens when
390 reading the file.
391 @end itemize
392
393 I hope this has provided you with a basic overview of what happens
394 behind the scenes when you open a file with @value{tramp}.
395
396
397 @c For the end user
398 @node Obtaining Tramp
399 @chapter Obtaining Tramp.
400 @cindex obtaining Tramp
401
402 @value{tramp} is freely available on the Internet and the latest
403 release may be downloaded from @uref{ftp://ftp.gnu.org/gnu/tramp/}.
404 This release includes the full documentation and code for
405 @value{tramp}, suitable for installation. But Emacs (22 or later)
406 includes @value{tramp} already, and there is a @value{tramp} package
407 for XEmacs, as well. So maybe it is easier to just use those. But if
408 you want the bleeding edge, read on@dots{}
409
410 For the especially brave, @value{tramp} is available from Git. The Git
411 version is the latest version of the code and may contain incomplete
412 features or new issues. Use these versions at your own risk.
413
414 Instructions for obtaining the latest development version of @value{tramp}
415 from Git can be found by going to the Savannah project page at the
416 following URL and then clicking on the Git link in the navigation bar
417 at the top.
418
419 @noindent
420 @uref{http://savannah.gnu.org/projects/tramp/}
421
422 @noindent
423 Or follow the example session below:
424
425 @example
426 ] @strong{cd ~/@value{emacsdir}}
427 ] @strong{git clone git://git.savannah.gnu.org/tramp.git}
428 @end example
429
430 @noindent
431 Tramp developers use instead
432
433 @example
434 ] @strong{git clone login@@git.sv.gnu.org:/srv/git/tramp.git}
435 @end example
436
437 @noindent
438 You should now have a directory @file{~/@value{emacsdir}/tramp}
439 containing the latest version of @value{tramp}. You can fetch the latest
440 updates from the repository by issuing the command:
441
442 @example
443 ] @strong{cd ~/@value{emacsdir}/tramp}
444 ] @strong{git pull}
445 @end example
446
447 @noindent
448 Once you've got updated files from the Git repository, you need to run
449 @command{autoconf} in order to get an up-to-date @file{configure}
450 script:
451
452 @example
453 ] @strong{cd ~/@value{emacsdir}/tramp}
454 ] @strong{autoconf}
455 @end example
456
457
458 @node History
459 @chapter History of @value{tramp}
460 @cindex history
461 @cindex development history
462
463 Development was started end of November 1998. The package was called
464 @file{rssh.el}, back then. It only provided one method to access a
465 file, using @command{ssh} to log in to a remote host and using
466 @command{scp} to transfer the file contents. After a while, the name
467 was changed to @file{rcp.el}, and now it's @value{tramp}. Along the way,
468 many more methods for getting a remote shell and for transferring the
469 file contents were added. Support for VC was added.
470
471 After that, there were added the multi-hop methods in April 2000 and
472 the unification of @value{tramp} and Ange-FTP filenames in July 2002.
473 In July 2004, multi-hop methods have been replaced by proxy hosts.
474 Running commands on remote hosts was introduced in December 2005.
475 @ifset emacsgw
476 Support of gateways exists since April 2007.
477 @end ifset
478 @ifset emacsgvfs
479 GVFS integration started in February 2009.
480 @end ifset
481 @ifset emacs
482 Remote commands on Windows hosts are available since September 2011.
483 @end ifset
484 Ad-hoc multi-hop methods (with a changed syntax) have been reenabled
485 in November 2011. In November 2012, Juergen Hoetzel's
486 @file{tramp-adb.el} has been added.
487
488 In December 2001, @value{tramp} has been added to the XEmacs package
489 repository. Being part of the Emacs repository happened in June 2002,
490 the first release including @value{tramp} was Emacs 22.1.
491
492 @value{tramp} is also a Debian GNU/Linux package since February 2001.
493
494
495 @c Installation chapter is necessary only in case of standalone
496 @c installation. Text taken from trampinst.texi.
497 @ifset installchapter
498 @include trampinst.texi
499 @end ifset
500
501
502 @node Configuration
503 @chapter Configuring @value{tramp} for use
504 @cindex configuration
505
506 @cindex default configuration
507 @value{tramp} is (normally) fully functional when it is initially
508 installed. It is initially configured to use the @command{scp}
509 program to connect to the remote host. So in the easiest case, you
510 just type @kbd{C-x C-f} and then enter the filename
511 @file{@trampfn{, user, machine, /path/to.file}}.
512
513 On some hosts, there are problems with opening a connection. These are
514 related to the behavior of the remote shell. See @xref{Remote shell
515 setup}, for details on this.
516
517 If you do not wish to use these commands to connect to the remote
518 host, you should change the default connection and transfer method
519 that @value{tramp} uses. There are several different methods that @value{tramp}
520 can use to connect to remote machines and transfer files
521 (@pxref{Connection types}).
522
523 If you don't know which method is right for you, see @xref{Default
524 Method}.
525
526
527 @menu
528 * Connection types:: Types of connections made to remote machines.
529 * Inline methods:: Inline methods.
530 * External methods:: External methods.
531 @ifset emacsgvfs
532 * GVFS based methods:: GVFS based external methods.
533 @end ifset
534 @ifset emacsgw
535 * Gateway methods:: Gateway methods.
536 @end ifset
537 * Default Method:: Selecting a default method.
538 Here we also try to help those who
539 don't have the foggiest which method
540 is right for them.
541 * Default User:: Selecting a default user.
542 * Default Host:: Selecting a default host.
543 * Multi-hops:: Connecting to a remote host using multiple hops.
544 * Customizing Methods:: Using Non-Standard Methods.
545 * Customizing Completion:: Selecting config files for user/host name completion.
546 * Password handling:: Reusing passwords for several connections.
547 * Connection caching:: Reusing connection related information.
548 * Predefined connection information::
549 Setting own connection related information.
550 * Remote Programs:: How @value{tramp} finds and uses programs on the remote machine.
551 * Remote shell setup:: Remote shell setup hints.
552 * Android shell setup:: Android shell setup hints.
553 * Auto-save and Backup:: Auto-save and Backup.
554 * Windows setup hints:: Issues with Cygwin ssh.
555 @end menu
556
557
558 @node Connection types
559 @section Types of connections made to remote machines
560 @cindex connection types, overview
561
562 There are two basic types of transfer methods, each with its own
563 advantages and limitations. Both types of connection make use of a
564 remote shell access program such as @command{rsh}, @command{ssh} or
565 @command{telnet} to connect to the remote machine.
566
567 This connection is used to perform many of the operations that @value{tramp}
568 requires to make the remote file system transparently accessible from
569 the local machine. It is only when visiting files that the methods
570 differ.
571
572 @cindex inline methods
573 @cindex external methods
574 @cindex methods, inline
575 @cindex methods, external
576 Loading or saving a remote file requires that the content of the file
577 be transferred between the two machines. The content of the file can
578 be transferred using one of two methods: the @dfn{inline method} over
579 the same connection used to log in to the remote machine, or the
580 @dfn{external method} through another connection using a remote copy
581 program such as @command{rcp}, @command{scp} or @command{rsync}.
582
583 The performance of the external methods is generally better than that
584 of the inline methods, at least for large files. This is caused by
585 the need to encode and decode the data when transferring inline.
586
587 The one exception to this rule are the @command{scp} based transfer
588 methods. While these methods do see better performance when actually
589 transferring files, the overhead of the cryptographic negotiation at
590 startup may drown out the improvement in file transfer times.
591
592 External methods should be configured such a way that they don't
593 require a password (with @command{ssh-agent}, or such alike). Modern
594 @command{scp} implementations offer options to reuse existing
595 @command{ssh} connections, which will be enabled by default if
596 available. If it isn't possible, you should consider @ref{Password
597 handling}, otherwise you will be prompted for a password every copy
598 action.
599
600
601 @node Inline methods
602 @section Inline methods
603 @cindex inline methods
604 @cindex methods, inline
605
606 The inline methods in @value{tramp} are quite powerful and can work in
607 situations where you cannot use an external transfer program to connect.
608 Inline methods are the only methods that work when connecting to the
609 remote machine via telnet. (There are also strange inline methods which
610 allow you to transfer files between @emph{user identities} rather than
611 hosts, see below.)
612
613 These methods depend on the existence of a suitable encoding and
614 decoding command on remote machine. Locally, @value{tramp} may be able to
615 use features of @value{emacsname} to decode and encode the files or
616 it may require access to external commands to perform that task.
617
618 @cindex uuencode
619 @cindex mimencode
620 @cindex base-64 encoding
621 @value{tramp} checks the availability and usability of commands like
622 @command{mimencode} (part of the @command{metamail} package) or
623 @command{uuencode} on the remote host. The first reliable command
624 will be used. The search path can be customized, see @ref{Remote
625 Programs}.
626
627 If both commands aren't available on the remote host, @value{tramp}
628 transfers a small piece of Perl code to the remote host, and tries to
629 apply it for encoding and decoding.
630
631 The variable @var{tramp-inline-compress-start-size} controls, whether
632 a file shall be compressed before encoding. This could increase
633 transfer speed for large text files.
634
635
636 @table @asis
637 @item @option{rsh}
638 @cindex method rsh
639 @cindex rsh method
640
641 Connect to the remote host with @command{rsh}. Due to the unsecure
642 connection it is recommended for very local host topology only.
643
644 On operating systems which provide the command @command{remsh} instead
645 of @command{rsh}, you can use the method @option{remsh}. This is true
646 for HP-UX or Cray UNICOS, for example.
647
648
649 @item @option{ssh}
650 @cindex method ssh
651 @cindex ssh method
652
653 Connect to the remote host with @command{ssh}. This is identical to
654 the previous option except that the @command{ssh} package is used,
655 making the connection more secure.
656
657 All the methods based on @command{ssh} have an additional feature: you
658 can specify a host name which looks like @file{host#42} (the real host
659 name, then a hash sign, then a port number). This means to connect to
660 the given host but to also pass @code{-p 42} as arguments to the
661 @command{ssh} command.
662
663
664 @item @option{telnet}
665 @cindex method telnet
666 @cindex telnet method
667
668 Connect to the remote host with @command{telnet}. This is as unsecure
669 as the @option{rsh} method.
670
671
672 @item @option{su}
673 @cindex method su
674 @cindex su method
675
676 This method does not connect to a remote host at all, rather it uses
677 the @command{su} program to allow you to edit files as another user.
678 That means, the specified host name in the file name must be either
679 @samp{localhost} or the host name as returned by the function
680 @command{(system-name)}. For an exception of this rule see
681 @ref{Multi-hops}.
682
683
684 @item @option{sudo}
685 @cindex method sudo
686 @cindex sudo method
687
688 This is similar to the @option{su} method, but it uses @command{sudo}
689 rather than @command{su} to become a different user.
690
691 Note that @command{sudo} must be configured to allow you to start a
692 shell as the user. It would be nice if it was sufficient if
693 @command{ls} and @command{mimencode} were allowed, but that is not
694 easy to implement, so I haven't got around to it, yet.
695
696
697 @item @option{sshx}
698 @cindex method sshx
699 @cindex sshx method
700
701 As you would expect, this is similar to @option{ssh}, only a little
702 different. Whereas @option{ssh} opens a normal interactive shell on
703 the remote host, this option uses @samp{ssh -t -t @var{host} -l
704 @var{user} /bin/sh} to open a connection. This is useful for users
705 where the normal login shell is set up to ask them a number of
706 questions when logging in. This procedure avoids these questions, and
707 just gives @value{tramp} a more-or-less `standard' login shell to work
708 with.
709
710 Note that this procedure does not eliminate questions asked by
711 @command{ssh} itself. For example, @command{ssh} might ask ``Are you
712 sure you want to continue connecting?'' if the host key of the remote
713 host is not known. @value{tramp} does not know how to deal with such a
714 question (yet), therefore you will need to make sure that you can log
715 in without such questions.
716
717 This is also useful for Windows users where @command{ssh}, when
718 invoked from an @value{emacsname} buffer, tells them that it is not
719 allocating a pseudo tty. When this happens, the login shell is wont
720 to not print any shell prompt, which confuses @value{tramp} mightily.
721
722 This supports the @samp{-p} argument.
723
724
725 @item @option{krlogin}
726 @cindex method krlogin
727 @cindex krlogin method
728 @cindex Kerberos (with krlogin method)
729
730 This method is also similar to @option{ssh}. It only uses the
731 @command{krlogin -x} command to log in to the remote host.
732
733
734 @item @option{ksu}
735 @cindex method ksu
736 @cindex ksu method
737 @cindex Kerberos (with ksu method)
738
739 This is another method from the Kerberos suite. It behaves like @option{su}.
740
741
742 @item @option{plink}
743 @cindex method plink
744 @cindex plink method
745
746 This method is mostly interesting for Windows users using the PuTTY
747 implementation of SSH@. It uses @samp{plink -ssh} to log in to the
748 remote host.
749
750 This supports the @samp{-P} argument.
751
752
753 @item @option{plinkx}
754 @cindex method plinkx
755 @cindex plinkx method
756
757 Another method using PuTTY on Windows. Instead of host names, it
758 expects PuTTY session names, calling @samp{plink -load @var{session}
759 -t"}. User names are relevant only in case the corresponding session
760 hasn't defined a user name. Different port numbers must be defined in
761 the session.
762
763 @end table
764
765
766 @node External methods
767 @section External methods
768 @cindex methods, external
769 @cindex external methods
770
771 The external methods operate through multiple channels, using the
772 remote shell connection for many actions while delegating file
773 transfers to an external transfer utility.
774
775 This saves the overhead of encoding and decoding that multiplexing the
776 transfer through the one connection has with the inline methods.
777
778 Since external methods need their own overhead opening a new channel,
779 all files which are smaller than @var{tramp-copy-size-limit} are still
780 transferred with the corresponding inline method. It should provide a
781 fair trade-off between both approaches.
782
783 @table @asis
784 @item @option{rcp}---@command{rsh} and @command{rcp}
785 @cindex method rcp
786 @cindex rcp method
787 @cindex rcp (with rcp method)
788 @cindex rsh (with rcp method)
789
790 This method uses the @command{rsh} and @command{rcp} commands to connect
791 to the remote machine and transfer files. This is probably the fastest
792 connection method available.
793
794 The alternative method @option{remcp} uses the @command{remsh} and
795 @command{rcp} commands. It should be applied on machines where
796 @command{remsh} is used instead of @command{rsh}.
797
798
799 @item @option{scp}---@command{ssh} and @command{scp}
800 @cindex method scp
801 @cindex scp method
802 @cindex scp (with scp method)
803 @cindex ssh (with scp method)
804
805 Using @command{ssh} to connect to the remote host and @command{scp} to
806 transfer files between the machines is the best method for securely
807 connecting to a remote machine and accessing files.
808
809 The performance of this option is also quite good. It may be slower than
810 the inline methods when you often open and close small files however.
811 The cost of the cryptographic handshake at the start of an @command{scp}
812 session can begin to absorb the advantage that the lack of encoding and
813 decoding presents.
814
815 All the @command{ssh} based methods support the @samp{-p} feature
816 where you can specify a port number to connect to in the host name.
817 For example, the host name @file{host#42} tells @value{tramp} to
818 specify @samp{-p 42} in the argument list for @command{ssh}, and to
819 specify @samp{-P 42} in the argument list for @command{scp}.
820
821
822 @item @option{sftp}---@command{ssh} and @command{sftp}
823 @cindex method sftp
824 @cindex sftp method
825 @cindex sftp (with sftp method)
826 @cindex ssh (with sftp method)
827
828 That is mostly the same method as @option{scp}, but using
829 @command{sftp} as transfer command. So the same remarks are valid.
830
831 This command does not work like @value{ftppackagename}, where
832 @command{ftp} is called interactively, and all commands are send from
833 within this session. Instead of, @command{ssh} is used for login.
834
835 This method supports the @samp{-p} argument.
836
837
838 @item @option{rsync}---@command{ssh} and @command{rsync}
839 @cindex method rsync
840 @cindex rsync method
841 @cindex rsync (with rsync method)
842 @cindex ssh (with rsync method)
843
844 Using the @command{ssh} command to connect securely to the remote
845 machine and the @command{rsync} command to transfer files is almost
846 identical to the @option{scp} method.
847
848 While @command{rsync} performs much better than @command{scp} when
849 transferring files that exist on both hosts, this advantage is lost if
850 the file exists only on one side of the connection. A file can exists
851 on both the remote and local host, when you copy a file from/to a
852 remote host. When you just open a file from the remote host (or write
853 a file there), a temporary file on the local side is kept as long as
854 the corresponding buffer, visiting this file, is alive.
855
856 This method supports the @samp{-p} argument.
857
858
859 @item @option{scpx}---@command{ssh} and @command{scp}
860 @cindex method scpx
861 @cindex scpx method
862 @cindex scp (with scpx method)
863 @cindex ssh (with scpx method)
864
865 As you would expect, this is similar to @option{scp}, only a little
866 different. Whereas @option{scp} opens a normal interactive shell on
867 the remote host, this option uses @samp{ssh -t -t @var{host} -l
868 @var{user} /bin/sh} to open a connection. This is useful for users
869 where the normal login shell is set up to ask them a number of
870 questions when logging in. This procedure avoids these questions, and
871 just gives @value{tramp} a more-or-less `standard' login shell to work
872 with.
873
874 This is also useful for Windows users where @command{ssh}, when
875 invoked from an @value{emacsname} buffer, tells them that it is not
876 allocating a pseudo tty. When this happens, the login shell is wont
877 to not print any shell prompt, which confuses @value{tramp} mightily.
878
879 This method supports the @samp{-p} argument.
880
881
882 @item @option{pscp}---@command{plink} and @command{pscp}
883 @cindex method pscp
884 @cindex pscp method
885 @cindex pscp (with pscp method)
886 @cindex plink (with pscp method)
887 @cindex PuTTY (with pscp method)
888
889 This method is similar to @option{scp}, but it uses the
890 @command{plink} command to connect to the remote host, and it uses
891 @command{pscp} for transferring the files. These programs are part
892 of PuTTY, an SSH implementation for Windows.
893
894 This method supports the @samp{-P} argument.
895
896
897 @item @option{psftp}---@command{plink} and @command{psftp}
898 @cindex method psftp
899 @cindex psftp method
900 @cindex psftp (with psftp method)
901 @cindex plink (with psftp method)
902 @cindex PuTTY (with psftp method)
903
904 As you would expect, this method is similar to @option{sftp}, but it
905 uses the @command{plink} command to connect to the remote host, and it
906 uses @command{psftp} for transferring the files. These programs are
907 part of PuTTY, an SSH implementation for Windows.
908
909 This method supports the @samp{-P} argument.
910
911
912 @item @option{fcp}---@command{fsh} and @command{fcp}
913 @cindex method fcp
914 @cindex fcp method
915 @cindex fsh (with fcp method)
916 @cindex fcp (with fcp method)
917
918 This method is similar to @option{scp}, but it uses the @command{fsh}
919 command to connect to the remote host, and it uses @command{fcp} for
920 transferring the files. @command{fsh/fcp} are a front-end for
921 @command{ssh} which allow for reusing the same @command{ssh} session
922 for submitting several commands. This avoids the startup overhead of
923 @command{scp} (which has to establish a secure connection whenever it
924 is called). Note, however, that you can also use one of the inline
925 methods to achieve a similar effect.
926
927 This method uses the command @samp{fsh @var{host} -l @var{user}
928 /bin/sh -i} to establish the connection, it does not work to just say
929 @command{fsh @var{host} -l @var{user}}.
930
931 @cindex method fsh
932 @cindex fsh method
933
934 There is no inline method using @command{fsh} as the multiplexing
935 provided by the program is not very useful in our context. @value{tramp}
936 opens just one connection to the remote host and then keeps it open,
937 anyway.
938
939
940 @item @option{ftp}
941 @cindex method ftp
942 @cindex ftp method
943
944 This is not a native @value{tramp} method. Instead, it forwards all
945 requests to @value{ftppackagename}.
946 @ifset xemacs
947 This works only for unified filenames, see @ref{Issues}.
948 @end ifset
949
950
951 @item @option{smb}---@command{smbclient}
952 @cindex method smb
953 @cindex smb method
954
955 This is another not native @value{tramp} method. It uses the
956 @command{smbclient} command on different Unices in order to connect to
957 an SMB server. An SMB server might be a Samba (or CIFS) server on
958 another UNIX host or, more interesting, a host running MS Windows. So
959 far, it is tested against MS Windows NT, MS Windows 2000, MS Windows
960 XP, MS Windows Vista, and MS Windows 7.
961
962 The first directory in the localname must be a share name on the remote
963 host. Remember that the @code{$} character, in which default shares
964 usually end, must be written @code{$$} due to environment variable
965 substitution in file names. If no share name is given (i.e., remote
966 directory @code{/}), all available shares are listed.
967
968 Since authorization is done on share level, you will always be
969 prompted for a password if you access another share on the same host.
970 This can be suppressed by @ref{Password handling}.
971
972 For authorization, MS Windows uses both a user name and a domain name.
973 Because of this, the @value{tramp} syntax has been extended: you can
974 specify a user name which looks like @code{user%domain} (the real user
975 name, then a percent sign, then the domain name). So, to connect to
976 the machine @code{melancholia} as user @code{daniel} of the domain
977 @code{BIZARRE}, and edit @file{.emacs} in the home directory (share
978 @code{daniel$}) I would specify the filename @file{@trampfn{smb,
979 daniel%BIZARRE, melancholia, /daniel$$/.emacs}}.
980
981 Depending on the Windows domain configuration, a Windows user might be
982 considered as domain user per default. In order to connect as local
983 user, the WINS name of that machine must be given as domain name.
984 Usually, it is the machine name in capital letters. In the example
985 above, the local user @code{daniel} would be specified as
986 @file{@trampfn{smb, daniel%MELANCHOLIA, melancholia, /daniel$$/.emacs}}.
987
988 The domain name as well as the user name are optional. If no user
989 name is specified at all, the anonymous user (without password
990 prompting) is assumed. This is different from all other @value{tramp}
991 methods, where in such a case the local user name is taken.
992
993 The @option{smb} method supports the @samp{-p} argument.
994
995 @strong{Please note:} If @value{emacsname} runs locally under MS
996 Windows, this method isn't available. Instead, you can use UNC
997 file names like @file{//melancholia/daniel$$/.emacs}. The only
998 disadvantage is that there's no possibility to specify another user
999 name.
1000
1001
1002 @item @option{adb}
1003 @cindex method adb
1004 @cindex adb method
1005
1006 This special method uses the Android Debug Bridge for accessing
1007 Android devices. The Android Debug Bridge must be installed locally.
1008 Some GNU/Linux distributions offer it for installation, otherwise it
1009 can be installed as part of the Android SDK. If the @command{adb}
1010 program is not found via the @env{PATH} environment variable, the
1011 variable @var{tramp-adb-program} must point to its absolute path.
1012
1013 Tramp does not connect Android devices to @command{adb}. This must be
1014 performed outside @value{emacsname}. If there is exactly one Android
1015 device connected to @command{adb}, a host name is not needed in the
1016 remote file name. The default @value{tramp} name to be used is
1017 @file{@trampfn{adb, , ,}} therefore. Otherwise, one could find
1018 potential host names with the command @command{adb devices}.
1019
1020 Usually, the @command{adb} method does not need any user name. It
1021 runs under the permissions of the @command{adbd} process on the
1022 Android device. If a user name is specified, @value{tramp} applies an
1023 @command{su} on the device. This does not work with all Android
1024 devices, especially with unrooted ones. In that case, an error
1025 message is displayed.
1026
1027 @end table
1028
1029
1030 @ifset emacsgvfs
1031 @node GVFS based methods
1032 @section GVFS based external methods
1033 @cindex methods, gvfs
1034 @cindex gvfs based methods
1035 @cindex dbus
1036
1037 The connection methods described in this section are based on GVFS
1038 @uref{http://en.wikipedia.org/wiki/GVFS}. Via GVFS, the remote
1039 filesystem is mounted locally through FUSE@. @value{tramp} uses
1040 this local mounted directory internally.
1041
1042 The communication with GVFS is implemented via D-Bus messages.
1043 Therefore, your @value{emacsname} must have D-Bus integration,
1044 @pxref{Top, , D-Bus, dbus}.
1045
1046 @table @asis
1047 @item @option{dav}
1048 @cindex method dav
1049 @cindex method davs
1050 @cindex dav method
1051 @cindex davs method
1052
1053 This method provides access to WebDAV files and directories. There
1054 exists also the external method @option{davs}, which uses SSL
1055 encryption for the access.
1056
1057 Both methods support the port number specification as discussed above.
1058
1059
1060 @item @option{obex}
1061 @cindex method obex
1062 @cindex obex method
1063
1064 OBEX is an FTP-like access protocol for simple devices, like cell
1065 phones. For the time being, @value{tramp} only supports OBEX over Bluetooth.
1066
1067
1068 @item @option{synce}
1069 @cindex method synce
1070 @cindex synce method
1071
1072 The @option{synce} method allows communication with Windows Mobile
1073 devices. Beside GVFS for mounting remote files and directories via
1074 FUSE, it also needs the SYNCE-GVFS plugin.
1075
1076 @end table
1077
1078 @defopt tramp-gvfs-methods
1079 This customer option, a list, defines the external methods which
1080 shall be used with GVFS@. Per default, these are @option{dav},
1081 @option{davs}, @option{obex} and @option{synce}. Other possible
1082 values are @option{ftp}, @option{sftp} and @option{smb}.
1083 @end defopt
1084 @end ifset
1085
1086
1087 @ifset emacsgw
1088 @node Gateway methods
1089 @section Gateway methods
1090 @cindex methods, gateway
1091 @cindex gateway methods
1092
1093 Gateway methods are not methods to access a remote host directly.
1094 These methods are intended to pass firewalls or proxy servers.
1095 Therefore, they can be used for proxy host declarations
1096 (@pxref{Multi-hops}) only.
1097
1098 A gateway method must always come along with a method which supports
1099 port setting. This is because @value{tramp} targets the accompanied
1100 method to @file{localhost#random_port}, from where the firewall or
1101 proxy server is accessed.
1102
1103 Gateway methods support user name and password declarations. These
1104 are used to authenticate towards the corresponding firewall or proxy
1105 server. They can be passed only if your friendly administrator has
1106 granted your access.
1107
1108 @table @asis
1109 @item @option{tunnel}
1110 @cindex method tunnel
1111 @cindex tunnel method
1112
1113 This method implements an HTTP tunnel via the @command{CONNECT}
1114 command (see RFC 2616, 2817). Any HTTP 1.1 compliant (proxy) server
1115 shall support this command.
1116
1117 As authentication method, only @option{Basic Authentication} (see RFC
1118 2617) is implemented so far. If no port number is given in the
1119 declaration, port @option{8080} is used for the proxy server.
1120
1121
1122 @item @option{socks}
1123 @cindex method socks
1124 @cindex socks method
1125
1126 The @command{socks} method provides access to SOCKSv5 servers (see
1127 RFC 1928). @option{Username/Password Authentication} according to RFC
1128 1929 is supported.
1129
1130 The default port number of the socks server is @option{1080}, if not
1131 specified otherwise.
1132
1133 @end table
1134 @end ifset
1135
1136
1137 @node Default Method
1138 @section Selecting a default method
1139 @cindex default method
1140
1141 @vindex tramp-default-method
1142 When you select an appropriate transfer method for your typical usage
1143 you should set the variable @code{tramp-default-method} to reflect that
1144 choice. This variable controls which method will be used when a method
1145 is not specified in the @value{tramp} file name. For example:
1146
1147 @lisp
1148 (setq tramp-default-method "ssh")
1149 @end lisp
1150
1151 @vindex tramp-default-method-alist
1152 You can also specify different methods for certain user/host
1153 combinations, via the variable @code{tramp-default-method-alist}. For
1154 example, the following two lines specify to use the @option{ssh}
1155 method for all user names matching @samp{john} and the @option{rsync}
1156 method for all host names matching @samp{lily}. The third line
1157 specifies to use the @option{su} method for the user @samp{root} on
1158 the machine @samp{localhost}.
1159
1160 @lisp
1161 (add-to-list 'tramp-default-method-alist '("" "john" "ssh"))
1162 (add-to-list 'tramp-default-method-alist '("lily" "" "rsync"))
1163 (add-to-list 'tramp-default-method-alist
1164 '("\\`localhost\\'" "\\`root\\'" "su"))
1165 @end lisp
1166
1167 @noindent
1168 See the documentation for the variable
1169 @code{tramp-default-method-alist} for more details.
1170
1171 External methods are normally preferable to inline methods, giving
1172 better performance.
1173
1174 @xref{Inline methods}.
1175 @xref{External methods}.
1176
1177 Another consideration with the selection of transfer methods is the
1178 environment you will use them in and, especially when used over the
1179 Internet, the security implications of your preferred method.
1180
1181 The @option{rsh} and @option{telnet} methods send your password as
1182 plain text as you log in to the remote machine, as well as
1183 transferring the files in such a way that the content can easily be
1184 read from other machines.
1185
1186 If you need to connect to remote systems that are accessible from the
1187 Internet, you should give serious thought to using @option{ssh} based
1188 methods to connect. These provide a much higher level of security,
1189 making it a non-trivial exercise for someone to obtain your password
1190 or read the content of the files you are editing.
1191
1192
1193 @subsection Which method is the right one for me?
1194 @cindex choosing the right method
1195
1196 Given all of the above, you are probably thinking that this is all fine
1197 and good, but it's not helping you to choose a method! Right you are.
1198 As a developer, we don't want to boss our users around but give them
1199 maximum freedom instead. However, the reality is that some users would
1200 like to have some guidance, so here I'll try to give you this guidance
1201 without bossing you around. You tell me whether it works @dots{}
1202
1203 My suggestion is to use an inline method. For large files, external
1204 methods might be more efficient, but I guess that most people will
1205 want to edit mostly small files. And if you access large text files,
1206 compression (driven by @var{tramp-inline-compress-start-size}) shall
1207 still result in good performance.
1208
1209 I guess that these days, most people can access a remote machine by
1210 using @command{ssh}. So I suggest that you use the @option{ssh}
1211 method. So, type @kbd{C-x C-f @trampfn{ssh, root, otherhost,
1212 /etc/motd} @key{RET}} to edit the @file{/etc/motd} file on the other
1213 host.
1214
1215 If you can't use @option{ssh} to log in to the remote host, then
1216 select a method that uses a program that works. For instance, Windows
1217 users might like the @option{plink} method which uses the PuTTY
1218 implementation of @command{ssh}. Or you use Kerberos and thus like
1219 @option{krlogin}.
1220
1221 For the special case of editing files on the local host as another
1222 user, see the @option{su} or @option{sudo} methods. They offer
1223 shortened syntax for the @samp{root} account, like
1224 @file{@trampfn{su, , , /etc/motd}}.
1225
1226 People who edit large files may want to consider @option{scp} instead
1227 of @option{ssh}, or @option{pscp} instead of @option{plink}. These
1228 external methods are faster than inline methods for large files.
1229 Note, however, that external methods suffer from some limitations.
1230 Please try first whether you really get a noticeable speed advantage
1231 from using an external method! Maybe even for large files, inline
1232 methods are fast enough.
1233
1234
1235 @node Default User
1236 @section Selecting a default user
1237 @cindex default user
1238
1239 The user part of a @value{tramp} file name can be omitted. Usually,
1240 it is replaced by the user name you are logged in. Often, this is not
1241 what you want. A typical use of @value{tramp} might be to edit some
1242 files with root permissions on the local host. This case, you should
1243 set the variable @code{tramp-default-user} to reflect that choice.
1244 For example:
1245
1246 @lisp
1247 (setq tramp-default-user "root")
1248 @end lisp
1249
1250 @code{tramp-default-user} is regarded as obsolete, and will be removed
1251 soon.
1252
1253 @vindex tramp-default-user-alist
1254 You can also specify different users for certain method/host
1255 combinations, via the variable @code{tramp-default-user-alist}. For
1256 example, if you always have to use the user @samp{john} in the domain
1257 @samp{somewhere.else}, you can specify the following:
1258
1259 @lisp
1260 (add-to-list 'tramp-default-user-alist
1261 '("ssh" ".*\\.somewhere\\.else\\'" "john"))
1262 @end lisp
1263
1264 @noindent
1265 See the documentation for the variable @code{tramp-default-user-alist}
1266 for more details.
1267
1268 One trap to fall in must be known. If @value{tramp} finds a default
1269 user, this user will be passed always to the connection command as
1270 parameter (for example @command{ssh here.somewhere.else -l john}. If
1271 you have specified another user for your command in its configuration
1272 files, @value{tramp} cannot know it, and the remote access will fail.
1273 If you have specified in the given example in @file{~/.ssh/config} the
1274 lines
1275
1276 @example
1277 Host here.somewhere.else
1278 User lily
1279 @end example
1280
1281 @noindent
1282 than you must discard selecting a default user by @value{tramp}. This
1283 will be done by setting it to @code{nil} (or @samp{lily}, likewise):
1284
1285 @lisp
1286 (add-to-list 'tramp-default-user-alist
1287 '("ssh" "\\`here\\.somewhere\\.else\\'" nil))
1288 @end lisp
1289
1290 The last entry in @code{tramp-default-user-alist} could be your
1291 default user you'll apply predominantly. You shall @emph{append} it
1292 to that list at the end:
1293
1294 @lisp
1295 (add-to-list 'tramp-default-user-alist '(nil nil "jonas") t)
1296 @end lisp
1297
1298
1299 @node Default Host
1300 @section Selecting a default host
1301 @cindex default host
1302
1303 @vindex tramp-default-host
1304 Finally, it is even possible to omit the host name part of a
1305 @value{tramp} file name. This case, the value of the variable
1306 @code{tramp-default-host} is used. Per default, it is initialized
1307 with the host name your local @value{emacsname} is running.
1308
1309 If you, for example, use @value{tramp} mainly to contact the host
1310 @samp{target} as user @samp{john}, you can specify:
1311
1312 @lisp
1313 (setq tramp-default-user "john"
1314 tramp-default-host "target")
1315 @end lisp
1316
1317 Then the simple file name @samp{@trampfn{ssh, , ,}} will connect you
1318 to John's home directory on target.
1319 @ifset emacs
1320 Note, however, that the most simplification @samp{/::} won't work,
1321 because @samp{/:} is the prefix for quoted file names.
1322 @end ifset
1323
1324 @vindex tramp-default-host-alist
1325 Like with methods and users, you can also specify different default
1326 hosts for certain method/user combinations via the variable
1327 @code{tramp-default-host-alist}. Usually, this isn't necessary,
1328 because @code{tramp-default-host} should be sufficient. For some
1329 methods, like @option{adb}, that default value must be overwritten,
1330 which is already the initial value of @code{tramp-default-host-alist}.
1331
1332 @noindent
1333 See the documentation for the variable @code{tramp-default-host-alist}
1334 for more details.
1335
1336
1337 @node Multi-hops
1338 @section Connecting to a remote host using multiple hops
1339 @cindex multi-hop
1340 @cindex proxy hosts
1341
1342 Sometimes, the methods described before are not sufficient.
1343 Sometimes, it is not possible to connect to a remote host using a
1344 simple command. For example, if you are in a secured network, you
1345 might have to log in to a bastion host first before you can connect to
1346 the outside world. Of course, the target host may also require a
1347 bastion host.
1348
1349 @vindex tramp-default-proxies-alist
1350 @defopt tramp-default-proxies-alist
1351 In order to specify multiple hops, it is possible to define a proxy
1352 host to pass through, via the variable
1353 @code{tramp-default-proxies-alist}. This variable keeps a list of
1354 triples (@var{host} @var{user} @var{proxy}).
1355
1356 The first matching item specifies the proxy host to be passed for a
1357 file name located on a remote target matching @var{user}@@@var{host}.
1358 @var{host} and @var{user} are regular expressions or @code{nil}, which
1359 is interpreted as a regular expression which always matches.
1360
1361 @var{proxy} must be a Tramp filename which localname part is ignored.
1362 Method and user name on @var{proxy} are optional, which is interpreted
1363 with the default values.
1364 @ifset emacsgw
1365 The method must be an inline or gateway method (@pxref{Inline
1366 methods}, @pxref{Gateway methods}).
1367 @end ifset
1368 @ifclear emacsgw
1369 The method must be an inline method (@pxref{Inline methods}).
1370 @end ifclear
1371 If @var{proxy} is @code{nil}, no additional hop is required reaching
1372 @var{user}@@@var{host}.
1373
1374 If you, for example, must pass the host @samp{bastion.your.domain} as
1375 user @samp{bird} for any remote host which is not located in your local
1376 domain, you can set
1377
1378 @lisp
1379 (add-to-list 'tramp-default-proxies-alist
1380 '("\\." nil "@trampfn{ssh, bird, bastion.your.domain,}"))
1381 (add-to-list 'tramp-default-proxies-alist
1382 '("\\.your\\.domain\\'" nil nil))
1383 @end lisp
1384
1385 Please note the order of the code. @code{add-to-list} adds elements at the
1386 beginning of a list. Therefore, most relevant rules must be added last.
1387
1388 Proxy hosts can be cascaded. If there is another host called
1389 @samp{jump.your.domain}, which is the only one in your local domain who
1390 is allowed connecting @samp{bastion.your.domain}, you can add another
1391 rule:
1392
1393 @lisp
1394 (add-to-list 'tramp-default-proxies-alist
1395 '("\\`bastion\\.your\\.domain\\'"
1396 "\\`bird\\'"
1397 "@trampfn{ssh, , jump.your.domain,}"))
1398 @end lisp
1399
1400 @var{proxy} can contain the patterns @code{%h} or @code{%u}. These
1401 patterns are replaced by the strings matching @var{host} or
1402 @var{user}, respectively.
1403
1404 If you, for example, wants to work as @samp{root} on hosts in the
1405 domain @samp{your.domain}, but login as @samp{root} is disabled for
1406 non-local access, you might add the following rule:
1407
1408 @lisp
1409 (add-to-list 'tramp-default-proxies-alist
1410 '("\\.your\\.domain\\'" "\\`root\\'" "@trampfn{ssh, , %h,}"))
1411 @end lisp
1412
1413 Opening @file{@trampfn{sudo, , randomhost.your.domain,}} would connect
1414 first @samp{randomhost.your.domain} via @code{ssh} under your account
1415 name, and perform @code{sudo -u root} on that host afterwards. It is
1416 important to know that the given method is applied on the host which
1417 has been reached so far. @code{sudo -u root}, applied on your local
1418 host, wouldn't be useful here.
1419
1420 @var{host}, @var{user} and @var{proxy} can also be Lisp forms. These
1421 forms are evaluated, and must return a string, or @code{nil}. The
1422 previous example could be generalized then: For all hosts except my
1423 local one connect via @command{ssh} first, and apply @command{sudo -u
1424 root} afterwards:
1425
1426 @lisp
1427 (add-to-list 'tramp-default-proxies-alist
1428 '(nil "\\`root\\'" "@trampfn{ssh, , %h,}"))
1429 (add-to-list 'tramp-default-proxies-alist
1430 '((regexp-quote (system-name)) nil nil))
1431 @end lisp
1432
1433 This is the recommended configuration to work as @samp{root} on remote
1434 Ubuntu hosts.
1435
1436 @ifset emacsgw
1437 Finally, @code{tramp-default-proxies-alist} can be used to pass
1438 firewalls or proxy servers. Imagine your local network has a host
1439 @samp{proxy.your.domain} which is used on port 3128 as HTTP proxy to
1440 the outer world. Your friendly administrator has granted you access
1441 under your user name to @samp{host.other.domain} on that proxy
1442 server.@footnote{HTTP tunnels are intended for secure SSL/TLS
1443 communication. Therefore, many proxy server restrict the tunnels to
1444 related target ports. You might need to run your ssh server on your
1445 target host @samp{host.other.domain} on such a port, like 443 (https).
1446 See @uref{http://savannah.gnu.org/maintenance/CvsFromBehindFirewall}
1447 for discussion of ethical issues.} You would need to add the
1448 following rule:
1449
1450 @lisp
1451 (add-to-list 'tramp-default-proxies-alist
1452 '("\\`host\\.other\\.domain\\'" nil
1453 "@trampfn{tunnel, , proxy.your.domain#3128,}"))
1454 @end lisp
1455
1456 Gateway methods can be declared as first hop only in a multiple hop
1457 chain.
1458 @end ifset
1459 @end defopt
1460
1461 Hops to be passed tend to be restricted firewalls and alike.
1462 Sometimes they offer limited features only, like running @command{rbash}
1463 (restricted bash). This must be told to @value{tramp}.
1464
1465 @vindex tramp-restricted-shell-hosts-alist
1466 @defopt tramp-restricted-shell-hosts-alist
1467 This variable keeps a list of regular expressions, which denote hosts
1468 running a registered shell like "rbash". Those hosts can be used as
1469 proxies only.
1470
1471 If the bastion host from the example above runs a restricted shell,
1472 you shall apply
1473
1474 @lisp
1475 (add-to-list 'tramp-restricted-shell-hosts-alist
1476 "\\`bastion\\.your\\.domain\\'")
1477 @end lisp
1478 @end defopt
1479
1480
1481 @node Customizing Methods
1482 @section Using Non-Standard Methods
1483 @cindex customizing methods
1484 @cindex using non-standard methods
1485 @cindex create your own methods
1486
1487 There is a variable @code{tramp-methods} which you can change if the
1488 predefined methods don't seem right.
1489
1490 For the time being, I'll refer you to the Lisp documentation of that
1491 variable, accessible with @kbd{C-h v tramp-methods @key{RET}}.
1492
1493
1494 @node Customizing Completion
1495 @section Selecting config files for user/host name completion
1496 @cindex customizing completion
1497 @cindex selecting config files
1498 @vindex tramp-completion-function-alist
1499
1500 The variable @code{tramp-completion-function-alist} is intended to
1501 customize which files are taken into account for user and host name
1502 completion (@pxref{Filename completion}). For every method, it keeps
1503 a set of configuration files, accompanied by a Lisp function able to
1504 parse that file. Entries in @code{tramp-completion-function-alist}
1505 have the form (@var{method} @var{pair1} @var{pair2} ...).
1506
1507 Each @var{pair} is composed of (@var{function} @var{file}).
1508 @var{function} is responsible to extract user names and host names
1509 from @var{file} for completion. There are two functions which access
1510 this variable:
1511
1512 @defun tramp-get-completion-function method
1513 This function returns the list of completion functions for @var{method}.
1514
1515 Example:
1516 @example
1517 (tramp-get-completion-function "rsh")
1518
1519 @result{} ((tramp-parse-rhosts "/etc/hosts.equiv")
1520 (tramp-parse-rhosts "~/.rhosts"))
1521 @end example
1522 @end defun
1523
1524 @defun tramp-set-completion-function method function-list
1525 This function sets @var{function-list} as list of completion functions
1526 for @var{method}.
1527
1528 Example:
1529 @example
1530 (tramp-set-completion-function "ssh"
1531 '((tramp-parse-sconfig "/etc/ssh_config")
1532 (tramp-parse-sconfig "~/.ssh/config")))
1533
1534 @result{} ((tramp-parse-sconfig "/etc/ssh_config")
1535 (tramp-parse-sconfig "~/.ssh/config"))
1536 @end example
1537 @end defun
1538
1539 The following predefined functions parsing configuration files exist:
1540
1541 @table @asis
1542 @item @code{tramp-parse-rhosts}
1543 @findex tramp-parse-rhosts
1544
1545 This function parses files which are syntactical equivalent to
1546 @file{~/.rhosts}. It returns both host names and user names, if
1547 specified.
1548
1549 @item @code{tramp-parse-shosts}
1550 @findex tramp-parse-shosts
1551
1552 This function parses files which are syntactical equivalent to
1553 @file{~/.ssh/known_hosts}. Since there are no user names specified
1554 in such files, it can return host names only.
1555
1556 @item @code{tramp-parse-sconfig}
1557 @findex tramp-parse-shosts
1558
1559 This function returns the host nicknames defined by @code{Host} entries
1560 in @file{~/.ssh/config} style files.
1561
1562 @item @code{tramp-parse-shostkeys}
1563 @findex tramp-parse-shostkeys
1564
1565 SSH2 parsing of directories @file{/etc/ssh2/hostkeys/*} and
1566 @file{~/ssh2/hostkeys/*}. Hosts are coded in file names
1567 @file{hostkey_@var{portnumber}_@var{host-name}.pub}. User names
1568 are always @code{nil}.
1569
1570 @item @code{tramp-parse-sknownhosts}
1571 @findex tramp-parse-shostkeys
1572
1573 Another SSH2 style parsing of directories like
1574 @file{/etc/ssh2/knownhosts/*} and @file{~/ssh2/knownhosts/*}. This
1575 case, hosts names are coded in file names
1576 @file{@var{host-name}.@var{algorithm}.pub}. User names are always @code{nil}.
1577
1578 @item @code{tramp-parse-hosts}
1579 @findex tramp-parse-hosts
1580
1581 A function dedicated to @file{/etc/hosts} style files. It returns
1582 host names only.
1583
1584 @item @code{tramp-parse-passwd}
1585 @findex tramp-parse-passwd
1586
1587 A function which parses @file{/etc/passwd} like files. Obviously, it
1588 can return user names only.
1589
1590 @item @code{tramp-parse-netrc}
1591 @findex tramp-parse-netrc
1592
1593 Finally, a function which parses @file{~/.netrc} like files. This
1594 includes also @file{~/.authinfo}-style files.
1595
1596 @end table
1597
1598 If you want to keep your own data in a file, with your own structure,
1599 you might provide such a function as well. This function must meet
1600 the following conventions:
1601
1602 @defun my-tramp-parse file
1603 @var{file} must be either a file name on your host, or @code{nil}.
1604 The function must return a list of (@var{user} @var{host}), which are
1605 taken as candidates for user and host name completion.
1606
1607 Example:
1608 @example
1609 (my-tramp-parse "~/.my-tramp-hosts")
1610
1611 @result{} ((nil "toto") ("daniel" "melancholia"))
1612 @end example
1613 @end defun
1614
1615
1616 @node Password handling
1617 @section Reusing passwords for several connections
1618 @cindex passwords
1619
1620 Sometimes it is necessary to connect to the same remote host several
1621 times. Reentering passwords again and again would be annoying, when
1622 the chosen method does not support access without password prompt
1623 through own configuration.
1624
1625 The best recommendation is to use the method's own mechanism for
1626 password handling. Consider @command{ssh-agent} for @option{ssh}-like
1627 methods, or @command{pageant} for @option{plink}-like methods.
1628
1629 However, if you cannot apply such native password handling,
1630 @value{tramp} offers alternatives.
1631
1632
1633 @anchor{Using an authentication file}
1634 @subsection Using an authentication file
1635
1636 @vindex auth-sources
1637 The package @file{auth-source.el}, originally developed in No Gnus,
1638 offers the possibility to read passwords from a file, like FTP does it
1639 from @file{~/.netrc}. The default authentication file is
1640 @file{~/.authinfo.gpg}, this can be changed via the variable
1641 @code{auth-sources}.
1642
1643 @noindent
1644 A typical entry in the authentication file would be
1645
1646 @example
1647 machine melancholia port scp login daniel password geheim
1648 @end example
1649
1650 The port can be any @value{tramp} method (@pxref{Inline methods},
1651 @pxref{External methods}), to match only this method. When you omit
1652 the port, you match all @value{tramp} methods.
1653
1654 In case of problems, setting @code{auth-source-debug} to @code{t}
1655 gives useful debug messages.
1656
1657
1658 @anchor{Caching passwords}
1659 @subsection Caching passwords
1660
1661 If there is no authentication file, @value{tramp} caches the passwords
1662 entered by you. They will be reused next time if a connection needs
1663 them for the same user name and host name, independently of the
1664 connection method.
1665
1666 @vindex password-cache-expiry
1667 Passwords are not saved permanently, that means the password caching
1668 is limited to the lifetime of your @value{emacsname} session. You
1669 can influence the lifetime of password caching by customizing the
1670 variable @code{password-cache-expiry}. The value is the number of
1671 seconds how long passwords are cached. Setting it to @code{nil}
1672 disables the expiration.
1673
1674 @vindex password-cache
1675 If you don't like this feature for security reasons, password caching
1676 can be disabled totally by customizing the variable
1677 @code{password-cache} (setting it to @code{nil}).
1678
1679 Implementation Note: password caching is based on the package
1680 @file{password-cache.el}. For the time being, it is activated only
1681 when this package is seen in the @code{load-path} while loading
1682 @value{tramp}.
1683 @ifset installchapter
1684 If you don't use No Gnus, you can take @file{password.el} from the
1685 @value{tramp} @file{contrib} directory, see @ref{Installation
1686 parameters}.
1687 @end ifset
1688
1689
1690 @node Connection caching
1691 @section Reusing connection related information
1692 @cindex caching
1693
1694 @vindex tramp-persistency-file-name
1695 In order to reduce initial connection time, @value{tramp} stores
1696 connection related information persistently. The variable
1697 @code{tramp-persistency-file-name} keeps the file name where these
1698 information are written. Its default value is
1699 @ifset emacs
1700 @file{~/.emacs.d/tramp}.
1701 @end ifset
1702 @ifset xemacs
1703 @file{~/.xemacs/tramp}.
1704 @end ifset
1705 It is recommended to choose a local file name.
1706
1707 @value{tramp} reads this file during startup, and writes it when
1708 exiting @value{emacsname}. You can simply remove this file if
1709 @value{tramp} shall be urged to recompute these information next
1710 @value{emacsname} startup time.
1711
1712 Using such persistent information can be disabled by setting
1713 @code{tramp-persistency-file-name} to @code{nil}.
1714
1715 Once consequence of reusing connection related information is that
1716 @var{tramp} needs to distinguish hosts. If you, for example, run a
1717 local @code{sshd} on port 3001, which tunnels @command{ssh} to another
1718 host, you could access both @file{@trampfn{ssh, , localhost,}} and
1719 @file{@trampfn{ssh, , localhost#3001,}}. @var{tramp} would use the
1720 same host related information (like paths, Perl variants, etc) for
1721 both connections, although the information is valid only for one of
1722 them.
1723
1724 In order to avoid trouble, you must use another host name for one of
1725 the connections, like introducing a @option{Host} section in
1726 @file{~/.ssh/config} (@pxref{Frequently Asked Questions}) or applying
1727 multiple hops (@pxref{Multi-hops}).
1728
1729 When @value{tramp} detects a changed operating system version on a
1730 remote host (via the command @command{uname -sr}), it flushes all
1731 connection related information for this host, and opens the
1732 connection again.
1733
1734
1735 @node Predefined connection information
1736 @section Setting own connection related information
1737
1738 Sometimes, @var{tramp} is not able to detect correct connection
1739 related information. In such cases, you could tell @var{tramp} which
1740 value it has to take. Since this could result in errors, it has to be
1741 used with care.
1742
1743 @vindex tramp-connection-properties
1744 Such settings can be performed via the list
1745 @code{tramp-connection-properties}. An entry in this list has the
1746 form @code{(@var{regexp} @var{property} @var{value})}. @var{regexp}
1747 matches remote file names for which a property shall be predefined.
1748 It can be @code{nil}. @var{property} is a string, and @var{value} the
1749 corresponding value. @var{property} could be any property found in
1750 the file @code{tramp-persistency-file-name}.
1751
1752 A special property is @code{"busybox"}. This must be set, if the
1753 remote host runs a very restricted busybox as shell, which closes the
1754 connection at will. Since there is no reliable test for this,
1755 @var{tramp} must be indicated this way. Example:
1756
1757 @lisp
1758 (add-to-list 'tramp-connection-properties
1759 (list (regexp-quote "@trampfn{ssh, user, randomhost.your.domain,}")
1760 "busybox" t))
1761 @end lisp
1762
1763
1764 @node Remote Programs
1765 @section How @value{tramp} finds and uses programs on the remote machine
1766
1767 @value{tramp} depends on a number of programs on the remote host in order to
1768 function, including @command{ls}, @command{test}, @command{find} and
1769 @command{cat}.
1770
1771 In addition to these required tools, there are various tools that may be
1772 required based on the connection method. See @ref{Inline methods} and
1773 @ref{External methods} for details on these.
1774
1775 Certain other tools, such as @command{perl} (or @command{perl5}) and
1776 @command{grep} will be used if they can be found. When they are
1777 available, they are used to improve the performance and accuracy of
1778 remote file access.
1779
1780 @vindex tramp-remote-path
1781 @vindex tramp-default-remote-path
1782 @vindex tramp-own-remote-path
1783 @defopt tramp-remote-path
1784 When @value{tramp} connects to the remote machine, it searches for the
1785 programs that it can use. The variable @code{tramp-remote-path}
1786 controls the directories searched on the remote machine.
1787
1788 By default, this is set to a reasonable set of defaults for most
1789 machines. The symbol @code{tramp-default-remote-path} is a place
1790 holder, it is replaced by the list of directories received via the
1791 command @command{getconf PATH} on your remote machine. For example,
1792 on Debian GNU/Linux this is @file{/bin:/usr/bin}, whereas on Solaris
1793 this is @file{/usr/xpg4/bin:/usr/ccs/bin:/usr/bin:/opt/SUNWspro/bin}.
1794 It is recommended to apply this symbol on top of
1795 @code{tramp-remote-path}.
1796
1797 It is possible, however, that your local (or remote ;) system
1798 administrator has put the tools you want in some obscure local
1799 directory.
1800
1801 In this case, you can still use them with @value{tramp}. You simply
1802 need to add code to your @file{.emacs} to add the directory to the
1803 remote path. This will then be searched by @value{tramp} when you
1804 connect and the software found.
1805
1806 To add a directory to the remote search path, you could use code such
1807 as:
1808
1809 @lisp
1810 @i{;; We load @value{tramp} to define the variable.}
1811 (require 'tramp)
1812 @i{;; We have @command{perl} in "/usr/local/perl/bin"}
1813 (add-to-list 'tramp-remote-path "/usr/local/perl/bin")
1814 @end lisp
1815
1816 Another possibility is to reuse the path settings of your remote
1817 account when you log in. Usually, these settings are overwritten,
1818 because they might not be useful for @value{tramp}. The place holder
1819 @code{tramp-own-remote-path} preserves these settings. You can
1820 activate it via
1821
1822 @lisp
1823 (add-to-list 'tramp-remote-path 'tramp-own-remote-path)
1824 @end lisp
1825 @end defopt
1826
1827 @value{tramp} caches several information, like the Perl binary
1828 location. The changed remote search path wouldn't affect these
1829 settings. In order to force @value{tramp} to recompute these values,
1830 you must exit @value{emacsname}, remove your persistency file
1831 (@pxref{Connection caching}), and restart @value{emacsname}.
1832
1833
1834 @node Remote shell setup
1835 @section Remote shell setup hints
1836 @cindex remote shell setup
1837 @cindex @file{.profile} file
1838 @cindex @file{.login} file
1839 @cindex shell init files
1840
1841 As explained in the @ref{Overview} section, @value{tramp} connects to the
1842 remote host and talks to the shell it finds there. Of course, when you
1843 log in, the shell executes its init files. Suppose your init file
1844 requires you to enter the birth date of your mother; clearly @value{tramp}
1845 does not know this and hence fails to log you in to that host.
1846
1847 There are different possible strategies for pursuing this problem. One
1848 strategy is to enable @value{tramp} to deal with all possible situations.
1849 This is a losing battle, since it is not possible to deal with
1850 @emph{all} situations. The other strategy is to require you to set up
1851 the remote host such that it behaves like @value{tramp} expects. This might
1852 be inconvenient because you have to invest a lot of effort into shell
1853 setup before you can begin to use @value{tramp}.
1854
1855 The package, therefore, pursues a combined approach. It tries to
1856 figure out some of the more common setups, and only requires you to
1857 avoid really exotic stuff. For example, it looks through a list of
1858 directories to find some programs on the remote host. And also, it
1859 knows that it is not obvious how to check whether a file exists, and
1860 therefore it tries different possibilities. (On some hosts and
1861 shells, the command @command{test -e} does the trick, on some hosts
1862 the shell builtin doesn't work but the program @command{/usr/bin/test
1863 -e} or @command{/bin/test -e} works. And on still other hosts,
1864 @command{ls -d} is the right way to do this.)
1865
1866 Below you find a discussion of a few things that @value{tramp} does not deal
1867 with, and that you therefore have to set up correctly.
1868
1869 @table @asis
1870 @item @var{shell-prompt-pattern}
1871 @vindex shell-prompt-pattern
1872
1873 After logging in to the remote host, @value{tramp} has to wait for the remote
1874 shell startup to finish before it can send commands to the remote
1875 shell. The strategy here is to wait for the shell prompt. In order to
1876 recognize the shell prompt, the variable @code{shell-prompt-pattern} has
1877 to be set correctly to recognize the shell prompt on the remote host.
1878
1879 Note that @value{tramp} requires the match for @code{shell-prompt-pattern}
1880 to be at the end of the buffer. Many people have something like the
1881 following as the value for the variable: @code{"^[^>$][>$] *"}. Now
1882 suppose your shell prompt is @code{a <b> c $ }. In this case,
1883 @value{tramp} recognizes the @code{>} character as the end of the prompt,
1884 but it is not at the end of the buffer.
1885
1886 @item @var{tramp-shell-prompt-pattern}
1887 @vindex tramp-shell-prompt-pattern
1888
1889 This regular expression is used by @value{tramp} in the same way as
1890 @code{shell-prompt-pattern}, to match prompts from the remote shell.
1891 This second variable exists because the prompt from the remote shell
1892 might be different from the prompt from a local shell---after all,
1893 the whole point of @value{tramp} is to log in to remote hosts as a
1894 different user. The default value of
1895 @code{tramp-shell-prompt-pattern} is the same as the default value of
1896 @code{shell-prompt-pattern}, which is reported to work well in many
1897 circumstances.
1898
1899 @item @var{tramp-password-prompt-regexp}
1900 @vindex tramp-password-prompt-regexp
1901 @vindex tramp-wrong-passwd-regexp
1902
1903 During login, @value{tramp} might be forced to enter a password or a
1904 passphrase. The difference between both is that a password is
1905 requested from the shell on the remote host, while a passphrase is
1906 needed for accessing local authentication information, like your ssh
1907 key.
1908
1909 @var{tramp-password-prompt-regexp} handles the detection of such
1910 requests for English environments. When you use another localization
1911 of your (local or remote) host, you might need to adapt this. Example:
1912
1913 @lisp
1914 (setq
1915 tramp-password-prompt-regexp
1916 (concat
1917 "^.*"
1918 (regexp-opt
1919 '("passphrase" "Passphrase"
1920 ;; English
1921 "password" "Password"
1922 ;; Deutsch
1923 "passwort" "Passwort"
1924 ;; Fran@,{c}ais
1925 "mot de passe" "Mot de passe") t)
1926 ".*:\0? *"))
1927 @end lisp
1928
1929 In parallel, it might also be necessary to adapt
1930 @var{tramp-wrong-passwd-regexp}.
1931
1932 @item @command{tset} and other questions
1933 @cindex Unix command tset
1934 @cindex tset Unix command
1935
1936 Some people invoke the @command{tset} program from their shell startup
1937 scripts which asks the user about the terminal type of the shell.
1938 Maybe some shells ask other questions when they are started.
1939 @value{tramp} does not know how to answer these questions. There are
1940 two approaches for dealing with this problem. One approach is to take
1941 care that the shell does not ask any questions when invoked from
1942 @value{tramp}. You can do this by checking the @env{TERM}
1943 environment variable, it will be set to @code{dumb} when connecting.
1944
1945 @vindex tramp-terminal-type
1946 The variable @code{tramp-terminal-type} can be used to change this value
1947 to @code{dumb}.
1948
1949 @vindex tramp-actions-before-shell
1950 The other approach is to teach @value{tramp} about these questions. See
1951 the variable @code{tramp-actions-before-shell}. Example:
1952
1953 @lisp
1954 (defconst my-tramp-prompt-regexp
1955 (concat (regexp-opt '("Enter the birth date of your mother:") t)
1956 "\\s-*")
1957 "Regular expression matching my login prompt question.")
1958
1959 (defun my-tramp-action (proc vec)
1960 "Enter \"19000101\" in order to give a correct answer."
1961 (save-window-excursion
1962 (with-current-buffer (tramp-get-connection-buffer vec)
1963 (tramp-message vec 6 "\n%s" (buffer-string))
1964 (tramp-send-string vec "19000101"))))
1965
1966 (add-to-list 'tramp-actions-before-shell
1967 '(my-tramp-prompt-regexp my-tramp-action))
1968 @end lisp
1969
1970
1971 @item Environment variables named like users in @file{.profile}
1972
1973 If you have a user named frumple and set the variable @env{FRUMPLE} in
1974 your shell environment, then this might cause trouble. Maybe rename
1975 the variable to @env{FRUMPLE_DIR} or the like.
1976
1977 This weird effect was actually reported by a @value{tramp} user!
1978
1979
1980 @item Non-Bourne commands in @file{.profile}
1981
1982 After logging in to the remote host, @value{tramp} issues the command
1983 @command{exec /bin/sh}. (Actually, the command is slightly
1984 different.) When @command{/bin/sh} is executed, it reads some init
1985 files, such as @file{~/.shrc} or @file{~/.profile}.
1986
1987 Now, some people have a login shell which is not @code{/bin/sh} but a
1988 Bourne-ish shell such as bash or ksh. Some of these people might put
1989 their shell setup into the files @file{~/.shrc} or @file{~/.profile}.
1990 This way, it is possible for non-Bourne constructs to end up in those
1991 files. Then, @command{exec /bin/sh} might cause the Bourne shell to
1992 barf on those constructs.
1993
1994 As an example, imagine somebody putting @command{export FOO=bar} into
1995 the file @file{~/.profile}. The standard Bourne shell does not
1996 understand this syntax and will emit a syntax error when it reaches
1997 this line.
1998
1999 Another example is the tilde (@code{~}) character, say when adding
2000 @file{~/bin} to @env{PATH}. Many Bourne shells will not expand this
2001 character, and since there is usually no directory whose name consists
2002 of the single character tilde, strange things will happen.
2003
2004 What can you do about this?
2005
2006 Well, one possibility is to make sure that everything in
2007 @file{~/.shrc} and @file{~/.profile} on all remote hosts is
2008 Bourne-compatible. In the above example, instead of @command{export
2009 FOO=bar}, you might use @command{FOO=bar; export FOO} instead.
2010
2011 The other possibility is to put your non-Bourne shell setup into some
2012 other files. For example, bash reads the file @file{~/.bash_profile}
2013 instead of @file{~/.profile}, if the former exists. So bash
2014 aficionados just rename their @file{~/.profile} to
2015 @file{~/.bash_profile} on all remote hosts, and Bob's your uncle.
2016
2017 The @value{tramp} developers would like to circumvent this problem, so
2018 if you have an idea about it, please tell us. However, we are afraid
2019 it is not that simple: before saying @command{exec /bin/sh},
2020 @value{tramp} does not know which kind of shell it might be talking
2021 to. It could be a Bourne-ish shell like ksh or bash, or it could be a
2022 csh derivative like tcsh, or it could be zsh, or even rc. If the
2023 shell is Bourne-ish already, then it might be prudent to omit the
2024 @command{exec /bin/sh} step. But how to find out if the shell is
2025 Bourne-ish?
2026
2027
2028 @item Interactive shell prompt
2029
2030 @value{tramp} redefines the shell prompt in order to parse the shell's
2031 output robustly. When calling an interactive shell by @kbd{M-x
2032 shell}, this doesn't look nice.
2033
2034 You can redefine the shell prompt by checking the environment variable
2035 @env{INSIDE_EMACS}, which is set by @value{tramp}, in your startup
2036 script @file{~/.emacs_SHELLNAME}. @env{SHELLNAME} might be the string
2037 @code{bash} or similar, in case of doubt you could set it the
2038 environment variable @env{ESHELL} in your @file{.emacs}:
2039
2040 @lisp
2041 (setenv "ESHELL" "bash")
2042 @end lisp
2043
2044 Your file @file{~/.emacs_SHELLNAME} could contain code like
2045
2046 @example
2047 # Reset the prompt for remote Tramp shells.
2048 if [ "$@{INSIDE_EMACS/*tramp*/tramp@}" == "tramp" ] ; then
2049 PS1="[\u@@\h \w]$ "
2050 fi
2051 @end example
2052
2053 @ifinfo
2054 @ifset emacs
2055 @xref{Interactive Shell, , , @value{emacsdir}}.
2056 @end ifset
2057 @end ifinfo
2058
2059 @end table
2060
2061
2062 @node Android shell setup
2063 @section Android shell setup hints
2064 @cindex android shell setup
2065
2066 Android devices use a restricted shell. They can be accessed via the
2067 @option{adb} method. However, this restricts the access to a USB
2068 connection, and it requires the installation of the Android SDK on the
2069 local machine.
2070
2071 When an @command{sshd} process runs on the Android device, like
2072 provided by the @code{SSHDroid} app, any @option{ssh}-based method can
2073 be used. This requires some special settings.
2074
2075 The default shell @code{/bin/sh} does not exist. Instead, you shall
2076 use just @code{sh}, which invokes the shell installed on the device.
2077 You can instruct @value{tramp} by this form:
2078
2079 @lisp
2080 (add-to-list 'tramp-connection-properties
2081 (list (regexp-quote "192.168.0.26") "remote-shell" "sh"))
2082 @end lisp
2083
2084 @noindent
2085 with @samp{192.168.0.26} being the IP address of your Android device
2086 (@pxref{Predefined connection information}).
2087
2088 The user settings for the @env{PATH} environment variable must be
2089 preserved. It has also been reported, that the commands in
2090 @file{/system/xbin} are better suited than the ones in
2091 @file{/system/bin}. Add these setting:
2092
2093 @lisp
2094 (add-to-list 'tramp-remote-path 'tramp-own-remote-path)
2095 (add-to-list 'tramp-remote-path "/system/xbin")
2096 @end lisp
2097
2098 @noindent
2099 If the Android device is not @samp{rooted}, you must give the shell a
2100 writable directory for temporary files:
2101
2102 @lisp
2103 (add-to-list 'tramp-remote-process-environment "TMPDIR=$HOME")
2104 @end lisp
2105
2106 @noindent
2107 Now you shall be able to open a remote connection with @kbd{C-x C-f
2108 @trampfn{ssh, , 192.168.0.26#2222, }}, given that @command{sshd}
2109 listens on port @samp{2222}.
2110
2111 It is also recommended to add a corresponding entry to your
2112 @file{~/.ssh/config} for that connection, like
2113
2114 @example
2115 Host android
2116 HostName 192.168.0.26
2117 User root
2118 Port 2222
2119 @end example
2120
2121 @noindent
2122 In this case, you must change the setting for the remote shell to
2123
2124 @lisp
2125 (add-to-list 'tramp-connection-properties
2126 (list (regexp-quote "android") "remote-shell" "sh"))
2127 @end lisp
2128
2129 @noindent
2130 You would open the connection with @kbd{C-x C-f @trampfn{ssh, ,
2131 android, }} then.
2132
2133
2134 @node Auto-save and Backup
2135 @section Auto-save and Backup configuration
2136 @cindex auto-save
2137 @cindex backup
2138 @ifset emacs
2139 @vindex backup-directory-alist
2140 @end ifset
2141 @ifset xemacs
2142 @vindex bkup-backup-directory-info
2143 @end ifset
2144
2145 Normally, @value{emacsname} writes backup files to the same directory
2146 as the original files, but this behavior can be changed via the
2147 variable
2148 @ifset emacs
2149 @code{backup-directory-alist}.
2150 @end ifset
2151 @ifset xemacs
2152 @code{bkup-backup-directory-info}.
2153 @end ifset
2154 In connection with @value{tramp}, this can have unexpected side
2155 effects. Suppose that you specify that all backups should go to the
2156 directory @file{~/.emacs.d/backups/}, and then you edit the file
2157 @file{@trampfn{su, root, localhost, /etc/secretfile}}. The effect is
2158 that the backup file will be owned by you and not by root, thus
2159 possibly enabling others to see it even if they were not intended to
2160 see it.
2161
2162 When
2163 @ifset emacs
2164 @code{backup-directory-alist}
2165 @end ifset
2166 @ifset xemacs
2167 @code{bkup-backup-directory-info}
2168 @end ifset
2169 is @code{nil} (the default), such problems do not occur.
2170
2171 Therefore, it is useful to set special values for @value{tramp}
2172 files. For example, the following statement effectively `turns off'
2173 the effect of
2174 @ifset emacs
2175 @code{backup-directory-alist}
2176 @end ifset
2177 @ifset xemacs
2178 @code{bkup-backup-directory-info}
2179 @end ifset
2180 for @value{tramp} files:
2181
2182 @ifset emacs
2183 @lisp
2184 (add-to-list 'backup-directory-alist
2185 (cons tramp-file-name-regexp nil))
2186 @end lisp
2187 @end ifset
2188 @ifset xemacs
2189 @lisp
2190 (require 'backup-dir)
2191 (add-to-list 'bkup-backup-directory-info
2192 (list tramp-file-name-regexp ""))
2193 @end lisp
2194 @end ifset
2195
2196 @ifset emacs
2197 It is also possible to disable backups depending on the used method.
2198 The following code disables backups for the @option{su} and
2199 @option{sudo} methods:
2200
2201 @lisp
2202 (setq backup-enable-predicate
2203 (lambda (name)
2204 (and (normal-backup-enable-predicate name)
2205 (not
2206 (let ((method (file-remote-p name 'method)))
2207 (when (stringp method)
2208 (member method '("su" "sudo"))))))))
2209 @end lisp
2210 @end ifset
2211
2212
2213 Another possibility is to use the @value{tramp} variable
2214 @ifset emacs
2215 @code{tramp-backup-directory-alist}.
2216 @end ifset
2217 @ifset xemacs
2218 @code{tramp-bkup-backup-directory-info}.
2219 @end ifset
2220 This variable has the same meaning like
2221 @ifset emacs
2222 @code{backup-directory-alist}.
2223 @end ifset
2224 @ifset xemacs
2225 @code{bkup-backup-directory-info}.
2226 @end ifset
2227 If a @value{tramp} file is backed up, and DIRECTORY is an absolute
2228 local file name, DIRECTORY is prepended with the @value{tramp} file
2229 name prefix of the file to be backed up.
2230
2231 @noindent
2232 Example:
2233
2234 @ifset emacs
2235 @lisp
2236 (add-to-list 'backup-directory-alist
2237 (cons "." "~/.emacs.d/backups/"))
2238 (setq tramp-backup-directory-alist backup-directory-alist)
2239 @end lisp
2240 @end ifset
2241 @ifset xemacs
2242 @lisp
2243 (require 'backup-dir)
2244 (add-to-list 'bkup-backup-directory-info
2245 (list "." "~/.emacs.d/backups/" 'full-path))
2246 (setq tramp-bkup-backup-directory-info bkup-backup-directory-info)
2247 @end lisp
2248 @end ifset
2249
2250 @noindent
2251 The backup file name of @file{@trampfn{su, root, localhost,
2252 /etc/secretfile}} would be
2253 @ifset emacs
2254 @file{@trampfn{su, root, localhost,
2255 ~/.emacs.d/backups/!su:root@@localhost:!etc!secretfile~}}
2256 @end ifset
2257 @ifset xemacs
2258 @file{@trampfn{su, root, localhost,
2259 ~/.emacs.d/backups/![su!root@@localhost]!etc!secretfile~}}
2260 @end ifset
2261
2262 The same problem can happen with auto-saving files.
2263 @ifset emacs
2264 The variable @code{auto-save-file-name-transforms} keeps information,
2265 on which directory an auto-saved file should go. By default, it is
2266 initialized for @value{tramp} files to the local temporary directory.
2267
2268 On some versions of @value{emacsname}, namely the version built for
2269 Debian GNU/Linux, the variable @code{auto-save-file-name-transforms}
2270 contains the directory where @value{emacsname} was built. A
2271 workaround is to manually set the variable to a sane value.
2272
2273 If auto-saved files should go into the same directory as the original
2274 files, @code{auto-save-file-name-transforms} should be set to @code{nil}.
2275
2276 Another possibility is to set the variable
2277 @code{tramp-auto-save-directory} to a proper value.
2278 @end ifset
2279 @ifset xemacs
2280 For this purpose you can set the variable @code{auto-save-directory}
2281 to a proper value.
2282 @end ifset
2283
2284
2285 @node Windows setup hints
2286 @section Issues with Cygwin ssh
2287 @cindex Cygwin, issues
2288
2289 This section needs a lot of work! Please help.
2290
2291 @cindex method sshx with Cygwin
2292 @cindex sshx method with Cygwin
2293 The recent Cygwin installation of @command{ssh} works only with a
2294 Cygwinized @value{emacsname}. You can check it by typing @kbd{M-x
2295 eshell}, and starting @kbd{ssh test.machine}. The problem is evident
2296 if you see a message like this:
2297
2298 @example
2299 Pseudo-terminal will not be allocated because stdin is not a terminal.
2300 @end example
2301
2302 Older @command{ssh} versions of Cygwin are told to cooperate with
2303 @value{tramp} selecting @option{sshx} as the connection method. You
2304 can find information about setting up Cygwin in their FAQ at
2305 @uref{http://cygwin.com/faq/}.
2306
2307 @cindex method scpx with Cygwin
2308 @cindex scpx method with Cygwin
2309 If you wish to use the @option{scpx} connection method, then you might
2310 have the problem that @value{emacsname} calls @command{scp} with a
2311 Windows filename such as @code{c:/foo}. The Cygwin version of
2312 @command{scp} does not know about Windows filenames and interprets
2313 this as a remote filename on the host @code{c}.
2314
2315 One possible workaround is to write a wrapper script for @option{scp}
2316 which converts the Windows filename to a Cygwinized filename.
2317
2318 @cindex Cygwin and ssh-agent
2319 @cindex SSH_AUTH_SOCK and @value{emacsname} on Windows
2320 If you want to use either @option{ssh} based method on Windows, then
2321 you might encounter problems with @command{ssh-agent}. Using this
2322 program, you can avoid typing the pass-phrase every time you log in.
2323 However, if you start @value{emacsname} from a desktop shortcut, then
2324 the environment variable @env{SSH_AUTH_SOCK} is not set and so
2325 @value{emacsname} and thus @value{tramp} and thus @command{ssh} and
2326 @command{scp} started from @value{tramp} cannot communicate with
2327 @command{ssh-agent}. It works better to start @value{emacsname} from
2328 the shell.
2329
2330 If anyone knows how to start @command{ssh-agent} under Windows in such a
2331 way that desktop shortcuts can profit, please holler. I don't really
2332 know anything at all about Windows@dots{}
2333
2334
2335 @node Usage
2336 @chapter Using @value{tramp}
2337 @cindex using @value{tramp}
2338
2339 Once you have installed @value{tramp} it will operate fairly
2340 transparently. You will be able to access files on any remote machine
2341 that you can log in to as though they were local.
2342
2343 Files are specified to @value{tramp} using a formalized syntax specifying the
2344 details of the system to connect to. This is similar to the syntax used
2345 by the @value{ftppackagename} package.
2346
2347 @cindex type-ahead
2348 Something that might happen which surprises you is that
2349 @value{emacsname} remembers all your keystrokes, so if you see a
2350 password prompt from @value{emacsname}, say, and hit @kbd{@key{RET}}
2351 twice instead of once, then the second keystroke will be processed by
2352 @value{emacsname} after @value{tramp} has done its thing. Why, this
2353 type-ahead is normal behavior, you say. Right you are, but be aware
2354 that opening a remote file might take quite a while, maybe half a
2355 minute when a connection needs to be opened. Maybe after half a
2356 minute you have already forgotten that you hit that key!
2357
2358 @menu
2359 * Filename Syntax:: @value{tramp} filename conventions.
2360 * Filename completion:: Filename completion.
2361 * Ad-hoc multi-hops:: Declaring multiple hops in the file name.
2362 * Remote processes:: Integration with other @value{emacsname} packages.
2363 * Cleanup remote connections:: Cleanup remote connections.
2364 @end menu
2365
2366
2367 @node Filename Syntax
2368 @section @value{tramp} filename conventions
2369 @cindex filename syntax
2370 @cindex filename examples
2371
2372 To access the file @var{localname} on the remote machine @var{machine}
2373 you would specify the filename @file{@trampfn{, , machine,
2374 localname}}. This will connect to @var{machine} and transfer the file
2375 using the default method. @xref{Default Method}.
2376
2377 Some examples of @value{tramp} filenames are shown below.
2378
2379 @table @file
2380 @item @value{prefix}melancholia@value{postfix}.emacs
2381 Edit the file @file{.emacs} in your home directory on the machine
2382 @code{melancholia}.
2383
2384 @item @value{prefix}melancholia.danann.net@value{postfix}.emacs
2385 This edits the same file, using the fully qualified domain name of
2386 the machine.
2387
2388 @item @value{prefix}melancholia@value{postfix}~/.emacs
2389 This also edits the same file; the @file{~} is expanded to your
2390 home directory on the remote machine, just like it is locally.
2391
2392 @item @value{prefix}melancholia@value{postfix}~daniel/.emacs
2393 This edits the file @file{.emacs} in the home directory of the user
2394 @code{daniel} on the machine @code{melancholia}. The @file{~<user>}
2395 construct is expanded to the home directory of that user on the remote
2396 machine.
2397
2398 @item @value{prefix}melancholia@value{postfix}/etc/squid.conf
2399 This edits the file @file{/etc/squid.conf} on the machine
2400 @code{melancholia}.
2401
2402 @end table
2403
2404 @var{machine} can also be an IPv4 or IPv6 address, like in
2405 @file{@trampfn{, , 127.0.0.1, .emacs}} or @file{@trampfn{, ,
2406 @value{ipv6prefix}::1@value{ipv6postfix}, .emacs}}.
2407 @ifset emacs
2408 For syntactical reasons, IPv6 addresses must be embedded in square
2409 brackets @file{@value{ipv6prefix}} and @file{@value{ipv6postfix}}.
2410 @end ifset
2411
2412 Unless you specify a different name to use, @value{tramp} will use the
2413 current local user name as the remote user name to log in with. If you
2414 need to log in as a different user, you can specify the user name as
2415 part of the filename.
2416
2417 To log in to the remote machine as a specific user, you use the syntax
2418 @file{@trampfn{, user, machine, path/to.file}}. That means that
2419 connecting to @code{melancholia} as @code{daniel} and editing
2420 @file{.emacs} in your home directory you would specify
2421 @file{@trampfn{, daniel, melancholia, .emacs}}.
2422
2423 It is also possible to specify other file transfer methods
2424 (@pxref{Inline methods}, @pxref{External methods}) as part of the
2425 filename.
2426 @ifset emacs
2427 This is done by putting the method before the user and host name, as
2428 in @file{@value{prefix}@var{method}@value{postfixhop}} (Note the
2429 trailing colon).
2430 @end ifset
2431 @ifset xemacs
2432 This is done by replacing the initial @file{@value{prefix}} with
2433 @file{@value{prefix}<method>@value{postfixhop}}. (Note the trailing
2434 slash!).
2435 @end ifset
2436 The user, machine and file specification remain the same.
2437
2438 So, to connect to the machine @code{melancholia} as @code{daniel},
2439 using the @option{ssh} method to transfer files, and edit
2440 @file{.emacs} in my home directory I would specify the filename
2441 @file{@trampfn{ssh, daniel, melancholia, .emacs}}.
2442
2443 @ifset emacs
2444 A remote filename containing a host name only, which is equal to a
2445 method name, is not allowed. If such a host name is used, it must
2446 always be preceded by an explicit method name, like
2447 @file{@value{prefix}ssh@value{postfixhop}ssh@value{postfix}}.
2448 @end ifset
2449
2450 Finally, for some methods it is possible to specify a different port
2451 number than the default one, given by the method. This is specified
2452 by adding @file{#<port>} to the host name, like in @file{@trampfn{ssh,
2453 daniel, melancholia#42, .emacs}}.
2454
2455
2456 @node Filename completion
2457 @section Filename completion
2458 @cindex filename completion
2459
2460 Filename completion works with @value{tramp} for completion of method
2461 names, of user names and of machine names as well as for completion of
2462 file names on remote machines.
2463 @ifset emacs
2464 In order to enable this, partial completion must be activated in your
2465 @file{.emacs}.
2466 @ifinfo
2467 @xref{Completion Options, , , @value{emacsdir}}.
2468 @end ifinfo
2469 @end ifset
2470
2471 If you, for example, type @kbd{C-x C-f @value{prefix}t
2472 @key{TAB}}, @value{tramp} might give you as result the choice for
2473
2474 @example
2475 @c @multitable {@trampfn{telnet, , melancholia.danann.net,}} {@trampfn{telnet, , 192.168.0.1,}}
2476 @multitable @columnfractions .5 .5
2477 @ifset emacs
2478 @item @value{prefixhop}telnet@value{postfixhop} @tab tmp/
2479 @item @value{prefixhop}toto@value{postfix} @tab
2480 @end ifset
2481 @ifset xemacs
2482 @item @value{prefixhop}telnet@value{postfixhop} @tab @value{prefixhop}toto@value{postfix}
2483 @end ifset
2484 @end multitable
2485 @end example
2486
2487 @samp{@value{prefixhop}telnet@value{postfixhop}}
2488 is a possible completion for the respective method,
2489 @ifset emacs
2490 @samp{tmp/} stands for the directory @file{/tmp} on your local
2491 machine,
2492 @end ifset
2493 and @samp{@value{prefixhop}toto@value{postfix}}
2494 might be a host @value{tramp} has detected in your @file{~/.ssh/known_hosts}
2495 file (given you're using default method @option{ssh}).
2496
2497 If you go on to type @kbd{e @key{TAB}}, the minibuffer is completed to
2498 @samp{@value{prefix}telnet@value{postfixhop}}.
2499 Next @kbd{@key{TAB}} brings you all machine names @value{tramp} detects in
2500 your @file{/etc/hosts} file, let's say
2501
2502 @example
2503 @multitable @columnfractions .5 .5
2504 @c @multitable {@trampfn{telnet, , melancholia.danann.net,}} {@trampfn{telnet, , 192.168.0.1,}}
2505 @item @trampfn{telnet, , 127.0.0.1,} @tab @trampfn{telnet, , 192.168.0.1,}
2506 @item @trampfn{telnet, , @value{ipv6prefix}::1@value{ipv6postfix},} @tab @trampfn{telnet, , localhost,}
2507 @item @trampfn{telnet, , melancholia.danann.net,} @tab @trampfn{telnet, , melancholia,}
2508 @end multitable
2509 @end example
2510
2511 Now you can choose the desired machine, and you can continue to
2512 complete file names on that machine.
2513
2514 If the configuration files (@pxref{Customizing Completion}), which
2515 @value{tramp} uses for analysis of completion, offer user names, those user
2516 names will be taken into account as well.
2517
2518 Remote machines which have been visited in the past and kept
2519 persistently (@pxref{Connection caching}) will be offered too.
2520
2521 Once the remote machine identification is completed, it comes to
2522 filename completion on the remote host. This works pretty much like
2523 for files on the local host, with the exception that minibuffer
2524 killing via a double-slash works only on the filename part, except
2525 that filename part starts with @file{//}.
2526 @ifset emacs
2527 A triple-slash stands for the default behavior.
2528 @end ifset
2529 @ifinfo
2530 @xref{Minibuffer File, , , @value{emacsdir}}.
2531 @end ifinfo
2532
2533 @noindent
2534 Example:
2535
2536 @example
2537 @ifset emacs
2538 @kbd{C-x C-f @trampfn{telnet, , melancholia, /usr/local/bin//etc} @key{TAB}}
2539 @print{} @trampfn{telnet, , melancholia, /etc}
2540
2541 @kbd{C-x C-f @trampfn{telnet, , melancholia, //etc} @key{TAB}}
2542 @print{} /etc
2543
2544 @kbd{C-x C-f @trampfn{telnet, , melancholia, /usr/local/bin///etc} @key{TAB}}
2545 @print{} /etc
2546 @end ifset
2547
2548 @ifset xemacs
2549 @kbd{C-x C-f @trampfn{telnet, , melancholia, /usr/local/bin//}}
2550 @print{} @trampfn{telnet, , melancholia, /}
2551
2552 @kbd{C-x C-f @trampfn{telnet, , melancholia, //}}
2553 @print{} /
2554 @end ifset
2555 @end example
2556
2557 A remote directory might have changed its contents out of
2558 @value{emacsname} control, for example by creation or deletion of
2559 files by other processes. Therefore, during filename completion, the
2560 remote directory contents are reread regularly in order to detect such
2561 changes, which would be invisible otherwise (@pxref{Connection caching}).
2562
2563 @defopt tramp-completion-reread-directory-timeout
2564 This variable defines the number of seconds since last remote command
2565 before rereading a directory contents. A value of 0 would require an
2566 immediate reread during filename completion, @code{nil} means to use
2567 always cached values for the directory contents.
2568 @end defopt
2569
2570
2571 @node Ad-hoc multi-hops
2572 @section Declaring multiple hops in the file name
2573 @cindex multi-hop, ad-hoc
2574 @cindex proxy hosts, ad-hoc
2575
2576 Multiple hops are configured with the variable
2577 @code{tramp-default-proxies-alist} (@pxref{Multi-hops}). However,
2578 sometimes it is desirable to reach a remote host immediately, without
2579 configuration changes. This can be reached by an ad-hoc specification
2580 of the proxies.
2581
2582 A proxy looks like a remote file name specification without the local
2583 file name part. It is prepended to the target remote file name,
2584 separated by @samp{|}. As an example, a remote file on
2585 @samp{you@@remotehost}, passing the proxy @samp{bird@@bastion}, could
2586 be opened by
2587
2588 @example
2589 @c @kbd{C-x C-f @trampfn{ssh@value{postfixhop}bird@@bastion|ssh, you,
2590 @c remotehost, /path}}
2591 @kbd{C-x C-f @value{prefix}ssh@value{postfixhop}bird@@bastion|ssh@value{postfixhop}you@@remotehost@value{postfix}/path}
2592 @end example
2593
2594 Multiple hops can be cascaded, separating all proxies by @samp{|}.
2595 The proxies can also contain the patterns @code{%h} or @code{%u}.
2596
2597 The ad-hoc definition is added on the fly to
2598 @code{tramp-default-proxies-alist}. Therefore, during the lifetime of
2599 the @value{emacsname} session it is not necessary to enter this ad-hoc
2600 specification, again. The remote file name @samp{@trampfn{ssh, you,
2601 remotehost, /path}} would be sufficient from now on.
2602
2603 @vindex tramp-save-ad-hoc-proxies
2604 @defopt tramp-save-ad-hoc-proxies
2605 This customer option controls whether ad-hoc definitions are kept
2606 persistently in @code{tramp-default-proxies-alist}. That means, those
2607 definitions are available also for future @value{emacsname} sessions.
2608 @end defopt
2609
2610
2611 @node Remote processes
2612 @section Integration with other @value{emacsname} packages
2613 @cindex compile
2614 @cindex recompile
2615
2616 @value{tramp} supports running processes on a remote host. This
2617 allows to exploit @value{emacsname} packages without modification for
2618 remote file names. It does not work for the @option{ftp} method.
2619 Association of a pty, as specified in @code{start-file-process}, is
2620 not supported.
2621
2622 @code{process-file} and @code{start-file-process} work on the remote
2623 host when the variable @code{default-directory} is remote:
2624
2625 @lisp
2626 (let ((default-directory "/ssh:remote.host:"))
2627 (start-file-process "grep" (get-buffer-create "*grep*")
2628 "/bin/sh" "-c" "grep -e tramp *"))
2629 @end lisp
2630
2631 @ifset emacsgvfs
2632 If the remote host is mounted via GVFS (see @ref{GVFS based methods}),
2633 the remote filesystem is mounted locally. Therefore, there are no
2634 remote processes; all processes run still locally on your machine with
2635 an adapted @code{default-directory}. This section does not apply for
2636 such connection methods.
2637 @end ifset
2638
2639 Remote processes are started when a corresponding command is executed
2640 from a buffer belonging to a remote file or directory. Up to now, the
2641 packages @file{compile.el} (commands like @code{compile} and
2642 @code{grep}) and @file{gud.el} (@code{gdb} or @code{perldb}) have been
2643 integrated. Integration of further packages is planned, any help for
2644 this is welcome!
2645
2646 When your program is not found in the default search path
2647 @value{tramp} sets on the remote machine, you should either use an
2648 absolute path, or extend @code{tramp-remote-path} (see @ref{Remote
2649 Programs}):
2650
2651 @lisp
2652 (add-to-list 'tramp-remote-path "~/bin")
2653 (add-to-list 'tramp-remote-path "/appli/pub/bin")
2654 @end lisp
2655
2656 The environment for your program can be adapted by customizing
2657 @code{tramp-remote-process-environment}. This variable is a list of
2658 strings. It is structured like @code{process-environment}. Each
2659 element is a string of the form @code{"ENVVARNAME=VALUE"}. An entry
2660 @code{"ENVVARNAME="} disables the corresponding environment variable,
2661 which might have been set in your init file like @file{~/.profile}.
2662
2663 @noindent
2664 Adding an entry can be performed via @code{add-to-list}:
2665
2666 @lisp
2667 (add-to-list 'tramp-remote-process-environment "JAVA_HOME=/opt/java")
2668 @end lisp
2669
2670 Changing or removing an existing entry is not encouraged. The default
2671 values are chosen for proper @value{tramp} work. Nevertheless, if for
2672 example a paranoid system administrator disallows changing the
2673 @env{HISTORY} environment variable, you can customize
2674 @code{tramp-remote-process-environment}, or you can apply the
2675 following code in your @file{.emacs}:
2676
2677 @lisp
2678 (let ((process-environment tramp-remote-process-environment))
2679 (setenv "HISTORY" nil)
2680 (setq tramp-remote-process-environment process-environment))
2681 @end lisp
2682
2683 If you use other @value{emacsname} packages which do not run
2684 out-of-the-box on a remote host, please let us know. We will try to
2685 integrate them as well. @xref{Bug Reports}.
2686
2687
2688 @subsection Running remote programs that create local X11 windows
2689
2690 If you want to run a remote program, which shall connect the X11
2691 server you are using with your local host, you can set the
2692 @env{DISPLAY} environment variable on the remote host:
2693
2694 @lisp
2695 (add-to-list 'tramp-remote-process-environment
2696 (format "DISPLAY=%s" (getenv "DISPLAY")))
2697 @end lisp
2698
2699 @noindent
2700 @code{(getenv "DISPLAY")} shall return a string containing a host
2701 name, which can be interpreted on the remote host; otherwise you might
2702 use a fixed host name. Strings like @code{:0} cannot be used properly
2703 on the remote host.
2704
2705 Another trick might be that you put @code{ForwardX11 yes} or
2706 @code{ForwardX11Trusted yes} to your @file{~/.ssh/config} file for
2707 that host.
2708
2709
2710 @subsection Running @code{shell} on a remote host
2711 @cindex shell
2712
2713 Calling @kbd{M-x shell} in a buffer related to a remote host runs the
2714 local shell as defined in @option{shell-file-name}. This might be
2715 also a valid path name for a shell to be applied on the remote host,
2716 but it will fail at least when your local and remote hosts belong to
2717 different system types, like @samp{windows-nt} and @samp{gnu/linux}.
2718
2719 You must set the variable @option{explicit-shell-file-name} to the
2720 shell path name on the remote host, in order to start that shell on
2721 the remote host.
2722
2723 @ifset emacs
2724 Starting with Emacs 24 this won't be necessary, if you call
2725 @code{shell} interactively. You will be asked for the remote shell
2726 path, if you are on a remote buffer, and if
2727 @option{explicit-shell-file-name} is equal to @code{nil}.
2728 @end ifset
2729
2730
2731 @subsection Running @code{shell-command} on a remote host
2732 @cindex shell-command
2733
2734 @code{shell-command} allows to execute commands in a shell, either
2735 synchronously, either asynchronously. This works also on remote
2736 hosts. Example:
2737
2738 @example
2739 @kbd{C-x C-f @trampfn{sudo, , , } @key{RET}}
2740 @kbd{M-! tail -f /var/log/syslog.log & @key{RET}}
2741 @end example
2742
2743 You will see the buffer @file{*Async Shell Command*}, containing the
2744 continuous output of the @command{tail} command.
2745
2746 @ifset emacs
2747 A similar behaviour can be reached by @kbd{M-x auto-revert-tail-mode},
2748 if available.
2749 @end ifset
2750
2751
2752 @subsection Running @code{eshell} on a remote host
2753 @cindex eshell
2754
2755 @value{tramp} is integrated into @file{eshell.el}. That is, you can
2756 open an interactive shell on your remote host, and run commands there.
2757 After you have started @kbd{M-x eshell}, you could perform commands
2758 like this:
2759
2760 @example
2761 @b{~ $} cd @trampfn{sudo, , , /etc} @key{RET}
2762 @b{@trampfn{sudo, root, host, /etc} $} hostname @key{RET}
2763 host
2764 @b{@trampfn{sudo, root, host, /etc} $} id @key{RET}
2765 uid=0(root) gid=0(root) groups=0(root)
2766 @b{@trampfn{sudo, root, host, /etc} $} find-file shadow @key{RET}
2767 #<buffer shadow>
2768 @b{@trampfn{sudo, root, host, /etc} $}
2769 @end example
2770
2771 @ifset emacs
2772 Since @value{emacsname} 23.2, @code{eshell} has also an own
2773 implementation of the @code{su} and @code{sudo} commands. Both
2774 commands change the default directory of the @file{*eshell*} buffer to
2775 the value related to the user the command has switched to. This works
2776 even on remote hosts, adding silently a corresponding entry to the
2777 variable @code{tramp-default-proxies-alist} (@pxref{Multi-hops}):
2778
2779 @example
2780 @b{~ $} cd @trampfn{ssh, user, remotehost, /etc} @key{RET}
2781 @b{@trampfn{ssh, user, remotehost, /etc} $} find-file shadow @key{RET}
2782 File is not readable: @trampfn{ssh, user, remotehost, /etc/shadow}
2783 @b{@trampfn{ssh, user, remotehost, /etc} $} sudo find-file shadow @key{RET}
2784 #<buffer shadow>
2785
2786 @b{@trampfn{ssh, user, remotehost, /etc} $} su - @key{RET}
2787 @b{@trampfn{su, root, remotehost, /root} $} id @key{RET}
2788 uid=0(root) gid=0(root) groups=0(root)
2789 @b{@trampfn{su, root, remotehost, /root} $}
2790 @end example
2791 @end ifset
2792
2793
2794 @anchor{Running a debugger on a remote host}
2795 @subsection Running a debugger on a remote host
2796 @cindex gud
2797 @cindex gdb
2798 @cindex perldb
2799
2800 @file{gud.el} offers an unified interface to several symbolic
2801 debuggers
2802 @ifset emacs
2803 @ifinfo
2804 (@ref{Debuggers, , , @value{emacsdir}}).
2805 @end ifinfo
2806 @end ifset
2807 With @value{tramp}, it is possible to debug programs on
2808 remote hosts. You can call @code{gdb} with a remote file name:
2809
2810 @example
2811 @kbd{M-x gdb @key{RET}}
2812 @b{Run gdb (like this):} gdb --annotate=3 @trampfn{ssh, , host, ~/myprog} @key{RET}
2813 @end example
2814
2815 The file name can also be relative to a remote default directory.
2816 Given you are in a buffer that belongs to the remote directory
2817 @trampfn{ssh, , host, /home/user}, you could call
2818
2819 @example
2820 @kbd{M-x perldb @key{RET}}
2821 @b{Run perldb (like this):} perl -d myprog.pl @key{RET}
2822 @end example
2823
2824 It is not possible to use just the absolute local part of a remote
2825 file name as program to debug, like @kbd{perl -d
2826 /home/user/myprog.pl}, though.
2827
2828 Arguments of the program to be debugged are taken literally. That
2829 means, file names as arguments must be given as ordinary relative or
2830 absolute file names, without any remote specification.
2831
2832
2833 @subsection Running remote processes on Windows hosts
2834 @cindex winexe
2835 @cindex powershell
2836
2837 With the help of the @command{winexe} it is possible tu run processes
2838 on a remote Windows host. @value{tramp} has implemented this for
2839 @code{process-file} and @code{start-file-process}.
2840
2841 The variable @code{tramp-smb-winexe-program} must contain the file
2842 name of your local @command{winexe} command. On the remote host,
2843 Powershell V2.0 must be installed; it is used to run the remote
2844 process.
2845
2846 In order to open a remote shell on the Windows host via @kbd{M-x
2847 shell}, you must set the variables @option{explicit-shell-file-name}
2848 and @option{explicit-*-args}. If you want, for example, run
2849 @command{cmd}, you must set:
2850
2851 @lisp
2852 (setq explicit-shell-file-name "cmd"
2853 explicit-cmd-args '("/q"))
2854 @end lisp
2855
2856 @noindent
2857 In case of running @command{powershell} as remote shell, the settings are
2858
2859 @lisp
2860 (setq explicit-shell-file-name "powershell"
2861 explicit-powershell-args '("-file" "-"))
2862 @end lisp
2863
2864
2865 @node Cleanup remote connections
2866 @section Cleanup remote connections
2867 @cindex cleanup
2868
2869 Sometimes it is useful to cleanup remote connections. The following
2870 commands support this.
2871
2872 @deffn Command tramp-cleanup-connection vec
2873 This command flushes all connection related objects. @option{vec} is
2874 the internal representation of a remote connection. Called
2875 interactively, the command offers all active remote connections in the
2876 minibuffer as remote file name prefix like @file{@trampfn{method,
2877 user, host, }}. The cleanup includes password cache (@pxref{Password
2878 handling}), file cache, connection cache (@pxref{Connection caching}),
2879 connection buffers.
2880 @end deffn
2881
2882 @deffn Command tramp-cleanup-this-connection
2883 This command flushes all objects of the current buffer's remote
2884 connection. The same objects are removed as in
2885 @code{tramp-cleanup-connection}.
2886 @end deffn
2887
2888 @deffn Command tramp-cleanup-all-connections
2889 This command flushes objects for all active remote connections. The
2890 same objects are removed as in @code{tramp-cleanup-connection}.
2891 @end deffn
2892
2893 @deffn Command tramp-cleanup-all-buffers
2894 Like in @code{tramp-cleanup-all-connections}, all remote connections
2895 are cleaned up. Additionally all buffers, which are related to a
2896 remote connection, are killed.
2897 @end deffn
2898
2899
2900 @node Bug Reports
2901 @chapter Reporting Bugs and Problems
2902 @cindex bug reports
2903
2904 Bugs and problems with @value{tramp} are actively worked on by the
2905 development team. Feature requests and suggestions are also more than
2906 welcome.
2907
2908 The @value{tramp} mailing list is a great place to get information on
2909 working with @value{tramp}, solving problems and general discussion
2910 and advice on topics relating to the package. It is moderated so
2911 non-subscribers can post but messages will be delayed, possibly up to
2912 48 hours (or longer in case of holidays), until the moderator approves
2913 your message.
2914
2915 The mailing list is at @email{tramp-devel@@gnu.org}. Messages sent to
2916 this address go to all the subscribers. This is @emph{not} the address
2917 to send subscription requests to.
2918
2919 Subscribing to the list is performed via
2920 @uref{http://lists.gnu.org/mailman/listinfo/tramp-devel/,
2921 the @value{tramp} Mail Subscription Page}.
2922
2923 @ifset emacs
2924 @ifset installchapter
2925 Before sending a bug report, you could check whether @value{tramp}
2926 works at all. Run the test suite on your local machine, @ref{Testing}.
2927 @end ifset
2928 @end ifset
2929
2930 @findex tramp-bug
2931 To report a bug in @value{tramp}, you should execute @kbd{M-x
2932 tramp-bug}. This will automatically generate a buffer with the details
2933 of your system and @value{tramp} version.
2934
2935 When submitting a bug report, please try to describe in excruciating
2936 detail the steps required to reproduce the problem, the setup of the
2937 remote machine and any special conditions that exist. You should also
2938 check that your problem is not described already in @xref{Frequently
2939 Asked Questions}.
2940
2941 If you can identify a minimal test case that reproduces the problem,
2942 include that with your bug report. This will make it much easier for
2943 the development team to analyze and correct the problem.
2944
2945 Sometimes, there might be also problems due to Tramp caches. Flush
2946 all caches before running the test, @ref{Cleanup remote connections}.
2947
2948 Before reporting the bug, you should set the verbosity level to 6
2949 (@pxref{Traces and Profiles, Traces}) in the @file{~/.emacs} file and
2950 repeat the bug. Then, include the contents of the @file{*tramp/foo*}
2951 and @file{*debug tramp/foo*} buffers in your bug report. A verbosity
2952 level greater than 6 will produce a very huge debug buffer, which is
2953 mostly not necessary for the analysis.
2954
2955 Please be aware that, with a verbosity level of 6 or greater, the
2956 contents of files and directories will be included in the debug
2957 buffer. Passwords you've typed will never be included there.
2958
2959
2960 @node Frequently Asked Questions
2961 @chapter Frequently Asked Questions
2962 @cindex frequently asked questions
2963 @cindex FAQ
2964
2965 @itemize @bullet
2966 @item
2967 Where can I get the latest @value{tramp}?
2968
2969 @value{tramp} is available under the URL below.
2970
2971 @noindent
2972 @uref{ftp://ftp.gnu.org/gnu/tramp/}
2973
2974 @noindent
2975 There is also a Savannah project page.
2976
2977 @noindent
2978 @uref{http://savannah.gnu.org/projects/tramp/}
2979
2980
2981 @item
2982 Which systems does it work on?
2983
2984 The package has been used successfully on Emacs 22, Emacs 23, Emacs
2985 24, XEmacs 21 (starting with 21.4), and SXEmacs 22.
2986
2987 The package was intended to work on Unix, and it really expects a
2988 Unix-like system on the remote end (except the @option{smb} method),
2989 but some people seemed to have some success getting it to work on MS
2990 Windows XP/Vista/7 @value{emacsname}.
2991
2992
2993 @item
2994 How could I speed up @value{tramp}?
2995
2996 In the backstage, @value{tramp} needs a lot of operations on the
2997 remote host. The time for transferring data from and to the remote
2998 host as well as the time needed to perform the operations there count.
2999 In order to speed up @value{tramp}, one could either try to avoid some
3000 of the operations, or one could try to improve their performance.
3001
3002 Use an external method, like @option{scp}.
3003
3004 Use caching. This is already enabled by default. Information about
3005 the remote host as well as the remote files are cached for reuse. The
3006 information about remote hosts is kept in the file specified in
3007 @code{tramp-persistency-file-name}. Keep this file. If you are
3008 confident that files on remote hosts are not changed out of
3009 @value{emacsname}' control, set @code{remote-file-name-inhibit-cache}
3010 to @code{nil}. Set also @code{tramp-completion-reread-directory-timeout}
3011 to @code{nil}, @ref{Filename completion}.
3012
3013 Disable version control. If you access remote files which are not
3014 under version control, a lot of check operations can be avoided by
3015 disabling VC@. This can be achieved by
3016
3017 @lisp
3018 (setq vc-ignore-dir-regexp
3019 (format "\\(%s\\)\\|\\(%s\\)"
3020 vc-ignore-dir-regexp
3021 tramp-file-name-regexp))
3022 @end lisp
3023
3024 Disable excessive traces. The default trace level of @value{tramp},
3025 defined in the variable @code{tramp-verbose}, is 3. You should
3026 increase this level only temporarily, hunting bugs.
3027
3028
3029 @item
3030 @value{tramp} does not connect to the remote host
3031
3032 When @value{tramp} does not connect to the remote host, there are three
3033 reasons heading the bug mailing list:
3034
3035 @itemize @minus
3036 @item
3037 Unknown characters in the prompt
3038
3039 @value{tramp} needs to recognize the prompt on the remote machine
3040 after execution any command. This is not possible when the prompt
3041 contains unknown characters like escape sequences for coloring. This
3042 should be avoided on the remote side. @xref{Remote shell setup}. for
3043 setting the regular expression detecting the prompt.
3044
3045 You can check your settings after an unsuccessful connection by
3046 switching to the @value{tramp} connection buffer @file{*tramp/foo*},
3047 setting the cursor at the top of the buffer, and applying the expression
3048
3049 @example
3050 @kbd{M-: (re-search-forward (concat tramp-shell-prompt-pattern "$"))}
3051 @end example
3052
3053 If it fails, or the cursor is not moved at the end of the buffer, your
3054 prompt is not recognized correctly.
3055
3056 A special problem is the zsh, which uses left-hand side and right-hand
3057 side prompts in parallel. Therefore, it is necessary to disable the
3058 zsh line editor on the remote host. You shall add to @file{~/.zshrc}
3059 the following command:
3060
3061 @example
3062 [ $TERM = "dumb" ] && unsetopt zle && PS1='$ '
3063 @end example
3064
3065 Furthermore it has been reported, that @value{tramp} (like sshfs,
3066 incidentally) doesn't work with WinSSHD due to strange prompt settings.
3067
3068 @item
3069 Echoed characters after login
3070
3071 When the remote machine opens an echoing shell, there might be control
3072 characters in the welcome message. @value{tramp} tries to suppress
3073 such echoes via the @command{stty -echo} command, but sometimes this
3074 command is not reached, because the echoed output has confused
3075 @value{tramp} already. In such situations it might be helpful to use
3076 the @option{sshx} or @option{scpx} methods, which allocate a pseudo tty.
3077 @xref{Inline methods}.
3078
3079 @item
3080 @value{tramp} doesn't transfer strings with more than 500 characters
3081 correctly
3082
3083 On some few systems, the implementation of @code{process-send-string}
3084 seems to be broken for longer strings. It is reported for HP-UX,
3085 FreeBSD and Tru64 Unix, for example. This case, you should customize
3086 the variable @code{tramp-chunksize} to 500. For a description how to
3087 determine whether this is necessary see the documentation of
3088 @code{tramp-chunksize}.
3089
3090 Additionally, it will be useful to set @code{file-precious-flag} to
3091 @code{t} for @value{tramp} files. Then the file contents will be
3092 written into a temporary file first, which is checked for correct
3093 checksum.
3094 @ifinfo
3095 @pxref{Saving Buffers, , , elisp}
3096 @end ifinfo
3097
3098 @lisp
3099 (add-hook
3100 'find-file-hook
3101 (lambda ()
3102 (when (file-remote-p default-directory)
3103 (set (make-local-variable 'file-precious-flag) t))))
3104 @end lisp
3105 @end itemize
3106
3107
3108 @item
3109 @value{tramp} does not recognize hung @command{ssh} sessions
3110
3111 When your network connection is down, @command{ssh} sessions might
3112 hang. @value{tramp} cannot detect it safely, because it still sees a
3113 running @command{ssh} process. Timeouts cannot be used as well,
3114 because it cannot be predicted how long a remote command will last,
3115 for example when copying very large files.
3116
3117 Therefore, you must configure the @command{ssh} process to die
3118 in such a case. The following entry in @file{~/.ssh/config} would do
3119 the job:
3120
3121 @example
3122 Host *
3123 ServerAliveInterval 5
3124 @end example
3125
3126
3127 @item
3128 @value{tramp} does not use my @command{ssh} @code{ControlPath}
3129
3130 Your @code{ControlPath} setting will be overwritten by @command{ssh}
3131 sessions initiated by @value{tramp}. This is because a master
3132 session, initiated outside @value{emacsname}, could be closed, which
3133 would stall all other @command{ssh} sessions for that host inside
3134 @value{emacsname}.
3135
3136 Consequently, if you connect to a remote host via @value{tramp}, you
3137 might be prompted for a password again, even if you have established
3138 already an @command{ssh} connection to that host. Further
3139 @value{tramp} connections to that host, for example in order to run a
3140 process on that host, will reuse that initial @command{ssh}
3141 connection.
3142
3143 If your @command{ssh} version supports the @code{ControlPersist}
3144 option, you could customize the variable
3145 @code{tramp-ssh-controlmaster-options} to use your @code{ControlPath},
3146 for example:
3147
3148 @lisp
3149 (setq tramp-ssh-controlmaster-options
3150 (concat
3151 "-o ControlPath=/tmp/ssh-ControlPath-%%r@@%%h:%%p "
3152 "-o ControlMaster=auto -o ControlPersist=yes"))
3153 @end lisp
3154
3155 Note, that "%r", "%h" and "%p" must be encoded as "%%r", "%%h" and
3156 "%%p", respectively.
3157
3158 These settings can be suppressed, if they are configured properly in
3159 your @file{~/.ssh/config}:
3160
3161 @lisp
3162 (setq tramp-use-ssh-controlmaster-options nil)
3163 @end lisp
3164
3165
3166 @item
3167 File name completion does not work with @value{tramp}
3168
3169 When you log in to the remote machine, do you see the output of
3170 @command{ls} in color? If so, this may be the cause of your problems.
3171
3172 @command{ls} outputs @acronym{ANSI} escape sequences that your terminal
3173 emulator interprets to set the colors. These escape sequences will
3174 confuse @value{tramp} however.
3175
3176 In your @file{.bashrc}, @file{.profile} or equivalent on the remote
3177 machine you probably have an alias configured that adds the option
3178 @option{--color=yes} or @option{--color=auto}.
3179
3180 You should remove that alias and ensure that a new login @emph{does not}
3181 display the output of @command{ls} in color. If you still cannot use
3182 filename completion, report a bug to the @value{tramp} developers.
3183
3184
3185 @item
3186 File name completion does not work in large directories
3187
3188 @value{tramp} uses globbing for some operations. (Globbing means to use the
3189 shell to expand wildcards such as `*.c'.) This might create long
3190 command lines, especially in directories with many files. Some shells
3191 choke on long command lines, or don't cope well with the globbing
3192 itself.
3193
3194 If you have a large directory on the remote end, you may wish to execute
3195 a command like @samp{ls -d * ..?* > /dev/null} and see if it hangs.
3196 Note that you must first start the right shell, which might be
3197 @command{/bin/sh}, @command{ksh} or @command{bash}, depending on which
3198 of those supports tilde expansion.
3199
3200
3201 @item
3202 How can I get notified when @value{tramp} file transfers are complete?
3203
3204 The following snippet can be put in your @file{~/.emacs} file. It
3205 makes @value{emacsname} beep after reading from or writing to the
3206 remote host.
3207
3208 @lisp
3209 (defadvice tramp-handle-write-region
3210 (after tramp-write-beep-advice activate)
3211 "Make tramp beep after writing a file."
3212 (interactive)
3213 (beep))
3214
3215 (defadvice tramp-handle-do-copy-or-rename-file
3216 (after tramp-copy-beep-advice activate)
3217 "Make tramp beep after copying a file."
3218 (interactive)
3219 (beep))
3220
3221 (defadvice tramp-handle-insert-file-contents
3222 (after tramp-insert-beep-advice activate)
3223 "Make tramp beep after inserting a file."
3224 (interactive)
3225 (beep))
3226 @end lisp
3227
3228
3229 @ifset emacs
3230 @item
3231 I'ld like to get a Visual Warning when working in a sudo:ed context
3232
3233 When you are working with @samp{root} privileges, it might be useful
3234 to get an indication in the buffer's modeline. The following code,
3235 tested with @value{emacsname} 22.1, does the job. You should put it
3236 into your @file{~/.emacs}:
3237
3238 @lisp
3239 (defun my-mode-line-function ()
3240 (when (string-match "^/su\\(do\\)?:" default-directory)
3241 (setq mode-line-format
3242 (format-mode-line mode-line-format 'font-lock-warning-face))))
3243
3244 (add-hook 'find-file-hook 'my-mode-line-function)
3245 (add-hook 'dired-mode-hook 'my-mode-line-function)
3246 @end lisp
3247 @end ifset
3248
3249
3250 @ifset emacs
3251 @item
3252 I'ld like to see a host indication in the mode line when I'm remote
3253
3254 The following code has been tested with @value{emacsname} 22.1. You
3255 should put it into your @file{~/.emacs}:
3256
3257 @lisp
3258 (defconst my-mode-line-buffer-identification
3259 (list
3260 '(:eval
3261 (let ((host-name
3262 (if (file-remote-p default-directory)
3263 (tramp-file-name-host
3264 (tramp-dissect-file-name default-directory))
3265 (system-name))))
3266 (if (string-match "^[^0-9][^.]*\\(\\..*\\)" host-name)
3267 (substring host-name 0 (match-beginning 1))
3268 host-name)))
3269 ": %12b"))
3270
3271 (setq-default
3272 mode-line-buffer-identification
3273 my-mode-line-buffer-identification)
3274
3275 (add-hook
3276 'dired-mode-hook
3277 (lambda ()
3278 (setq
3279 mode-line-buffer-identification
3280 my-mode-line-buffer-identification)))
3281 @end lisp
3282
3283 Since @value{emacsname} 23.1, the mode line contains an indication if
3284 @code{default-directory} for the current buffer is on a remote host.
3285 The corresponding tooltip includes the name of that host. If you
3286 still want the host name as part of the mode line, you can use the
3287 example above, but the @code{:eval} clause can be simplified:
3288
3289 @lisp
3290 '(:eval
3291 (let ((host-name
3292 (or (file-remote-p default-directory 'host)
3293 (system-name))))
3294 (if (string-match "^[^0-9][^.]*\\(\\..*\\)" host-name)
3295 (substring host-name 0 (match-beginning 1))
3296 host-name)))
3297 @end lisp
3298 @end ifset
3299
3300
3301 @ifset emacs
3302 @item
3303 My remote host does not understand default directory listing options
3304
3305 @value{emacsname} computes the @command{dired} options depending on
3306 the local host you are working. If your @command{ls} command on the
3307 remote host does not understand those options, you can change them
3308 like this:
3309
3310 @lisp
3311 (add-hook
3312 'dired-before-readin-hook
3313 (lambda ()
3314 (when (file-remote-p default-directory)
3315 (setq dired-actual-switches "-al"))))
3316 @end lisp
3317 @end ifset
3318
3319
3320 @item
3321 There's this @file{~/.sh_history} file on the remote host which keeps
3322 growing and growing. What's that?
3323
3324 Sometimes, @value{tramp} starts @command{ksh} on the remote host for
3325 tilde expansion. Maybe @command{ksh} saves the history by default.
3326 @value{tramp} tries to turn off saving the history, but maybe you have
3327 to help. For example, you could put this in your @file{.kshrc}:
3328
3329 @example
3330 if [ -f $HOME/.sh_history ] ; then
3331 /bin/rm $HOME/.sh_history
3332 fi
3333 if [ "$@{HISTFILE-unset@}" != "unset" ] ; then
3334 unset HISTFILE
3335 fi
3336 if [ "$@{HISTSIZE-unset@}" != "unset" ] ; then
3337 unset HISTSIZE
3338 fi
3339 @end example
3340
3341
3342 @item There are longish file names to type. How to shorten this?
3343
3344 Let's say you need regularly access to @file{@trampfn{ssh, news,
3345 news.my.domain, /opt/news/etc}}, which is boring to type again and
3346 again. The following approaches can be mixed:
3347
3348 @enumerate
3349
3350 @item Use default values for method and user name:
3351
3352 You can define default methods and user names for hosts,
3353 (@pxref{Default Method}, @pxref{Default User}):
3354
3355 @lisp
3356 (setq tramp-default-method "ssh"
3357 tramp-default-user "news")
3358 @end lisp
3359
3360 The file name left to type would be
3361 @kbd{C-x C-f @trampfn{, , news.my.domain, /opt/news/etc}}.
3362
3363 Note that there are some useful settings already. Accessing your
3364 local host as @samp{root} user, is possible just by @kbd{C-x C-f
3365 @trampfn{su, , ,}}.
3366
3367 @item Use configuration possibilities of your method:
3368
3369 Several connection methods (i.e., the programs used) offer powerful
3370 configuration possibilities (@pxref{Customizing Completion}). In the
3371 given case, this could be @file{~/.ssh/config}:
3372
3373 @example
3374 Host xy
3375 HostName news.my.domain
3376 User news
3377 @end example
3378
3379 The file name left to type would be @kbd{C-x C-f @trampfn{ssh, , xy,
3380 /opt/news/etc}}. Depending on files in your directories, it is even
3381 possible to complete the host name with @kbd{C-x C-f
3382 @value{prefix}ssh@value{postfixhop}x @key{TAB}}.
3383
3384 @item Use environment variables:
3385
3386 File names typed in the minibuffer can be expanded by environment
3387 variables. You can set them outside @value{emacsname}, or even with
3388 Lisp:
3389
3390 @lisp
3391 (setenv "xy" "@trampfn{ssh, news, news.my.domain, /opt/news/etc/}")
3392 @end lisp
3393
3394 Then you need simply to type @kbd{C-x C-f $xy @key{RET}}, and here you
3395 are. The disadvantage is that you cannot edit the file name, because
3396 environment variables are not expanded during editing in the
3397 minibuffer.
3398
3399 @item Define own keys:
3400
3401 You can define your own key sequences in @value{emacsname}, which can
3402 be used instead of @kbd{C-x C-f}:
3403
3404 @lisp
3405 (global-set-key
3406 [(control x) (control y)]
3407 (lambda ()
3408 (interactive)
3409 (find-file
3410 (read-file-name
3411 "Find Tramp file: "
3412 "@trampfn{ssh, news, news.my.domain, /opt/news/etc/}"))))
3413 @end lisp
3414
3415 Simply typing @kbd{C-x C-y} would initialize the minibuffer for
3416 editing with your beloved file name.
3417
3418 See also @uref{http://www.emacswiki.org/cgi-bin/wiki/TrampMode, the
3419 Emacs Wiki} for a more comprehensive example.
3420
3421 @item Define own abbreviation (1):
3422
3423 It is possible to define an own abbreviation list for expanding file
3424 names:
3425
3426 @lisp
3427 (add-to-list
3428 'directory-abbrev-alist
3429 '("^/xy" . "@trampfn{ssh, news, news.my.domain, /opt/news/etc/}"))
3430 @end lisp
3431
3432 This shortens the file opening command to @kbd{C-x C-f /xy
3433 @key{RET}}. The disadvantage is, again, that you cannot edit the file
3434 name, because the expansion happens after entering the file name only.
3435
3436 @item Define own abbreviation (2):
3437
3438 The @code{abbrev-mode} gives more flexibility for editing the
3439 minibuffer:
3440
3441 @lisp
3442 (define-abbrev-table 'my-tramp-abbrev-table
3443 '(("xy" "@trampfn{ssh, news, news.my.domain, /opt/news/etc/}")))
3444
3445 (add-hook
3446 'minibuffer-setup-hook
3447 (lambda ()
3448 (abbrev-mode 1)
3449 (setq local-abbrev-table my-tramp-abbrev-table)))
3450
3451 (defadvice minibuffer-complete
3452 (before my-minibuffer-complete activate)
3453 (expand-abbrev))
3454
3455 ;; If you use partial-completion-mode
3456 (defadvice PC-do-completion
3457 (before my-PC-do-completion activate)
3458 (expand-abbrev))
3459 @end lisp
3460
3461 After entering @kbd{C-x C-f xy @key{TAB}}, the minibuffer is
3462 expanded, and you can continue editing.
3463
3464 @item Use bookmarks:
3465
3466 Bookmarks can be used to visit Tramp files or directories.
3467 @ifinfo
3468 @pxref{Bookmarks, , , @value{emacsdir}}
3469 @end ifinfo
3470
3471 When you have opened @file{@trampfn{ssh, news, news.my.domain,
3472 /opt/news/etc/}}, you should save the bookmark via
3473 @ifset emacs
3474 @kbd{@key{menu-bar} @key{edit} @key{bookmarks} @key{set}}.
3475 @end ifset
3476 @ifset xemacs
3477 @kbd{@key{menu-bar} @key{view} @key{bookmarks} @key{set}}.
3478 @end ifset
3479
3480 Later on, you can always navigate to that bookmark via
3481 @ifset emacs
3482 @kbd{@key{menu-bar} @key{edit} @key{bookmarks} @key{jump}}.
3483 @end ifset
3484 @ifset xemacs
3485 @kbd{@key{menu-bar} @key{view} @key{bookmarks} @key{jump}}.
3486 @end ifset
3487
3488 @item Use recent files:
3489
3490 @ifset emacs
3491 @file{recentf}
3492 @end ifset
3493 @ifset xemacs
3494 @file{recent-files}
3495 @end ifset
3496 remembers visited places.
3497 @ifinfo
3498 @ifset emacs
3499 @pxref{File Conveniences, , , @value{emacsdir}}
3500 @end ifset
3501 @ifset xemacs
3502 @pxref{recent-files, , , edit-utils}
3503 @end ifset
3504 @end ifinfo
3505
3506 You could keep remote file names in the recent list without checking
3507 their readability through a remote access:
3508
3509 @lisp
3510 @ifset emacs
3511 (recentf-mode 1)
3512 @end ifset
3513 @ifset xemacs
3514 (recent-files-initialize)
3515 (add-hook
3516 'find-file-hook
3517 (lambda ()
3518 (when (file-remote-p (buffer-file-name))
3519 (recent-files-make-permanent)))
3520 'append)
3521 @end ifset
3522 @end lisp
3523
3524 The list of files opened recently is reachable via
3525 @ifset emacs
3526 @kbd{@key{menu-bar} @key{file} @key{Open Recent}}.
3527 @end ifset
3528 @ifset xemacs
3529 @kbd{@key{menu-bar} @key{Recent Files}}.
3530 @end ifset
3531
3532 @ifset emacs
3533 @item Use filecache:
3534
3535 @file{filecache} remembers visited places. Add the directory into
3536 the cache:
3537
3538 @lisp
3539 (eval-after-load "filecache"
3540 '(file-cache-add-directory
3541 "@trampfn{ssh, news, news.my.domain, /opt/news/etc/}"))
3542 @end lisp
3543
3544 Whenever you want to load a file, you can enter @kbd{C-x C-f
3545 C-@key{TAB}} in the minibuffer. The completion is done for the given
3546 directory.
3547 @end ifset
3548
3549 @ifset emacs
3550 @item Use bbdb:
3551
3552 @file{bbdb} has a built-in feature for @value{ftppackagename} files,
3553 which works also for @value{tramp}.
3554 @ifinfo
3555 @pxref{bbdb-ftp, Storing FTP sites in the BBDB, , bbdb}
3556 @end ifinfo
3557
3558 You need to load @file{bbdb}:
3559
3560 @lisp
3561 (require 'bbdb)
3562 (bbdb-initialize)
3563 @end lisp
3564
3565 Then you can create a BBDB entry via @kbd{M-x bbdb-create-ftp-site}.
3566 Because BBDB is not prepared for @value{tramp} syntax, you must
3567 specify a method together with the user name when needed. Example:
3568
3569 @example
3570 @kbd{M-x bbdb-create-ftp-site @key{RET}}
3571 @b{Ftp Site:} news.my.domain @key{RET}
3572 @b{Ftp Directory:} /opt/news/etc/ @key{RET}
3573 @b{Ftp Username:} ssh@value{postfixhop}news @key{RET}
3574 @b{Company:} @key{RET}
3575 @b{Additional Comments:} @key{RET}
3576 @end example
3577
3578 When you have opened your BBDB buffer, you can access such an entry by
3579 pressing the key @key{F}.
3580 @end ifset
3581
3582 @end enumerate
3583
3584 I would like to thank all @value{tramp} users who have contributed to
3585 the different recipes!
3586
3587
3588 @ifset emacs
3589 @item
3590 How can I use @value{tramp} to connect to a remote @value{emacsname}
3591 session?
3592
3593 You can configure Emacs Client doing this.
3594 @ifinfo
3595 @xref{Emacs Server, , , @value{emacsdir}}.
3596 @end ifinfo
3597
3598 On the remote host, you start the Emacs Server:
3599
3600 @lisp
3601 (require 'server)
3602 (setq server-host (system-name)
3603 server-use-tcp t)
3604 (server-start)
3605 @end lisp
3606
3607 Make sure that the result of @code{(system-name)} can be resolved on
3608 your local host; otherwise you might use a hard coded IP address.
3609
3610 The resulting file @file{~/.emacs.d/server/server} must be copied to
3611 your local host, at the same location. You can call then the Emacs
3612 Client from the command line:
3613
3614 @example
3615 emacsclient @trampfn{ssh, user, host, /file/to/edit}
3616 @end example
3617
3618 @code{user} and @code{host} shall be related to your local host.
3619
3620 If you want to use Emacs Client also as editor for other programs, you
3621 could write a script @file{emacsclient.sh}:
3622
3623 @example
3624 #!/bin/sh
3625 emacsclient @trampfn{ssh, $(whoami), $(hostname --fqdn), $1}
3626 @end example
3627
3628 Then you must set the environment variable @env{EDITOR} pointing to
3629 that script:
3630
3631 @example
3632 export EDITOR=/path/to/emacsclient.sh
3633 @end example
3634 @end ifset
3635
3636
3637 @item
3638 There are packages which call @value{tramp} although I haven't entered
3639 a remote file name ever. I dislike it, how could I disable it?
3640
3641 In general, @value{tramp} functions are used only when
3642 you apply remote file name syntax. However, some packages enable
3643 @value{tramp} on their own.
3644
3645 @itemize @minus
3646 @item
3647 @file{ido.el}
3648
3649 You could disable @value{tramp} file name completion:
3650
3651 @lisp
3652 (custom-set-variables
3653 '(ido-enable-tramp-completion nil))
3654 @end lisp
3655
3656 @item
3657 @file{rlogin.el}
3658
3659 You could disable remote directory tracking mode:
3660
3661 @lisp
3662 (rlogin-directory-tracking-mode -1)
3663 @end lisp
3664 @end itemize
3665
3666
3667 @item
3668 How can I disable @value{tramp} at all?
3669
3670 Shame on you, why did you read until now?
3671
3672 @itemize @minus
3673 @ifset emacs
3674 @item
3675 If you just want to have @value{ftppackagename} as default remote
3676 files access package, you should apply the following code:
3677
3678 @lisp
3679 (setq tramp-default-method "ftp")
3680 @end lisp
3681 @end ifset
3682
3683 @item
3684 In order to disable
3685 @ifset emacs
3686 @value{tramp} (and @value{ftppackagename}),
3687 @end ifset
3688 @ifset xemacs
3689 @value{tramp},
3690 @end ifset
3691 you must set @code{tramp-mode} to @code{nil}:
3692
3693 @lisp
3694 (setq tramp-mode nil)
3695 @end lisp
3696
3697 @item
3698 Unloading @value{tramp} can be achieved by applying @kbd{M-x
3699 tramp-unload-tramp}.
3700 @ifset emacs
3701 This resets also the @value{ftppackagename} plugins.
3702 @end ifset
3703 @end itemize
3704 @end itemize
3705
3706
3707 @c For the developer
3708 @node Files directories and localnames
3709 @chapter How file names, directories and localnames are mangled and managed.
3710
3711 @menu
3712 * Localname deconstruction:: Breaking a localname into its components.
3713 @ifset emacs
3714 * External packages:: Integration with external Lisp packages.
3715 @end ifset
3716 @end menu
3717
3718
3719 @node Localname deconstruction
3720 @section Breaking a localname into its components
3721
3722 @value{tramp} file names are somewhat different, obviously, to ordinary file
3723 names. As such, the lisp functions @code{file-name-directory} and
3724 @code{file-name-nondirectory} are overridden within the @value{tramp}
3725 package.
3726
3727 Their replacements are reasonably simplistic in their approach. They
3728 dissect the filename, call the original handler on the localname and
3729 then rebuild the @value{tramp} file name with the result.
3730
3731 This allows the platform specific hacks in the original handlers to take
3732 effect while preserving the @value{tramp} file name information.
3733
3734
3735 @ifset emacs
3736 @node External packages
3737 @section Integration with external Lisp packages
3738 @subsection Filename completion.
3739
3740 While reading filenames in the minibuffer, @value{tramp} must decide
3741 whether it completes possible incomplete filenames, or not. Imagine
3742 there is the following situation: You have typed @kbd{C-x C-f
3743 @value{prefix}ssh@value{postfixhop} @key{TAB}}. @value{tramp} cannot
3744 know, whether @option{ssh} is a method or a host name. It checks
3745 therefore the last input character you have typed. If this is
3746 @key{TAB}, @key{SPACE} or @kbd{?}, @value{tramp} assumes that you are
3747 still in filename completion, and it does not connect to the possible
3748 remote host @option{ssh}.
3749
3750 External packages, which use other characters for completing filenames
3751 in the minibuffer, must signal this to @value{tramp}. For this case,
3752 the variable @code{non-essential} can be bound temporarily to
3753 a non-@code{nil} value.
3754
3755 @lisp
3756 (let ((non-essential t))
3757 ...)
3758 @end lisp
3759
3760
3761 @subsection File attributes cache.
3762
3763 When @value{tramp} runs remote processes, files on the remote host
3764 could change their attributes. Consequently, @value{tramp} must flush
3765 its complete cache keeping attributes for all files of the remote host
3766 it has seen so far.
3767
3768 This is a performance degradation, because the lost file attributes
3769 must be recomputed when needed again. In cases the caller of
3770 @code{process-file} knows that there are no file attribute changes, it
3771 shall let-bind the variable @code{process-file-side-effects} to
3772 @code{nil}. @value{tramp} wouldn't flush the file attributes cache then.
3773
3774 @lisp
3775 (let (process-file-side-effects)
3776 ...)
3777 @end lisp
3778
3779 For asynchronous processes, @value{tramp} flushes the file attributes
3780 cache via a process sentinel. If the caller of
3781 @code{start-file-process} knows that there are no file attribute
3782 changes, it shall set the process sentinel to @code{nil}. In case the
3783 caller defines an own process sentinel, @value{tramp}'s process
3784 sentinel is overwritten. The caller can still flush the file
3785 attributes cache in its process sentinel with this code:
3786
3787 @lisp
3788 (unless (memq (process-status proc) '(run open))
3789 (dired-uncache remote-directory))
3790 @end lisp
3791
3792 @code{remote-directory} shall be the root directory, where file
3793 attribute changes can happen during the process lifetime.
3794 @value{tramp} traverses all subdirectories, starting at this
3795 directory. Often, it is sufficient to use @code{default-directory} of
3796 the process buffer as root directory.
3797 @end ifset
3798
3799
3800 @node Traces and Profiles
3801 @chapter How to Customize Traces
3802
3803 All @value{tramp} messages are raised with a verbosity level. The
3804 verbosity level can be any number between 0 and 10. Only messages with
3805 a verbosity level less than or equal to @code{tramp-verbose} are
3806 displayed.
3807
3808 The verbosity levels are
3809
3810 @w{ 0} silent (no @value{tramp} messages at all)
3811 @*@indent @w{ 1} errors
3812 @*@indent @w{ 2} warnings
3813 @*@indent @w{ 3} connection to remote hosts (default verbosity)
3814 @*@indent @w{ 4} activities
3815 @*@indent @w{ 5} internal
3816 @*@indent @w{ 6} sent and received strings
3817 @*@indent @w{ 7} file caching
3818 @*@indent @w{ 8} connection properties
3819 @*@indent @w{ 9} test commands
3820 @*@indent @w{10} traces (huge)
3821
3822 When @code{tramp-verbose} is greater than or equal to 4, the messages
3823 are also written into a @value{tramp} debug buffer. This debug buffer
3824 is useful for analyzing problems; sending a @value{tramp} bug report
3825 should be done with @code{tramp-verbose} set to a verbosity level of at
3826 least 6 (@pxref{Bug Reports}).
3827
3828 The debug buffer is in
3829 @ifinfo
3830 @ref{Outline Mode, , , @value{emacsdir}}.
3831 @end ifinfo
3832 @ifnotinfo
3833 Outline Mode.
3834 @end ifnotinfo
3835 That means, you can change the level of messages to be viewed. If you
3836 want, for example, see only messages up to verbosity level 5, you must
3837 enter @kbd{C-u 6 C-c C-q}.
3838 @ifinfo
3839 Other keys for navigating are described in
3840 @ref{Outline Visibility, , , @value{emacsdir}}.
3841 @end ifinfo
3842
3843 @value{tramp} errors are handled internally in order to raise the
3844 verbosity level 1 messages. When you want to get a Lisp backtrace in
3845 case of an error, you need to set both
3846
3847 @lisp
3848 (setq debug-on-error t
3849 debug-on-signal t)
3850 @end lisp
3851
3852 Sometimes, it might be even necessary to step through @value{tramp}
3853 function call traces. Such traces are enabled by the following code:
3854
3855 @lisp
3856 (require 'tramp)
3857 (require 'trace)
3858 (dolist (elt (all-completions "tramp-" obarray 'functionp))
3859 (trace-function-background (intern elt)))
3860 (untrace-function 'tramp-read-passwd)
3861 (untrace-function 'tramp-gw-basic-authentication)
3862 @end lisp
3863
3864 The function call traces are inserted in the buffer
3865 @file{*trace-output*}. @code{tramp-read-passwd} and
3866 @code{tramp-gw-basic-authentication} shall be disabled when the
3867 function call traces are added to @value{tramp}, because both
3868 functions return password strings, which should not be distributed.
3869
3870
3871 @node Issues
3872 @chapter Debatable Issues and What Was Decided
3873
3874 @itemize @bullet
3875 @item The uuencode method does not always work.
3876
3877 Due to the design of @value{tramp}, the encoding and decoding programs
3878 need to read from stdin and write to stdout. On some systems,
3879 @command{uudecode -o -} will read stdin and write the decoded file to
3880 stdout, on other systems @command{uudecode -p} does the same thing.
3881 But some systems have uudecode implementations which cannot do this at
3882 all---it is not possible to call these uudecode implementations with
3883 suitable parameters so that they write to stdout.
3884
3885 Of course, this could be circumvented: the @code{begin foo 644} line
3886 could be rewritten to put in some temporary file name, then
3887 @command{uudecode} could be called, then the temp file could be
3888 printed and deleted.
3889
3890 But I have decided that this is too fragile to reliably work, so on some
3891 systems you'll have to do without the uuencode methods.
3892
3893 @item The @value{tramp} filename syntax differs between Emacs and XEmacs.
3894
3895 The Emacs maintainers wish to use a unified filename syntax for
3896 Ange-FTP and @value{tramp} so that users don't have to learn a new
3897 syntax. It is sufficient to learn some extensions to the old syntax.
3898
3899 For the XEmacs maintainers, the problems caused from using a unified
3900 filename syntax are greater than the gains. The XEmacs package system
3901 uses EFS for downloading new packages. So, obviously, EFS has to be
3902 installed from the start. If the filenames were unified, @value{tramp}
3903 would have to be installed from the start, too.
3904
3905 @ifset xemacs
3906 @strong{Note:} If you'd like to use a similar syntax like
3907 @value{ftppackagename}, you need the following settings in your init
3908 file:
3909
3910 @lisp
3911 (setq tramp-unified-filenames t)
3912 (require 'tramp)
3913 @end lisp
3914
3915 The autoload of the @value{emacsname} @value{tramp} package must be
3916 disabled. This can be achieved by setting file permissions @code{000}
3917 to the files @file{.../xemacs-packages/lisp/tramp/auto-autoloads.el*}.
3918
3919 In case of unified filenames, all @value{emacsname} download sites are
3920 added to @code{tramp-default-method-alist} with default method
3921 @option{ftp} @xref{Default Method}. These settings shouldn't be
3922 touched for proper working of the @value{emacsname} package system.
3923
3924 The syntax for unified filenames is described in the @value{tramp} manual
3925 for @value{emacsothername}.
3926 @end ifset
3927 @end itemize
3928
3929
3930 @node GNU Free Documentation License
3931 @appendix GNU Free Documentation License
3932 @include doclicense.texi
3933
3934
3935 @node Function Index
3936 @unnumbered Function Index
3937 @printindex fn
3938
3939
3940 @node Variable Index
3941 @unnumbered Variable Index
3942 @printindex vr
3943
3944
3945 @node Concept Index
3946 @unnumbered Concept Index
3947 @printindex cp
3948
3949 @bye
3950
3951 @c TODO
3952 @c
3953 @c * Say something about the .login and .profile files of the remote
3954 @c shells.
3955 @c * Explain how tramp.el works in principle: open a shell on a remote
3956 @c host and then send commands to it.
3957 @c * Use `filename' resp. `file name' consistently.
3958 @c * Use `host' resp. `machine' consistently.
3959 @c * Consistent small or capitalized words especially in menus.
3960 @c * Make a unique declaration of @trampfn.