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