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