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