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