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