]> code.delx.au - gnu-emacs/blob - doc/misc/tramp.texi
; Merge from origin/emacs-25
[gnu-emacs] / doc / misc / tramp.texi
1 \input texinfo @c -*- mode: texinfo; coding: utf-8 -*-
2 @setfilename ../../info/tramp.info
3 @c %**start of header
4 @settitle TRAMP User Manual
5 @include docstyle.texi
6 @c %**end of header
7
8 @c This is *so* much nicer :)
9 @footnotestyle end
10
11 @c In the Tramp repository, the version number is auto-frobbed from
12 @c configure.ac, so you should edit that file and run
13 @c "autoconf && ./configure" to change the version number.
14
15 @c Additionally, flags are set with respect to the Emacs flavor; and
16 @c depending whether Tramp is packaged into (X)Emacs, or standalone.
17
18 @include trampver.texi
19
20 @c Macro for formatting a file name according to the respective
21 @c syntax. Macro arguments should not have any leading or trailing
22 @c whitespace. Not very elegant, but I don't know it better.
23
24 @macro trampfn {method, userhost, localname}
25 @value{prefix}@c
26 \method\@value{postfixhop}@c
27 \userhost\@value{postfix}\localname\
28 @end macro
29
30 @c Similar, but without a method prefix.
31
32 @macro trampf {userhost, localname}
33 @value{prefix}@c
34 \userhost\@value{postfix}\localname\
35 @end macro
36
37 @copying
38 Copyright @copyright{} 1999--2016 Free Software Foundation, Inc.
39
40 @quotation
41 Permission is granted to copy, distribute and/or modify this document
42 under the terms of the GNU Free Documentation License, Version 1.3 or
43 any later version published by the Free Software Foundation; with no
44 Invariant Sections, with the Front-Cover Texts being ``A GNU Manual'',
45 and with the Back-Cover Texts as in (a) below. A copy of the license
46 is included in the section entitled ``GNU Free Documentation License''.
47
48 (a) The FSF's Back-Cover Text is: ``You have the freedom to
49 copy and modify this GNU manual.''
50 @end quotation
51 @end copying
52
53 @c Entries for @command{install-info} to use
54 @dircategory Emacs network features
55 @direntry
56 * TRAMP: (tramp). Transparent Remote Access, Multiple Protocol
57 Emacs remote file access via ssh and scp.
58 @end direntry
59
60 @titlepage
61 @title @value{tramp} version @value{trampver} User Manual
62 @author by Daniel Pittman
63 @author based on documentation by Kai Großjohann
64 @page
65 @insertcopying
66 @end titlepage
67
68 @contents
69
70
71 @node Top, Overview, (dir), (dir)
72 @top @value{tramp} version @value{trampver} User Manual
73
74 @ifnottex
75 This file documents @value{tramp} version @value{trampver}, a remote file
76 editing package for Emacs.
77
78 @value{tramp} stands for ``Transparent Remote (file) Access, Multiple
79 Protocol''. This package provides remote file editing, similar to
80 Ange FTP.
81
82 The difference is that Ange FTP uses FTP to transfer files between the
83 local and the remote host, whereas @value{tramp} uses a combination of
84 @command{rsh} and @command{rcp} or other work-alike programs, such as
85 @command{ssh}/@command{scp}.
86
87 You can find the latest version of this document on the web at
88 @uref{http://www.gnu.org/software/tramp/}.
89
90 @ifhtml
91 The latest release of @value{tramp} is available for
92 @uref{ftp://ftp.gnu.org/gnu/tramp/, download}, or you may see
93 @ref{Obtaining Tramp} for more details, including the Git server
94 details.
95
96 @value{tramp} also has a @uref{http://savannah.gnu.org/projects/tramp/,
97 Savannah Project Page}.
98 @end ifhtml
99
100 There is a mailing list for @value{tramp}, available at
101 @email{tramp-devel@@gnu.org}, and archived at
102 @uref{http://lists.gnu.org/archive/html/tramp-devel/, the
103 @value{tramp} Mail Archive}.
104 @ifhtml
105 Older archives are located at
106 @uref{http://sourceforge.net/mailarchive/forum.php?forum=tramp-devel,
107 SourceForge Mail Archive} and
108 @uref{http://www.mail-archive.com/emacs-rcp@@ls6.cs.uni-dortmund.de/,
109 The Mail Archive}.
110 @c in HTML output, there's no new paragraph.
111 @*@*
112 @end ifhtml
113
114 @insertcopying
115 @end ifnottex
116
117 @menu
118 * Overview:: What @value{tramp} can and cannot do.
119
120 For the end user:
121
122 * Obtaining Tramp:: How to obtain @value{tramp}.
123 * History:: History of @value{tramp}.
124 @ifset installchapter
125 * Installation:: Installing @value{tramp} with your Emacs.
126 @end ifset
127 * Configuration:: Configuring @value{tramp} for use.
128 * Usage:: An overview of the operation of @value{tramp}.
129 * Bug Reports:: Reporting Bugs and Problems.
130 * Frequently Asked Questions:: Questions and answers from the mailing list.
131
132 For the developer:
133
134 * Files directories and localnames::
135 How file names, directories and localnames
136 are mangled and managed.
137 * Traces and Profiles:: How to Customize Traces.
138
139 * GNU Free Documentation License:: The license for this documentation.
140 * Function Index:: @value{tramp} functions.
141 * Variable Index:: User options and variables.
142 * Concept Index:: An item for each concept.
143
144 @detailmenu
145 --- The Detailed Node Listing ---
146 @c
147 @ifset installchapter
148 Installing @value{tramp} with your Emacs
149
150 * Installation parameters:: Parameters in order to control installation.
151 * Load paths:: How to plug-in @value{tramp} into your environment.
152
153 @end ifset
154
155 Configuring @value{tramp} for use
156
157 * Connection types:: Types of connections to remote hosts.
158 * Inline methods:: Inline methods.
159 * External methods:: External methods.
160 * GVFS based methods:: GVFS based external methods.
161 * Gateway methods:: Gateway methods.
162 * Default Method:: Selecting a default method.
163 * Default User:: Selecting a default user.
164 * Default Host:: Selecting a default host.
165 * Multi-hops:: Connecting to a remote host using multiple hops.
166 * Customizing Methods:: Using Non-Standard Methods.
167 * Customizing Completion:: Selecting config files for user/host name completion.
168 * Password handling:: Reusing passwords for several connections.
169 * Connection caching:: Reusing connection related information.
170 * Predefined connection information::
171 Setting own connection related information.
172 * Remote programs:: How @value{tramp} finds and uses programs on the remote host.
173 * Remote shell setup:: Remote shell setup hints.
174 * Android shell setup:: Android shell setup hints.
175 * Auto-save and Backup:: Auto-save and Backup.
176 * Windows setup hints:: Issues with Cygwin ssh.
177
178 Using @value{tramp}
179
180 * File name Syntax:: @value{tramp} file name conventions.
181 * File name completion:: File name completion.
182 * Ad-hoc multi-hops:: Declaring multiple hops in the file name.
183 * Remote processes:: Integration with other Emacs packages.
184 * Cleanup remote connections:: Cleanup remote connections.
185
186 How file names, directories and localnames are mangled and managed
187
188 * Localname deconstruction:: Breaking a localname into its components.
189 * External packages:: Integration with external Lisp packages.
190
191 @end detailmenu
192 @end menu
193
194
195 @node Overview
196 @chapter An overview of @value{tramp}
197 @cindex overview
198
199 @value{tramp} is for transparently accessing remote files from within
200 Emacs. @value{tramp} enables an easy, convenient, and consistent
201 interface to remote files as if they are local files. @value{tramp}'s
202 transparency extends to editing, version control, and @code{dired}.
203
204 @value{tramp} can access remote hosts using any number of access
205 methods, such as @command{rsh}, @command{rlogin}, @command{telnet},
206 and related programs. If these programs can successfully pass
207 @acronym{ASCII]} characters, @value{tramp} can use them.
208 @value{tramp} does not require or mandate 8-bit clean connections.
209
210 @value{tramp}'s most common access method is through @command{ssh}, a
211 more secure alternative to @command{ftp} and other older access
212 methods.
213
214 @value{tramp} on Windows operating systems is integrated with the
215 PuTTY package, and uses the @command{plink} program.
216
217 @value{tramp} mostly operates transparently in the background using
218 the connection programs. As long as these programs enable remote login
219 and can use the terminal, @value{tramp} can adapt them for seamless
220 and transparent access.
221
222 @value{tramp} temporarily transfers a remote file's contents to the
223 local host editing and related operations. @value{tramp} can also
224 transfer files between hosts using standard Emacs interfaces, a
225 benefit of direct integration of @value{tramp} in Emacs.
226
227 @value{tramp} can transfer files using any number of available host
228 programs for remote files, such as @command{rcp}, @command{scp},
229 @command{rsync} or (under Windows) @command{pscp}. @value{tramp}
230 provides easy ways to specify these programs and customize them to
231 specific files, hosts, or access methods.
232
233 For faster small-size file transfers, @value{tramp} supports encoded
234 transfers directly through the shell using @command{mimencode} or
235 @command{uuencode} provided such tools are available on the remote
236 host.
237
238
239 @subsubheading @value{tramp} behind the scenes
240 @cindex behind the scenes
241 @cindex details of operation
242 @cindex how it works
243
244 Accessing a remote file through @value{tramp} entails a series of
245 actions, many of which are transparent to the user. Yet some actions
246 may require user response (such as entering passwords or completing
247 file names). One typical scenario, opening a file on a remote host, is
248 presented here to illustrate the steps involved:
249
250 @kbd{C-x C-f} to initiate find-file, enter part of the @value{tramp}
251 file name, then hit @kbd{@key{TAB}} for completion. If this is the
252 first time connection to that host, here's what happens:
253
254 @itemize
255 @item
256 @value{tramp} invokes @samp{telnet @var{host}} or @samp{rsh @var{host}
257 -l @var{user}} and establishes an external process to connect to the
258 remote host. @value{tramp} communicates with the process through an
259 Emacs buffer, which also shows output from the remote host.
260
261 @item
262 The remote host may prompt for a login name (for @command{telnet}, for
263 example) in the buffer. If on the other hand, the login name was
264 included in the file name portion, @value{tramp} sends the login name
265 followed by a newline.
266
267 @item
268 The remote host may then prompt for a password or pass phrase (for
269 @command{rsh} or for @command{telnet}). @value{tramp} displays the
270 password prompt in the minibuffer. @value{tramp} then sends whatever
271 is entered to the remote host, followed by a newline.
272
273 @item
274 @value{tramp} now waits for either the shell prompt or a failed login
275 message.
276
277 If @value{tramp} does not receive any messages within a timeout period
278 (a minute, for example), then @value{tramp} responds with an error
279 message about not finding the remote shell prompt. If any messages
280 from the remote host, @value{tramp} displays them in the buffer.
281
282 For any @samp{login failed} message from the remote host,
283 @value{tramp} aborts the login attempt, and repeats the login steps
284 again.
285
286 @item
287 Upon successful login and @value{tramp} recognizes the shell prompt
288 from the remote host, @value{tramp} prepares the shell environment by
289 turning off echoing, setting shell prompt, and other housekeeping
290 chores.
291
292 @strong{Note} that for the remote shell, @value{tramp} invokes
293 @command{/bin/sh}. The remote host must recognize @samp{exec /bin/sh}
294 and execute the appropriate shell. This shell must support Bourne
295 shell syntax.
296
297 @item
298 @value{tramp} executes @command{cd} and @command{ls} commands to find
299 which files exist on the remote host. @value{tramp} sometimes uses
300 @command{echo} with globbing. @value{tramp} checks if a file or
301 directory is writable with @command{test}. After each command,
302 @value{tramp} parses the output from the remote host for completing
303 the next operation.
304
305 @item
306 After remote file name completion, @value{tramp} transfers the file
307 contents from the remote host.
308
309 For inline transfers, @value{tramp} sends a command, such as
310 @samp{mimencode -b /path/to/remote/file}, waits until the output has
311 accumulated in the buffer, decodes that output to produce the file's
312 contents.
313
314 For external transfers, @value{tramp} sends a command as follows:
315 @example
316 rcp user@@host:/path/to/remote/file /tmp/tramp.4711
317 @end example
318 @value{tramp} reads the local temporary file @file{/tmp/tramp.4711}
319 into a buffer, and then deletes the temporary file.
320
321 @item
322 Edit, modify, change the buffer contents as normal, and then save the
323 buffer wth @kbd{C-x C-s}.
324
325 @item
326 @value{tramp} transfers the buffer contents to the remote host in
327 a reverse of the process using the appropriate inline or external
328 program.
329 @end itemize
330
331 I hope this has provided you with a basic overview of what happens
332 behind the scenes when you open a file with @value{tramp}.
333
334
335 @c For the end user
336 @node Obtaining Tramp
337 @chapter Obtaining @value{tramp}
338 @cindex obtaining Tramp
339
340 @value{tramp} is included as part of Emacs (since Emacs version 22.1).
341
342 @value{tramp} is also freely packaged for download on the Internet at
343 @uref{ftp://ftp.gnu.org/gnu/tramp/}.
344
345 @value{tramp} development versions are available on Git servers.
346 Development versions contain new and incomplete features.
347
348 One way to obtain from Git server is to visit the Savannah project
349 page at the following URL and then clicking on the Git link in the
350 navigation bar at the top.
351
352 @noindent
353 @uref{http://savannah.gnu.org/projects/tramp/}
354
355 @noindent
356 Another way is to follow the terminal session below:
357
358 @example
359 ] @strong{cd ~/emacs}
360 ] @strong{git clone git://git.savannah.gnu.org/tramp.git}
361 @end example
362
363 @noindent
364 From behind a firewall:
365
366 @example
367 ] @strong{git config --global http.proxy http://user:pwd@@proxy.server.com:8080}
368 ] @strong{git clone http://git.savannah.gnu.org/r/tramp.git}
369 @end example
370
371 @noindent
372 Tramp developers:
373
374 @example
375 ] @strong{git clone login@@git.sv.gnu.org:/srv/git/tramp.git}
376 @end example
377
378 @noindent
379 After one of the above commands, @file{~/emacs/tramp} will
380 containing the latest version of @value{tramp}.
381
382 @noindent
383 To fetch updates from the repository, use git pull:
384
385 @example
386 ] @strong{cd ~/emacs/tramp}
387 ] @strong{git pull}
388 @end example
389
390 @noindent
391 Run @command{autoconf} as follows to generate an up-to-date
392 @file{configure} script:
393
394 @example
395 ] @strong{cd ~/emacs/tramp}
396 ] @strong{autoconf}
397 @end example
398
399
400 @node History
401 @chapter History of @value{tramp}
402 @cindex history
403 @cindex development history
404
405 @value{tramp} development started at the end of November 1998 as
406 @file{rssh.el}. It provided only one method of access. It used
407 @command{ssh} for login and @command{scp} to transfer file contents.
408 The name was changed to @file{rcp.el} before it got its preset name
409 @value{tramp}. New methods of remote access were added, so was support
410 for version control.
411
412 April 2000 was the first time when multi-hop methods were added. In
413 July 2002, @value{tramp} unified file names with Ange-FTP@. In July
414 2004, proxy hosts replaced multi-hop methods. Running commands on
415 remote hosts was introduced in December 2005. Support for gateways
416 since April 2007. GVFS integration started in February 2009. Remote
417 commands on Windows hosts since September 2011. Ad-hoc multi-hop
418 methods (with a changed syntax) re-enabled in November 2011. In
419 November 2012, added Juergen Hoetzel's @file{tramp-adb.el}.
420
421 XEmacs support has been stopped in January 2016.
422
423 @c Installation chapter is necessary only in case of standalone
424 @c installation. Text taken from trampinst.texi.
425 @ifset installchapter
426 @include trampinst.texi
427 @end ifset
428
429
430 @node Configuration
431 @chapter Configuring @value{tramp}
432 @cindex configuration
433 @cindex default configuration
434
435 @value{tramp} is initially configured to use the @command{scp} program
436 to connect to the remote host. Just type @kbd{C-x C-f} and then enter
437 file name @file{@trampf{user@@host,/path/to.file}}. For details, see
438 @xref{Default Method}.
439
440 For problems related to the behavior of remote shell, see @ref{Remote
441 shell setup} for details.
442
443 For changing the connection type and file access method from the
444 defaults to one of several other options, see (@pxref{Connection
445 types}).
446
447 @strong{Note} that some user options and variables described in these
448 examples are not auto loaded by Emacs. All examples require
449 @value{tramp} is installed and loaded:
450
451 @lisp
452 (require 'tramp)
453 @end lisp
454
455
456 @menu
457 * Connection types:: Types of connections to remote hosts.
458 * Inline methods:: Inline methods.
459 * External methods:: External methods.
460 * GVFS based methods:: GVFS based external methods.
461 * Gateway methods:: Gateway methods.
462 * Default Method:: Selecting a default method.
463 Here we also try to help those who
464 don't have the foggiest which method
465 is right for them.
466 * Default User:: Selecting a default user.
467 * Default Host:: Selecting a default host.
468 * Multi-hops:: Connecting to a remote host using multiple hops.
469 * Customizing Methods:: Using Non-Standard Methods.
470 * Customizing Completion:: Selecting config files for user/host name completion.
471 * Password handling:: Reusing passwords for several connections.
472 * Connection caching:: Reusing connection related information.
473 * Predefined connection information::
474 Setting own connection related information.
475 * Remote programs:: How @value{tramp} finds and uses programs on the remote host.
476 * Remote shell setup:: Remote shell setup hints.
477 * Android shell setup:: Android shell setup hints.
478 * Auto-save and Backup:: Auto-save and Backup.
479 * Windows setup hints:: Issues with Cygwin ssh.
480 @end menu
481
482
483 @node Connection types
484 @section Types of connections to remote hosts
485 @cindex connection types, overview
486
487 @dfn{Inline method} and @dfn{external method} are the two basic types
488 of access methods. While they both use the same remote shell access
489 programs, such as @command{rsh}, @command{ssh}, or @command{telnet},
490 they differ in the file access methods. Choosing the right method
491 becomes important for editing files, transferring large files, or
492 operating on a large number of files.
493
494 @cindex inline methods
495 @cindex external methods
496 @cindex methods, inline
497 @cindex methods, external
498
499 The performance of the external methods is generally better than that
500 of the inline methods, at least for large files. This is caused by
501 the need to encode and decode the data when transferring inline.
502
503 The one exception to this rule are the @option{scp}-based access
504 methods. While these methods do see better performance when actually
505 transferring files, the overhead of the cryptographic negotiation at
506 startup may drown out the improvement in file transfer times.
507
508 External methods should be configured such a way that they don't
509 require a password (with @command{ssh-agent}, or such alike). Modern
510 @command{scp} implementations offer options to reuse existing
511 @command{ssh} connections, which will be enabled by default if
512 available. If it isn't possible, you should consider @ref{Password
513 handling}, otherwise you will be prompted for a password every copy
514 action.
515
516
517 @node Inline methods
518 @section Inline methods
519 @cindex inline methods
520 @cindex methods, inline
521
522 Inline methods use the same login connection to transfer file
523 contents. Inline methods are quick and easy for small files. They
524 depend on the availability of suitable encoding and decoding programs
525 on the remote host. For local source and destination, @value{tramp}
526 may use built-in equivalents of such programs in Emacs.
527
528 Inline methods can work in situations where an external transfer
529 program is unavailable. Inline methods also work when transferring
530 files between different @emph{user identities} on the same host.
531
532 @cindex uuencode
533 @cindex mimencode
534 @cindex base-64 encoding
535
536 @value{tramp} checks the remote host for the availability and
537 usability of @command{mimencode} (part of the @command{metamail}
538 package) or @command{uuencode}. @value{tramp} uses the first reliable
539 command it finds. @value{tramp}'s search path can be customized, see
540 @ref{Remote programs}.
541
542 In case both @command{mimencode} and @command{uuencode} are
543 unavailable, @value{tramp} first transfers a small Perl program to the
544 remote host, and then tries that program for encoding and decoding.
545
546 To increase transfer speeds for large text files, use compression
547 before encoding. The variable @var{tramp-inline-compress-start-size}
548 specifies the file size for such optimization.
549
550 @table @asis
551 @item @option{rsh}
552 @cindex method rsh
553 @cindex rsh method
554
555 @command{rsh} is an option for connecting to hosts within local
556 networks since @command{rsh} is not as secure as other methods.
557
558 @item @option{ssh}
559 @cindex method ssh
560 @cindex ssh method
561
562 @command{ssh} is a more secure option than others to connect to a
563 remote host.
564
565 @command{ssh} can also take extra parameters as port numbers. For
566 example, a host on port 42 is specified as @file{host#42} (the real
567 host name, a hash sign, then a port number). It is the same as passing
568 @code{-p 42} to the @command{ssh} command.
569
570 @item @option{telnet}
571 @cindex method telnet
572 @cindex telnet method
573
574 Connecting to a remote host with @command{telnet} is as insecure
575 as the @option{rsh} method.
576
577 @item @option{su}
578 @cindex method su
579 @cindex su method
580
581 Instead of connecting to a remote host, @command{su} program allows
582 editing as another user. The host can be either @samp{localhost} or
583 the host returned by the function @command{(system-name)}. See
584 @ref{Multi-hops} for an exception to this behavior.
585
586 @item @option{sudo}
587 @cindex method sudo
588 @cindex sudo method
589
590 Similar to @option{su} method, @option{sudo} uses @command{sudo}.
591 @command{sudo} must have sufficient rights to start a shell.
592
593 @item @option{sg}
594 @cindex method sg
595 @cindex sg method
596
597 The @command{sg} program allows editing as different group. The host
598 can be either @samp{localhost} or the host returned by the function
599 @command{(system-name)}. The user name must be specified, but it
600 denotes a group name. See @ref{Multi-hops} for an exception to this
601 behavior.
602
603 @item @option{sshx}
604 @cindex method sshx
605 @cindex sshx method
606
607 Works like @option{ssh} but without the extra authentication prompts.
608 @option{sshx} uses @samp{ssh -t -t @var{host} -l @var{user} /bin/sh}
609 to open a connection with a ``standard'' login shell.
610
611 @strong{Note} that @option{sshx} does not bypass authentication
612 questions. For example, if the host key of the remote host is not
613 known, @option{sshx} will still ask ``Are you sure you want to
614 continue connecting?''. @value{tramp} cannot handle such questions.
615 Connections will have to be setup where logins can proceed without
616 such questions.
617
618 @option{sshx} is useful for Windows users when @command{ssh} triggers
619 an error about allocating a pseudo tty. This happens due to missing
620 shell prompts that confuses @value{tramp}.
621
622 @option{sshx} supports the @samp{-p} argument.
623
624 @item @option{krlogin}
625 @cindex method krlogin
626 @cindex krlogin method
627 @cindex Kerberos (with krlogin method)
628
629 This method is also similar to @option{ssh}. It uses the
630 @command{krlogin -x} command only for remote host login.
631
632 @item @option{ksu}
633 @cindex method ksu
634 @cindex ksu method
635 @cindex Kerberos (with ksu method)
636
637 This is another method from the Kerberos suite. It behaves like @option{su}.
638
639 @item @option{plink}
640 @cindex method plink
641 @cindex plink method
642
643 @option{plink} method is for Windows users with the PuTTY
644 implementation of SSH@. It uses @samp{plink -ssh} to log in to the
645 remote host.
646
647 Check the @samp{Share SSH connections if possible} control for that
648 session.
649
650 @option{plink} method supports the @samp{-P} argument.
651
652 @item @option{plinkx}
653 @cindex method plinkx
654 @cindex plinkx method
655
656 Another method using PuTTY on Windows with session names instead of
657 host names. @option{plinkx} calls @samp{plink -load @var{session} -t}.
658 User names and port numbers must be defined in the session.
659
660 Check the @samp{Share SSH connections if possible} control for that
661 session.
662
663 @end table
664
665
666 @node External methods
667 @section External methods
668 @cindex methods, external
669 @cindex external methods
670
671 External methods operate over multiple channels, using the remote
672 shell connection for some actions while delegating file transfers to
673 an external transfer program.
674
675 External methods save on the overhead of encoding and decoding of
676 inline methods.
677
678 Since external methods have the overhead of opening a new channel,
679 files smaller than @var{tramp-copy-size-limit} still use inline
680 methods.
681
682 @table @asis
683 @item @option{rcp}---@command{rsh} and @command{rcp}
684 @cindex method rcp
685 @cindex rcp method
686 @cindex rcp (with rcp method)
687 @cindex rsh (with rcp method)
688
689 This method uses the @command{rsh} and @command{rcp} commands to
690 connect to the remote host and transfer files. This is the fastest
691 access method available.
692
693 The alternative method @option{remcp} uses the @command{remsh} and
694 @command{rcp} commands.
695
696 @item @option{scp}---@command{ssh} and @command{scp}
697 @cindex method scp
698 @cindex scp method
699 @cindex scp (with scp method)
700 @cindex ssh (with scp method)
701
702 Using a combination of @command{ssh} to connect and @command{scp} to
703 transfer is the most secure. While the performance is good, it is
704 slower than the inline methods for smaller files. Though there is no
705 overhead of encoding and decoding of the inline methods,
706 @command{scp}'s cryptographic handshake negates those speed gains.
707
708 @option{ssh}-based methods support @samp{-p} feature for specifying
709 port numbers. For example, @file{host#42} passes @samp{-p 42} in the
710 argument list to @command{ssh}, and @samp{-P 42} in the argument list
711 to @command{scp}.
712
713 @item @option{rsync}---@command{ssh} and @command{rsync}
714 @cindex method rsync
715 @cindex rsync method
716 @cindex rsync (with rsync method)
717 @cindex ssh (with rsync method)
718
719 @command{ssh} command to connect in combination with @command{rsync}
720 command to transfer is similar to the @option{scp} method.
721
722 @command{rsync} performs much better than @command{scp} when
723 transferring files that exist on both hosts. However, this advantage
724 is lost if the file exists only on one side of the connection.
725
726 This method supports the @samp{-p} argument.
727
728 @item @option{scpx}---@command{ssh} and @command{scp}
729 @cindex method scpx
730 @cindex scpx method
731 @cindex scp (with scpx method)
732 @cindex ssh (with scpx method)
733
734 @option{scpx} is useful to avoid login shell questions. It is similar
735 in performance to @option{scp}. @option{scpx} uses @samp{ssh -t -t
736 @var{host} -l @var{user} /bin/sh} to open a connection.
737
738 @option{sshx} is useful for Windows users when @command{ssh} triggers
739 an error about allocating a pseudo tty. This happens due to missing
740 shell prompts that confuses @value{tramp}.
741
742 This method supports the @samp{-p} argument.
743
744 @item @option{pscp}---@command{plink} and @command{pscp}
745 @item @option{psftp}---@command{plink} and @command{psftp}
746 @cindex method pscp
747 @cindex pscp method
748 @cindex pscp (with pscp method)
749 @cindex plink (with pscp method)
750 @cindex PuTTY (with pscp method)
751 @cindex method psftp
752 @cindex psftp method
753 @cindex pscp (with psftp method)
754 @cindex plink (with psftp method)
755 @cindex PuTTY (with psftp method)
756
757 These methods are similar to @option{scp} or @option{sftp}, but they
758 use the @command{plink} command to connect to the remote host, and
759 they use @command{pscp} or @command{psftp} for transferring the files.
760 These programs are part of PuTTY, an SSH implementation for Windows.
761
762 Check the @samp{Share SSH connections if possible} control for that
763 session.
764
765 These methods support the @samp{-P} argument.
766
767 @item @option{fcp}---@command{fsh} and @command{fcp}
768 @cindex method fcp
769 @cindex fcp method
770 @cindex fsh (with fcp method)
771 @cindex fcp (with fcp method)
772
773 This method is similar to @option{scp}, but uses @command{fsh} to
774 connect and @command{fcp} to transfer files. @command{fsh/fcp}, a
775 front-end for @command{ssh}, reuse @command{ssh} session by
776 submitting several commands. This avoids the startup overhead due to
777 @command{scp}'s secure connection. Inline methods have similar
778 benefits.
779
780 The command used for this connection is: @samp{fsh @var{host} -l
781 @var{user} /bin/sh -i}
782
783 @cindex method fsh
784 @cindex fsh method
785
786 @option{fsh} has no inline method since the multiplexing it offers is
787 not useful for @value{tramp}. @command{fsh} connects to remote host
788 and @value{tramp} keeps that one connection open.
789
790 @item @option{nc}---@command{telnet} and @command{nc}
791 @cindex method nc
792 @cindex nc method
793 @cindex nc (with nc method)
794 @cindex telnet (with nc method)
795
796 Using @command{telnet} to connect and @command{nc} to transfer files
797 is sometimes the only combination suitable for accessing routers or
798 NAS hosts. These dumb devices have severely restricted local shells,
799 such as the @command{busybox} and do not host any other encode or
800 decode programs.
801
802 @item @option{ftp}
803 @cindex method ftp
804 @cindex ftp method
805
806 When @value{tramp} uses @option{ftp}, it forwards requests to whatever
807 ftp program is specified by Ange FTP. This external program must be
808 capable of servicing requests from @value{tramp}.
809
810 @item @option{smb}---@command{smbclient}
811 @cindex method smb
812 @cindex smb method
813
814 This non-native @value{tramp} method connects via the Server Message
815 Block (SMB) networking protocol to hosts running file servers that are
816 typically based on @url{https://www.samba.org/,,Samba} or MS Windows.
817
818 Using @command{smbclient} requires a few tweaks when working with
819 @value{tramp}:
820
821 The first directory in the localname must be a share name on the
822 remote host.
823
824 Since SMB shares end in the @code{$} character, @value{tramp} must use
825 @code{$$} when specifying those shares to avoid environment variable
826 substitutions.
827
828 When @value{tramp} is not specific about the share name or uses the
829 generic remote directory @code{/}, @command{smbclient} returns all
830 available shares.
831
832 Since SMB authentication is based on each SMB share, @value{tramp}
833 prompts for a password even when accessing a different share on the
834 same SMB host. This prompting can be suppressed by @ref{Password
835 handling}.
836
837 To accommodate user name/domain name syntax required by MS Windows
838 authorization, @value{tramp} provides for an extended syntax in
839 @code{user%domain} format (where user is username, @code{%} is the
840 percent symbol, and domain is the windows domain name). An example:
841
842 @example
843 @trampfn{smb,daniel%BIZARRE@@melancholia,/daniel$$/.emacs}
844 @end example
845
846 where user @code{daniel} connects as a domain user to the SMB host
847 @code{melancholia} in the windows domain @code{BIZARRE} to edit
848 @file{.emacs} located in the home directory (share @code{daniel$}).
849
850 Alternatively, for local WINS users (as opposed to domain users),
851 substitute the domain name with the name of the local host in
852 UPPERCASE as shown here:
853
854 @example
855 @trampfn{smb,daniel%MELANCHOLIA@@melancholia,/daniel$$/.emacs}
856 @end example
857
858 where user @code{daniel} connects as local user to the SMB host
859 @code{melancholia} in the local domain @code{MELANCHOLIA} to edit
860 @file{.emacs} located in the home directory (share @code{daniel$}).
861
862 The domain name and user name are optional for @command{smbclient}
863 authentication. When user name is not specified, @command{smbclient}
864 uses the anonymous user (without prompting for password). This
865 behavior is unlike other @value{tramp} methods, where local user name
866 is substituted.
867
868 The @option{smb} method is unavailable if Emacs is run under a local
869 user authentication context in MS Windows. However such users can
870 still access remote files using UNC file names instead of @value{tramp}:
871
872 @example
873 //melancholia/daniel$$/.emacs
874 @end example
875
876 UNC file name specification does not allow the specification of a
877 different user name for authentication like the @command{smbclient}
878 can.
879
880
881 @item @option{adb}
882 @cindex method adb
883 @cindex adb method
884
885 This method uses Android Debug Bridge program for accessing Android
886 devices. The Android Debug Bridge must be installed locally for
887 @value{tramp} to work. Some GNU/Linux distributions provide Android
888 Debug Bridge as an installation package. Alternatively, the program is
889 installed as part of the Android SDK@. @value{tramp} finds the
890 @command{adb} program either via the @env{PATH} environment variable
891 or the absolute path set in the variable @var{tramp-adb-program}.
892
893 @value{tramp} connects to Android devices with @option{adb} only when
894 the custom option @option{tramp-adb-connect-if-not-connected} is not
895 @code{nil}. Otherwise, the connection must be established outside
896 Emacs.
897
898 @value{tramp} does not require a host name part of the remote file
899 name when a single Android device is connected to @command{adb}.
900 @value{tramp} instead uses @file{@trampfn{adb,,}} as the default name.
901 @command{adb devices} shows available host names.
902
903 @option{adb} method normally does not need user name to authenticate
904 on the Android device because it runs under the @command{adbd}
905 process. But when a user name is specified, however, @value{tramp}
906 applies an @command{su} in the syntax. When authentication does not
907 succeed, especially on un-rooted Android devices, @value{tramp}
908 displays login errors.
909
910 For Android devices connected through TCP/IP, a port number can be
911 specified using @file{device#42} host name syntax or @value{tramp} can
912 use the default value as declared in @command{adb} command. Port
913 numbers are not applicable to Android devices connected through USB@.
914
915 @end table
916
917
918 @node GVFS based methods
919 @section GVFS based external methods
920 @cindex methods, gvfs
921 @cindex gvfs based methods
922 @cindex dbus
923
924 GVFS is the virtual file system for the Gnome Desktop,
925 @uref{http://en.wikipedia.org/wiki/GVFS}. Remote files on GVFS are
926 mounted locally through FUSE and @value{tramp} uses this locally
927 mounted directory internally.
928
929 Emacs uses the D-Bus mechanism to communicate with GVFS@. Emacs must
930 have the message bus system, D-Bus integration active, @pxref{Top, ,
931 D-Bus, dbus}.
932
933 @table @asis
934 @item @option{afp}
935 @cindex method afp
936 @cindex afp method
937
938 This method is for connecting to remote hosts with the Apple Filing
939 Protocol for accessing files on Mac OS X volumes. @value{tramp} access
940 syntax requires a leading volume (share) name, for example:
941 @file{@trampfn{afp,user@@host,/volume}}.
942
943 @item @option{dav}
944 @item @option{davs}
945 @cindex method dav
946 @cindex method davs
947 @cindex dav method
948 @cindex davs method
949
950 @option{dav} method provides access to WebDAV files and directories
951 based on standard protocols, such as HTTP@. @option{davs} does the same
952 but with SSL encryption. Both methods support the port numbers.
953
954 @item @option{obex}
955 @cindex method obex
956 @cindex obex method
957
958 OBEX is an FTP-like access protocol for cell phones and similar simple
959 devices. @value{tramp} supports OBEX over Bluetooth.
960
961 @item @option{sftp}
962 @cindex method sftp
963 @cindex sftp method
964
965 This method uses @command{sftp} in order to securely access remote
966 hosts. @command{sftp} is a more secure option for connecting to hosts
967 that for security reasons refuse @command{ssh} connections.
968
969 @item @option{synce}
970 @cindex method synce
971 @cindex synce method
972
973 @option{synce} method allows connecting to Windows Mobile devices. It
974 uses GVFS for mounting remote files and directories via FUSE and
975 requires the SYNCE-GVFS plugin.
976
977 @end table
978
979 @defopt tramp-gvfs-methods
980 @vindex tramp-gvfs-methods
981 This custom option is a list of external methods for GVFS@. By
982 default, this list includes @option{afp}, @option{dav}, @option{davs},
983 @option{obex}, @option{sftp} and @option{synce}. Other methods to
984 include are: @option{ftp} and @option{smb}.
985 @end defopt
986
987
988 @node Gateway methods
989 @section Gateway methods
990 @cindex methods, gateway
991 @cindex gateway methods
992
993 Gateway methods are for proxy host declarations (@pxref{Multi-hops})
994 so as to pass through firewalls and proxy servers. They are not like
995 the other methods that declare direct connections to a remote host.
996
997 A gateway method always comes with a port setting. @value{tramp}
998 targets the port number with the gateway method
999 @file{localhost#random_port} from where the firewall or proxy server
1000 is accessed.
1001
1002 Gateway methods support user name and password declarations for
1003 authenticating the corresponding firewall or proxy server. Such
1004 authentication can be passed through only if granted access by system
1005 administrators.
1006
1007 @table @asis
1008 @item @option{tunnel}
1009 @cindex method tunnel
1010 @cindex tunnel method
1011
1012 This method implements an HTTP tunnel via the @command{CONNECT}
1013 command (conforming to RFC 2616, 2817 specifications). Proxy servers
1014 using HTTP version 1.1 or later protocol support this command.
1015
1016 For authentication, this protocol uses only @option{Basic
1017 Authentication} (see RFC 2617). When no port number is specified, this
1018 protocol defaults to @option{8080}.
1019
1020 @item @option{socks}
1021 @cindex method socks
1022 @cindex socks method
1023
1024 The @option{socks} method connects to SOCKSv5 servers (see RFC 1928)
1025 and supports @option{Username/Password Authentication}.
1026
1027 The default port number for the socks server is @option{1080}, if not
1028 specified otherwise.
1029
1030 @end table
1031
1032
1033 @node Default Method
1034 @section Selecting a default method
1035 @cindex default method
1036 @vindex tramp-default-method
1037 @vindex tramp-default-method-alist
1038
1039 Default method is for transferring files. The variable
1040 @code{tramp-default-method} sets it. @value{tramp} uses this variable
1041 to determine the default method for tramp file names that do not have
1042 one specified.
1043
1044 @lisp
1045 (setq tramp-default-method "ssh")
1046 @end lisp
1047
1048 Default methods for transferring files can be customized for specific
1049 user and host combinations through the alist variable
1050 @code{tramp-default-method-alist}.
1051
1052 For example, the following two lines specify to use the @option{ssh}
1053 method for all user names matching @samp{john} and the @option{rsync}
1054 method for all host names matching @samp{lily}. The third line
1055 specifies to use the @option{su} method for the user @samp{root} on
1056 the host @samp{localhost}.
1057
1058 @lisp
1059 (add-to-list 'tramp-default-method-alist '("" "john" "ssh"))
1060 (add-to-list 'tramp-default-method-alist '("lily" "" "rsync"))
1061 (add-to-list 'tramp-default-method-alist
1062 '("\\`localhost\\'" "\\`root\\'" "su"))
1063 @end lisp
1064
1065 @noindent
1066 See the documentation for the variable
1067 @code{tramp-default-method-alist} for details.
1068
1069 @noindent
1070 External methods performance faster for large files.
1071
1072 @noindent
1073 @xref{Inline methods}.
1074 @xref{External methods}.
1075
1076 Choosing the access method also depends on the security environment.
1077 For example, @option{rsh} and @option{telnet} methods that use clear
1078 text password transfers are inappropriate for over the Internet
1079 connections. Secure remote connections should use @option{ssh} that
1080 provide encryption.
1081
1082
1083 @subsection Which method to use?
1084 @cindex choosing the right method
1085
1086 @value{tramp} provides maximum number of choices for maximum
1087 flexibility. Choosing which method depends on the hosts, clients,
1088 network speeds, and the security context.
1089
1090 Start by using an inline method.
1091
1092 External methods might be more efficient for large files, but most
1093 @value{tramp} users edit small files more often than large files.
1094
1095 Enable compression, @var{tramp-inline-compress-start-size}, for a
1096 performance boost for large files.
1097
1098 Since @command{ssh} has become the most common method of remote host
1099 access and it has the most reasonable security protocols, use
1100 @option{ssh} method. Typical @option{ssh} usage to edit the
1101 @file{/etc/motd} file on the otherhost:
1102
1103 @example
1104 @kbd{C-x C-f @trampfn{ssh,root@@otherhost,/etc/motd} @key{RET}}
1105 @end example
1106
1107 If @option{ssh} is unavailable for whatever reason, look for other
1108 obvious options. For Windows, try the @option{plink} method. For
1109 Kerberos, try @option{krlogin}.
1110
1111 For editing local files as @option{su} or @option{sudo} methods, try
1112 the shortened syntax of @samp{root}:
1113
1114 @example
1115 @kbd{C-x C-f @trampfn{su,,/etc/motd} @key{RET}}
1116 @end example
1117
1118 For editing large files, @option{scp} is faster than @option{ssh}.
1119 @option{pscp} is faster than @option{plink}. But this speed
1120 improvement is not always true.
1121
1122
1123 @node Default User
1124 @section Selecting a default user
1125 @cindex default user
1126 @vindex tramp-default-user
1127 @vindex tramp-default-user-alist
1128
1129 @value{tramp} file name can omit the user name part since
1130 @value{tramp} substitutes the currently logged-in user name. However
1131 this substitution can be overridden with @code{tramp-default-user}.
1132 For example:
1133
1134 @lisp
1135 (setq tramp-default-user "root")
1136 @end lisp
1137
1138 Instead of a single default user, @code{tramp-default-user-alist}
1139 allows multiple default user values based on access method or host
1140 name combinations. The alist can hold multiple values. For example, to
1141 use the @samp{john} as the default user for the domain
1142 @samp{somewhere.else} only:
1143
1144 @lisp
1145 (add-to-list 'tramp-default-user-alist
1146 '("ssh" ".*\\.somewhere\\.else\\'" "john"))
1147 @end lisp
1148
1149 @noindent
1150 See the documentation for the variable @code{tramp-default-user-alist}
1151 for more details.
1152
1153 A Caution: @value{tramp} will override any default user specified in
1154 the configuration files outside Emacs, such as @file{~/.ssh/config}.
1155 To stop @value{tramp} from applying the default value, set the
1156 corresponding alist entry to nil:
1157
1158 @lisp
1159 (add-to-list 'tramp-default-user-alist
1160 '("ssh" "\\`here\\.somewhere\\.else\\'" nil))
1161 @end lisp
1162
1163 The last entry in @code{tramp-default-user-alist} should be reserved
1164 for catch-all or most often used login.
1165
1166 @lisp
1167 (add-to-list 'tramp-default-user-alist
1168 '(nil nil "jonas") t)
1169 @end lisp
1170
1171
1172 @node Default Host
1173 @section Selecting a default host
1174 @cindex default host
1175 @vindex tramp-default-host
1176 @vindex tramp-default-host-alist
1177
1178 When host name is omitted, @value{tramp} substitutes the value from
1179 the @code{tramp-default-host} variable. It is initially populated
1180 with the local hostname where Emacs is running. Both the default user
1181 and default host can be overridden as follows:
1182
1183 @lisp
1184 (setq tramp-default-user "john"
1185 tramp-default-host "target")
1186 @end lisp
1187
1188 With both defaults set, @samp{@trampfn{ssh,,}} will connect
1189 @value{tramp} to John's home directory on target.
1190
1191 @strong{Note} @samp{/::} won't work, because @samp{/:} is the prefix
1192 for quoted file names.
1193
1194 Instead of a single default host, @code{tramp-default-host-alist}
1195 allows multiple default host values based on access method or user
1196 name combinations. The alist can hold multiple values. While
1197 @code{tramp-default-host} is sufficient in most cases, some methods,
1198 like @option{adb}, require defaults overwritten.
1199
1200 @noindent
1201 See the documentation for the variable @code{tramp-default-host-alist}
1202 for more details.
1203
1204
1205 @node Multi-hops
1206 @section Connecting to a remote host using multiple hops
1207 @cindex multi-hop
1208 @cindex proxy hosts
1209
1210 Multi-hops are methods to reach hosts behind firewalls or to reach the
1211 outside world from inside a bastion host. With multi-hops,
1212 @value{tramp} can negotiate these hops with the appropriate user/host
1213 authentication at each hop. All methods until now have been the single
1214 hop kind, where the start and end points of the connection did not
1215 have intermediate check points.
1216
1217 @defopt tramp-default-proxies-alist
1218 @vindex tramp-default-proxies-alist
1219 @option{tramp-default-proxies-alist} specifies proxy hosts to pass
1220 through. This variable is list of triples consisting of (@var{host}
1221 @var{user} @var{proxy}).
1222
1223 The first match is the proxy host through which passes the file name
1224 and the target host matching @var{user}@@@var{host}. @var{host} and
1225 @var{user} are regular expressions or @code{nil}, interpreted as a
1226 regular expression which always matches.
1227
1228 @var{proxy} is a literal @value{tramp} file name whose local name part
1229 is ignored, and the method and user name parts are optional.
1230
1231 The method must be an inline or gateway method (@pxref{Inline
1232 methods}, @pxref{Gateway methods}).
1233 If @var{proxy} is @code{nil}, no additional hop is required reaching
1234 @var{user}@@@var{host}.
1235
1236 For example, to pass through the host @samp{bastion.your.domain} as
1237 user @samp{bird} to reach remote hosts outside the local domain:
1238
1239 @lisp
1240 (add-to-list 'tramp-default-proxies-alist
1241 '("\\." nil "@trampfn{ssh,bird@@bastion.your.domain,}"))
1242 (add-to-list 'tramp-default-proxies-alist
1243 '("\\.your\\.domain\\'" nil nil))
1244 @end lisp
1245
1246 @strong{Note}: @code{add-to-list} adds elements at the beginning of a
1247 list. Therefore, most relevant rules must come last in the list.
1248
1249 Proxy hosts can be cascaded in the alist. If there is another host
1250 called @samp{jump.your.domain}, which is the only host allowed to
1251 connect to @samp{bastion.your.domain}, then:
1252
1253 @lisp
1254 (add-to-list 'tramp-default-proxies-alist
1255 '("\\`bastion\\.your\\.domain\\'"
1256 "\\`bird\\'"
1257 "@trampfn{ssh,jump.your.domain,}"))
1258 @end lisp
1259
1260 @var{proxy} can take patterns @code{%h} or @code{%u} for @var{host} or
1261 @var{user} respectively.
1262
1263 To login as @samp{root} on remote hosts in the domain
1264 @samp{your.domain}, but login as @samp{root} is disabled for non-local
1265 access, then use this alist entry:
1266
1267 @lisp
1268 (add-to-list 'tramp-default-proxies-alist
1269 '("\\.your\\.domain\\'" "\\`root\\'" "@trampfn{ssh,%h,}"))
1270 @end lisp
1271
1272 Opening @file{@trampfn{sudo,randomhost.your.domain,}} first connects
1273 to @samp{randomhost.your.domain} via @code{ssh} under your account
1274 name, and then perform @code{sudo -u root} on that host.
1275
1276 It is key for the sudo method in the above example to be applied on
1277 the host after reaching it and not on the local host.
1278
1279 @var{host}, @var{user} and @var{proxy} can also take Lisp forms. These
1280 forms when evaluated must return either a string or @code{nil}.
1281
1282 To generalize (from the previous example): For all hosts, except my
1283 local one, first connect via @command{ssh}, and then apply
1284 @command{sudo -u root}:
1285
1286 @lisp
1287 (add-to-list 'tramp-default-proxies-alist
1288 '(nil "\\`root\\'" "@trampfn{ssh,%h,}"))
1289 (add-to-list 'tramp-default-proxies-alist
1290 '((regexp-quote (system-name)) nil nil))
1291 @end lisp
1292
1293 The above configuration allows @value{tramp} connection as @samp{root}
1294 to remote Ubuntu hosts.
1295
1296 @code{tramp-default-proxies-alist} is also used for passing through
1297 firewalls or proxy servers.
1298
1299 For example, the local host @samp{proxy.your.domain} on port 3128
1300 serves as HTTP proxy to the outer world. User has access rights to
1301 another proxy server on @samp{host.other.domain}.@footnote{HTTP tunnels
1302 are intended for secure SSL/TLS communication. Therefore, many proxy
1303 servers restrict the tunnels to related target ports. You might need
1304 to run your ssh server on your target host @samp{host.other.domain} on
1305 such a port, like 443 (https). See
1306 @uref{http://savannah.gnu.org/maintenance/CvsFromBehindFirewall} for
1307 discussion of ethical issues.} Then the configuration is:
1308
1309 @lisp
1310 (add-to-list 'tramp-default-proxies-alist
1311 '("\\`host\\.other\\.domain\\'" nil
1312 "@trampfn{tunnel,proxy.your.domain#3128,}"))
1313 @end lisp
1314
1315 Gateway methods in a multiple hop chain can be declared only as the first hop.
1316 @end defopt
1317
1318 Passing through hops involves dealing with restricted shells, such as
1319 @command{rbash}. If @value{tramp} is made aware, then it would use
1320 them for proxies only.
1321
1322 @defopt tramp-restricted-shell-hosts-alist
1323 @vindex tramp-restricted-shell-hosts-alist
1324 An alist of regular expressions of hosts running restricted shells,
1325 such as @command{rbash}. @value{tramp} will then use them only as
1326 proxies.
1327
1328 To specify the bastion host from the example above as running a
1329 restricted shell:
1330
1331 @lisp
1332 (add-to-list 'tramp-restricted-shell-hosts-alist
1333 "\\`bastion\\.your\\.domain\\'")
1334 @end lisp
1335 @end defopt
1336
1337
1338 @node Customizing Methods
1339 @section Using Non-Standard Methods
1340 @cindex customizing methods
1341 @cindex using non-standard methods
1342 @cindex create your own methods
1343
1344 The @code{tramp-methods} variable currently has an exhaustive list of
1345 predefined methods. Any part of this list can be modified with more
1346 suitable settings. Refer to the Lisp documentation of that variable,
1347 accessible with @kbd{C-h v tramp-methods @key{RET}}.
1348
1349
1350 @node Customizing Completion
1351 @section Selecting config files for user/host name completion
1352 @cindex customizing completion
1353 @cindex selecting config files
1354 @vindex tramp-completion-function-alist
1355
1356 @code{tramp-completion-function-alist} uses predefined files for user
1357 and host name completion (@pxref{File name completion}). For each
1358 method, it keeps a set of configuration files and a function that can
1359 parse that file. Each entry in @code{tramp-completion-function-alist}
1360 is of the form (@var{method} @var{pair1} @var{pair2} @dots{}).
1361
1362 Each @var{pair} is composed of (@var{function} @var{file}).
1363 @var{function} is responsible for extracting user names and host names
1364 from @var{file} for completion. There are two functions which access
1365 this variable:
1366
1367 @defun tramp-get-completion-function method
1368 This function returns the list of completion functions for @var{method}.
1369
1370 Example:
1371 @example
1372 (tramp-get-completion-function "rsh")
1373
1374 @result{} ((tramp-parse-rhosts "/etc/hosts.equiv")
1375 (tramp-parse-rhosts "~/.rhosts"))
1376 @end example
1377 @end defun
1378
1379 @defun tramp-set-completion-function method function-list
1380 This function sets @var{function-list} as list of completion functions
1381 for @var{method}.
1382
1383 Example:
1384 @example
1385 (tramp-set-completion-function "ssh"
1386 '((tramp-parse-sconfig "/etc/ssh_config")
1387 (tramp-parse-sconfig "~/.ssh/config")))
1388
1389 @result{} ((tramp-parse-sconfig "/etc/ssh_config")
1390 (tramp-parse-sconfig "~/.ssh/config"))
1391 @end example
1392 @end defun
1393
1394 The following predefined functions parsing configuration files exist:
1395
1396 @table @asis
1397 @item @code{tramp-parse-rhosts}
1398 @findex tramp-parse-rhosts
1399
1400 This function parses files which are syntactical equivalent to
1401 @file{~/.rhosts}. It returns both host names and user names, if
1402 specified.
1403
1404 @item @code{tramp-parse-shosts}
1405 @findex tramp-parse-shosts
1406
1407 This function parses files which are syntactical equivalent to
1408 @file{~/.ssh/known_hosts}. Since there are no user names specified
1409 in such files, it can return host names only.
1410
1411 @item @code{tramp-parse-sconfig}
1412 @findex tramp-parse-shosts
1413
1414 This function returns the host nicknames defined by @code{Host} entries
1415 in @file{~/.ssh/config} style files.
1416
1417 @item @code{tramp-parse-shostkeys}
1418 @findex tramp-parse-shostkeys
1419
1420 SSH2 parsing of directories @file{/etc/ssh2/hostkeys/*} and
1421 @file{~/ssh2/hostkeys/*}. Hosts are coded in file names
1422 @file{hostkey_@var{portnumber}_@var{host-name}.pub}. User names
1423 are always @code{nil}.
1424
1425 @item @code{tramp-parse-sknownhosts}
1426 @findex tramp-parse-shostkeys
1427
1428 Another SSH2 style parsing of directories like
1429 @file{/etc/ssh2/knownhosts/*} and @file{~/ssh2/knownhosts/*}. This
1430 case, hosts names are coded in file names
1431 @file{@var{host-name}.@var{algorithm}.pub}. User names are always @code{nil}.
1432
1433 @item @code{tramp-parse-hosts}
1434 @findex tramp-parse-hosts
1435
1436 A function dedicated to @file{/etc/hosts} for host names.
1437
1438 @item @code{tramp-parse-passwd}
1439 @findex tramp-parse-passwd
1440
1441 A function which parses @file{/etc/passwd} files for user names.
1442
1443 @item @code{tramp-parse-etc-group}
1444 @findex tramp-parse-etc-group
1445
1446 A function which parses @file{/etc/group} files for group names.
1447
1448 @item @code{tramp-parse-netrc}
1449 @findex tramp-parse-netrc
1450
1451 A function which parses @file{~/.netrc} and @file{~/.authinfo}-style files.
1452
1453 @end table
1454
1455 To keep a custom file with custom data in a custom structure, a custom
1456 function has to be provided. This function must meet the following
1457 conventions:
1458
1459 @defun my-tramp-parse file
1460 @var{file} must be either a file on the host, or @code{nil}. The
1461 function must return a list of (@var{user} @var{host}), which are
1462 taken as candidates for completion for user and host names.
1463
1464 Example:
1465 @example
1466 (my-tramp-parse "~/.my-tramp-hosts")
1467
1468 @result{} ((nil "toto") ("daniel" "melancholia"))
1469 @end example
1470 @end defun
1471
1472
1473 @node Password handling
1474 @section Reusing passwords for several connections
1475 @cindex passwords
1476
1477 To avoid repeated prompts for passwords, consider native caching
1478 mechanisms, such as @command{ssh-agent} for @option{ssh}-like
1479 methods, or @command{pageant} for @option{plink}-like methods.
1480
1481 @value{tramp} offers alternatives when native solutions cannot meet
1482 the need.
1483
1484
1485 @anchor{Using an authentication file}
1486 @subsection Using an authentication file
1487 @vindex auth-sources
1488
1489 The package @file{auth-source.el}, originally developed for No Gnus,
1490 reads passwords from different sources, @xref{Help for users, ,
1491 auth-source, auth}. The default authentication file is
1492 @file{~/.authinfo.gpg}, but this can be changed via the variable
1493 @code{auth-sources}.
1494
1495 @noindent
1496 A typical entry in the authentication file:
1497
1498 @example
1499 machine melancholia port scp login daniel password geheim
1500 @end example
1501
1502 The port can take any @value{tramp} method (@pxref{Inline methods},
1503 @pxref{External methods}). Omitting port values matches all
1504 @value{tramp} methods.
1505
1506 Setting @code{auth-source-debug} to @code{t} to debug messages.
1507
1508
1509 @anchor{Caching passwords}
1510 @subsection Caching passwords
1511
1512 @value{tramp} can cache passwords as entered and reuse when needed for
1513 the same user or host name independent of the access method.
1514
1515 @vindex password-cache-expiry
1516
1517 @code{password-cache-expiry} sets the duration (in seconds) the
1518 passwords are remembered. Passwords are never saved permanently nor
1519 can they extend beyond the lifetime of the current Emacs session. Set
1520 @code{password-cache-expiry} to @code{nil} to disable expiration.
1521
1522 @vindex password-cache
1523
1524 Set @code{password-cache} to @code{nil} to disable password caching.
1525
1526 @strong{Implementation Note}: password caching depends on
1527 @file{password-cache.el} package. @value{tramp} activates password
1528 caching only if @value{tramp} can discover, while Emacs is loading,
1529 the package through @code{load-path}.
1530
1531 @ifset installchapter
1532 @file{password.el} is available from No Gnus or from the @value{tramp}
1533 @file{contrib} directory, see @ref{Installation parameters}.
1534 @end ifset
1535
1536
1537 @node Connection caching
1538 @section Reusing connection related information
1539 @cindex caching
1540 @vindex tramp-persistency-file-name
1541
1542 For faster initial connection times, @value{tramp} stores previous
1543 connection properties in a file specified by the variable
1544 @code{tramp-persistency-file-name}.
1545
1546 The default file name for @code{tramp-persistency-file-name} is
1547 @file{~/.emacs.d/tramp}.
1548
1549 @value{tramp} reads this file during Emacs startup, and writes to it
1550 when exiting Emacs. Delete this file for @value{tramp} to recreate a
1551 new one on next Emacs startup.
1552
1553 Set @code{tramp-persistency-file-name} to @code{nil} to disable
1554 storing connections persistently.
1555
1556 To reuse connection information from the persistent list,
1557 @value{tramp} needs to uniquely identify every host. However in some
1558 cases, two different connections may result in the same persistent
1559 information. For example, connecting to a host using @command{ssh} and
1560 connecting to the same host through @code{sshd} on port 3001. Both
1561 access methods result in nearly identical persistent specifications
1562 @file{@trampfn{ssh,localhost,}} and @file{@trampfn{ssh,localhost#3001,}}.
1563
1564 Changing host names could avoid duplicates. One way is to add a
1565 @option{Host} section in @file{~/.ssh/config} (@pxref{Frequently Asked
1566 Questions}). Another way is to apply multiple hops (@pxref{Multi-hops}).
1567
1568 When @value{tramp} detects a change in the operating system version in
1569 a remote host (via the command @command{uname -sr}), it flushes all
1570 connection related information for that host and creates a new entry.
1571
1572
1573 @node Predefined connection information
1574 @section Setting own connection related information
1575 @vindex tramp-connection-properties
1576
1577 For more precise customization, parameters specified by
1578 @code{tramp-methods} can be overwritten manually.
1579
1580 Set @code{tramp-connection-properties} to manually override
1581 @code{tramp-methods}. Properties in this list are in the form
1582 @code{(@var{regexp} @var{property} @var{value})}. @var{regexp} matches
1583 remote file names. Use @code{nil} to match all. @var{property} is the
1584 property's name, and @var{value} is the property's value.
1585
1586 @var{property} is any method specific parameter contained in
1587 @code{tramp-methods}. The parameter key in @code{tramp-methods} is a
1588 symbol name @code{tramp-<foo>}. To overwrite that property, use the
1589 string @samp{<foo>} for @var{property}. For example, this changes the
1590 remote shell:
1591
1592 @lisp
1593 (add-to-list 'tramp-connection-properties
1594 (list (regexp-quote "@trampfn{ssh,user@@randomhost.your.domain,}")
1595 "remote-shell" "/bin/ksh"))
1596 (add-to-list 'tramp-connection-properties
1597 (list (regexp-quote "@trampfn{ssh,user@@randomhost.your.domain,}")
1598 "remote-shell-login" '("-")))
1599 @end lisp
1600
1601 The parameters @code{tramp-remote-shell} and
1602 @code{tramp-remote-shell-login} in @code{tramp-methods} now have new
1603 values for the remote host.
1604
1605 @var{property} could also be any property found in
1606 @code{tramp-persistency-file-name}.
1607
1608 To get around how restricted shells randomly drop connections, set the
1609 special property @samp{busybox}. For example:
1610
1611 @lisp
1612 (add-to-list 'tramp-connection-properties
1613 (list (regexp-quote "@trampfn{ssh,user@@randomhost.your.domain,}")
1614 "busybox" t))
1615 @end lisp
1616
1617
1618 @node Remote programs
1619 @section How @value{tramp} finds and uses programs on the remote host
1620
1621 @value{tramp} requires access to and rights to several commands on
1622 remote hosts: @command{ls}, @command{test}, @command{find} and
1623 @command{cat}.
1624
1625 Besides there are other required programs for @ref{Inline methods} and
1626 @ref{External methods} of connection.
1627
1628 To improve performance and accuracy of remote file access,
1629 @value{tramp} uses @command{perl} (or @command{perl5}) and
1630 @command{grep} when available.
1631
1632 @defopt tramp-remote-path
1633 @vindex tramp-remote-path
1634 @vindex tramp-default-remote-path
1635 @vindex tramp-own-remote-path
1636 @option{tramp-remote-path} specifies which remote directory paths
1637 @value{tramp} can search for @ref{Remote programs}.
1638
1639 @value{tramp} uses standard defaults, such as @file{/bin} and
1640 @file{/usr/bin}, which are reasonable for most hosts. To accommodate
1641 differences in hosts and paths, for example, @file{/bin:/usr/bin} on
1642 Debian GNU/Linux or
1643 @file{/usr/xpg4/bin:/usr/ccs/bin:/usr/bin:/opt/SUNWspro/bin} on
1644 Solaris, @value{tramp} queries the remote host with @command{getconf
1645 PATH} and updates the symbol @code{tramp-default-remote-path}.
1646
1647 For instances where hosts keep obscure locations for paths for
1648 security reasons, manually add such paths to local @file{.emacs} as
1649 shown below for @value{tramp} to use when connecting.
1650
1651 @lisp
1652 (add-to-list 'tramp-remote-path "/usr/local/perl/bin")
1653 @end lisp
1654
1655 Another way to find the remote path is to use the path assigned to the
1656 remote user by the remote host. @value{tramp} does not normally retain
1657 this remote path after logging. However, @code{tramp-own-remote-path}
1658 preserves the path value, which can be used to update
1659 @code{tramp-remote-path}.
1660
1661 @lisp
1662 (add-to-list 'tramp-remote-path 'tramp-own-remote-path)
1663 @end lisp
1664 @end defopt
1665
1666 When remote search paths are changed, local @value{tramp} caches must
1667 be recomputed. To force @value{tramp} to recompute afresh, exit
1668 Emacs, remove the persistent file (@pxref{Connection caching}), and
1669 restart Emacs.
1670
1671
1672 @node Remote shell setup
1673 @section Remote shell setup hints
1674 @cindex remote shell setup
1675 @cindex @file{.profile} file
1676 @cindex @file{.login} file
1677 @cindex shell init files
1678
1679 @value{tramp} checks for the availability of standard programs in the
1680 usual locations. Common tactics include successively trying
1681 @command{test -e}, @command{/usr/bin/test -e}, and @command{/bin/test
1682 -e}. @command{ls -d} is another approach. But these approaches do not
1683 help with these new login patterns.
1684
1685 When @value{tramp} encounters two-factor logins or additional challenge
1686 questions, such as entering birth date or security code or passphrase,
1687 @value{tramp} needs a few more configuration steps to accommodate
1688 them.
1689
1690 The difference between a password prompt and a passphrase prompt is
1691 that the password for completing the login while the passphrase is
1692 for authorizing access to local authentication information, such as
1693 the ssh key.
1694
1695 There is no one configuration to accommodate all the variations in
1696 login security, especially not the exotic ones. However, @value{tramp}
1697 provides a few tweaks to address the most common ones.
1698
1699 @table @asis
1700 @item @var{tramp-shell-prompt-pattern}
1701 @vindex tramp-shell-prompt-pattern
1702
1703 @code{tramp-shell-prompt-pattern} is for remote login shell prompt,
1704 which may not be the same as the local login shell prompt,
1705 @code{shell-prompt-pattern}. Since most hosts use identical prompts,
1706 @value{tramp} sets a similar default value for both prompts.
1707
1708 @item @var{tramp-password-prompt-regexp}
1709 @item @var{tramp-wrong-passwd-regexp}
1710 @vindex tramp-password-prompt-regexp
1711 @vindex tramp-wrong-passwd-regexp
1712
1713 @value{tramp} uses @var{tramp-password-prompt-regexp} to distinguish
1714 between prompts for passwords and prompts for passphrases. By default,
1715 @var{tramp-password-prompt-regexp} handles the detection in English
1716 language environments. See a localization example below:
1717
1718 @lisp
1719 (setq
1720 tramp-password-prompt-regexp
1721 (concat
1722 "^.*"
1723 (regexp-opt
1724 '("passphrase" "Passphrase"
1725 ;; English
1726 "password" "Password"
1727 ;; Deutsch
1728 "passwort" "Passwort"
1729 ;; Français
1730 "mot de passe" "Mot de passe") t)
1731 ".*:\0? *"))
1732 @end lisp
1733
1734 Similar localization may be necessary for handling wrong password
1735 prompts, for which @value{tramp} uses @var{tramp-wrong-passwd-regexp}.
1736
1737 @item @command{tset} and other questions
1738 @cindex Unix command tset
1739 @cindex tset Unix command
1740 @vindex tramp-terminal-type
1741
1742 To suppress inappropriate prompts for terminal type, @value{tramp}
1743 sets the @env{TERM} to @code{dumb} before the remote login process
1744 begins via the variable @code{tramp-terminal-type}. This will silence
1745 common @command{tset} related prompts.
1746
1747 @value{tramp}'s strategy for handling such prompts (commonly triggered
1748 from login scripts on remote hosts) is to set the environment
1749 variables so that no prompts interrupt the shell initialization
1750 process.
1751
1752 @vindex tramp-actions-before-shell
1753
1754 An alternative approach is to configure @value{tramp} with strings
1755 that can identify such questions using
1756 @code{tramp-actions-before-shell}. Example:
1757
1758 @lisp
1759 (defconst my-tramp-prompt-regexp
1760 (concat (regexp-opt '("Enter the birth date of your mother:") t)
1761 "\\s-*")
1762 "Regular expression matching my login prompt question.")
1763
1764 (defun my-tramp-action (proc vec)
1765 "Enter \"19000101\" in order to give a correct answer."
1766 (save-window-excursion
1767 (with-current-buffer (tramp-get-connection-buffer vec)
1768 (tramp-message vec 6 "\n%s" (buffer-string))
1769 (tramp-send-string vec "19000101"))))
1770
1771 (add-to-list 'tramp-actions-before-shell
1772 '(my-tramp-prompt-regexp my-tramp-action))
1773 @end lisp
1774
1775
1776 @item Conflicting names for users and variables in @file{.profile}
1777
1778 When a user name is the same as a variable name in a local file, such
1779 as @file{.profile}, then @value{tramp} may send incorrect values for
1780 environment variables. To avoid incorrect values, change the local
1781 variable name to something different from the user name. For example,
1782 if the user name is @env{FRUMPLE}, then change the variable name to
1783 @env{FRUMPLE_DIR}.
1784
1785
1786 @item Non-Bourne commands in @file{.profile}
1787
1788 When the remote host's @file{.profile} is also used for shells other
1789 than Bourne shell, then some incompatible syntaxes for commands in
1790 @file{.profile} may trigger errors in Bourne shell on the host and may
1791 not complete client's @value{tramp} connections.
1792
1793 One example of a Bourne shell incompatible syntax in @file{.profile}:
1794 using @command{export FOO=bar} instead of @command{FOO=bar; export
1795 FOO}. After remote login, @value{tramp} will trigger an error during
1796 its execution of @command{/bin/sh} on the remote host because Bourne
1797 shell does not recognize the export command as entered in
1798 @file{.profile}.
1799
1800 Likewise, (@code{~}) character in paths will cause errors because
1801 Bourne shell does not do (@code{~}) character expansions.
1802
1803 One approach to avoiding these incompatibilities is to make all
1804 commands in @file{~/.shrc} and @file{~/.profile} Bourne shell
1805 compatible so @value{tramp} can complete connections to that remote.
1806 To accommodate using non-Bourne shells on that remote, use other
1807 shell-specific config files. For example, bash can use
1808 @file{~/.bash_profile} and ignore @file{.profile}.
1809
1810
1811 @item Interactive shell prompt
1812
1813 @value{tramp} redefines the remote shell prompt internally for robust
1814 parsing. This redefinition affects the looks of a prompt in an
1815 interactive remote shell through commands, such as @kbd{M-x
1816 shell}. Such prompts, however, can be reset to something more readable
1817 and recognizable using these @value{tramp} variables.
1818
1819 @value{tramp} sets the @env{INSIDE_EMACS} variable in the startup
1820 script file @file{~/.emacs_SHELLNAME}.
1821
1822 @env{SHELLNAME} is @code{bash} or equivalent shell names. Change it by
1823 setting the environment variable @env{ESHELL} in the @file{.emacs} as
1824 follows:
1825
1826 @lisp
1827 (setenv "ESHELL" "bash")
1828 @end lisp
1829
1830 Then re-set the prompt string in @file{~/.emacs_SHELLNAME} as follows:
1831
1832 @example
1833 # Reset the prompt for remote Tramp shells.
1834 if [ "$@{INSIDE_EMACS/*tramp*/tramp@}" == "tramp" ] ; then
1835 PS1="[\u@@\h \w]$ "
1836 fi
1837 @end example
1838
1839 @ifinfo
1840 @xref{Interactive Shell, , , emacs}.
1841 @end ifinfo
1842
1843 @item @command{busybox} / @command{nc}
1844 @cindex Unix command nc
1845 @cindex nc Unix command
1846
1847 @value{tramp}'s @option{nc} method uses the @command{nc} command to
1848 install and execute a listener as follows (see @code{tramp-methods}):
1849
1850 @example
1851 # nc -l -p 42
1852 @end example
1853
1854 The above command-line syntax has changed with @command{busybox}
1855 versions. If @command{nc} refuses the @command{-p} parameter, then
1856 overwrite as follows:
1857
1858 @lisp
1859 (add-to-list
1860 'tramp-connection-properties
1861 `(,(regexp-quote "192.168.0.1") "remote-copy-args" (("-l") ("%r"))))
1862 @end lisp
1863
1864 @noindent
1865 where @samp{192.168.0.1} is the remote host IP address
1866 (@pxref{Predefined connection information}).
1867
1868 @end table
1869
1870
1871 @node Android shell setup
1872 @section Android shell setup hints
1873 @cindex android shell setup
1874
1875 @value{tramp} uses the @option{adb} method to access Android
1876 devices. Android devices provide a restricted shell access through an
1877 USB connection. The local host must have the Android SDK installed.
1878
1879 Applications such as @code{SSHDroid} that run @command{sshd} process
1880 on the Android device can accept any @option{ssh}-based methods
1881 provided these settings are adjusted:
1882
1883 @code{sh} must be specified for remote shell since Android devices do
1884 not provide @code{/bin/sh}. @code{sh} will then invoke whatever shell is
1885 installed on the device with this setting:
1886
1887 @lisp
1888 (add-to-list 'tramp-connection-properties
1889 (list (regexp-quote "192.168.0.26") "remote-shell" "sh"))
1890 @end lisp
1891
1892 @noindent
1893 where @samp{192.168.0.26} is the Android device's IP address.
1894 (@pxref{Predefined connection information}).
1895
1896 @value{tramp} requires preserving @env{PATH} environment variable from
1897 user settings. Android devices prefer @file{/system/xbin} path over
1898 @file{/system/bin}. Both of these are set as follows:
1899
1900 @lisp
1901 (add-to-list 'tramp-remote-path 'tramp-own-remote-path)
1902 (add-to-list 'tramp-remote-path "/system/xbin")
1903 @end lisp
1904
1905 @noindent
1906 When the Android device is not @samp{rooted}, specify a writable
1907 directory for temporary files:
1908
1909 @lisp
1910 (add-to-list 'tramp-remote-process-environment "TMPDIR=$HOME")
1911 @end lisp
1912
1913 @noindent
1914 Open a remote connection with the command @kbd{C-x C-f
1915 @trampfn{ssh,192.168.0.26#2222,}}, where @command{sshd} is listening
1916 on port @samp{2222}.
1917
1918 To add a corresponding entry to the @file{~/.ssh/config} file
1919 (recommended), use this:
1920
1921 @example
1922 Host android
1923 HostName 192.168.0.26
1924 User root
1925 Port 2222
1926 @end example
1927
1928 @noindent
1929 To use the host name @samp{android} instead of the IP address shown in
1930 the previous example, fix the connection properties as follows:
1931
1932 @lisp
1933 (add-to-list 'tramp-connection-properties
1934 (list (regexp-quote "android") "remote-shell" "sh"))
1935 @end lisp
1936
1937 @noindent
1938 Open a remote connection with a more concise command @kbd{C-x C-f
1939 @trampfn{ssh,android,}}.
1940
1941
1942 @node Auto-save and Backup
1943 @section Auto-save and Backup configuration
1944 @cindex auto-save
1945 @cindex backup
1946 @vindex backup-directory-alist
1947
1948 To avoid @value{tramp} from saving backup files owned by @samp{root}
1949 to locations accessible to others, default backup settings in
1950 @code{backup-directory-alist} have to be altered.
1951
1952 Here's a scenario where files could be inadvertently exposed. Emacs
1953 by default writes backup files to the same directory as the original
1954 files unless changed to another location, such as
1955 @file{~/.emacs.d/backups/}. Such a directory will also be used by
1956 default by @value{tramp} when using, say, a restricted file
1957 @file{@trampfn{su,root@@localhost,/etc/secretfile}}. The backup file
1958 of the secretfile is now owned by the user logged in from
1959 @value{tramp} and not @samp{root}.
1960
1961 When @code{backup-directory-alist} is @code{nil} (the default), such
1962 problems do not occur.
1963
1964 To ``turns off'' the backup feature for @value{tramp} files and stop
1965 @value{tramp} from saving to the backup directory, use this:
1966
1967 @lisp
1968 (add-to-list 'backup-directory-alist
1969 (cons tramp-file-name-regexp nil))
1970 @end lisp
1971
1972 @noindent
1973 Disabling backups can be targeted to just the @option{su} and
1974 @option{sudo} methods:
1975
1976 @lisp
1977 (setq backup-enable-predicate
1978 (lambda (name)
1979 (and (normal-backup-enable-predicate name)
1980 (not
1981 (let ((method (file-remote-p name 'method)))
1982 (when (stringp method)
1983 (member method '("su" "sudo"))))))))
1984 @end lisp
1985
1986 Another option is to create better backup file naming with user and
1987 host names prefixed to the file name. For example, transforming
1988 @file{/etc/secretfile} to
1989 @file{~/.emacs.d/backups/!su:root@@localhost:!etc!secretfile}, set the
1990 @value{tramp} variable @code{tramp-backup-directory-alist} from the
1991 existing variable @code{backup-directory-alist}.
1992
1993 Then @value{tramp} backs up to a file name that is transformed with a
1994 prefix consisting of the DIRECTORY name. This file name prefixing
1995 happens only when the DIRECTORY is an absolute local file name.
1996
1997 @noindent
1998 Example:
1999
2000 @lisp
2001 (add-to-list 'backup-directory-alist
2002 (cons "." "~/.emacs.d/backups/"))
2003 (setq tramp-backup-directory-alist backup-directory-alist)
2004 @end lisp
2005
2006 @noindent
2007 The backup file name of
2008 @file{@trampfn{su,root@@localhost,/etc/secretfile}} would be
2009 @ifset unified
2010 @file{@trampfn{su,root@@localhost,~/.emacs.d/backups/!su:root@@localhost:!etc!secretfile~}}
2011 @end ifset
2012 @ifset separate
2013 @file{@trampfn{su,root@@localhost,~/.emacs.d/backups/![su!root@@localhost]!etc!secretfile~}}
2014 @end ifset
2015
2016 Just as for backup files, similar issues of file naming affect
2017 auto-saving @value{tramp} files. Auto-saved files are saved in the
2018 directory specified by the variable
2019 @code{auto-save-file-name-transforms}. By default this is set to the
2020 local temporary directory. But in some versions of Debian GNU/Linux,
2021 this points to the source directory where the Emacs was compiled.
2022 Reset such values to a valid directory.
2023
2024 Set @code{auto-save-file-name-transforms} to @code{nil} to save
2025 auto-saved files to the same directory as the original file.
2026
2027 Alternatively, set the variable @code{tramp-auto-save-directory} to
2028 direct all auto saves to that location.
2029
2030 @node Windows setup hints
2031 @section Issues with Cygwin ssh
2032 @cindex Cygwin, issues
2033
2034 This section is incomplete. Please share your solutions.
2035
2036 @cindex method sshx with Cygwin
2037 @cindex sshx method with Cygwin
2038
2039 Cygwin's @command{ssh} works only with a Cygwin version of Emacs. To
2040 check for compatibility: type @kbd{M-x eshell}, and start @kbd{ssh
2041 test.host}. Incompatibilities trigger this message:
2042
2043 @example
2044 Pseudo-terminal will not be allocated because stdin is not a terminal.
2045 @end example
2046
2047 Some older versions of Cygwin's @command{ssh} work with the
2048 @option{sshx} access method. Consult Cygwin's FAQ at
2049 @uref{http://cygwin.com/faq/} for details.
2050
2051
2052 @cindex method scpx with Cygwin
2053 @cindex scpx method with Cygwin
2054
2055 When using the @option{scpx} access method, Emacs may call
2056 @command{scp} with Windows file naming, such as @code{c:/foo}. But
2057 the version of @command{scp} that is installed with Cygwin does not
2058 know about Windows file naming, which causes it to incorrectly look
2059 for a host named @code{c}.
2060
2061 A workaround: write a wrapper script for @option{scp} to convert
2062 Windows file names to Cygwin file names.
2063
2064 @cindex Cygwin and ssh-agent
2065 @cindex SSH_AUTH_SOCK and Emacs on Windows
2066
2067 When using the @command{ssh-agent} on Windows for password-less
2068 interaction, @option{ssh} methods depend on the environment variable
2069 @env{SSH_AUTH_SOCK}. But this variable is not set when Emacs is
2070 started from a Desktop shortcut and authentication fails.
2071
2072 One workaround is to use a Windows based SSH Agent, such as
2073 Pageant. It is part of the Putty Suite of tools.
2074
2075 The fallback is to start Emacs from a shell.
2076
2077
2078 @node Usage
2079 @chapter Using @value{tramp}
2080 @cindex using @value{tramp}
2081
2082 @value{tramp} operates transparently, accessing remote files as if
2083 they are local. However, @value{tramp} employs a formalized remote
2084 file naming syntax to perform its functions transparently. This
2085 syntax consists of many parts specifying access methods,
2086 authentication, host names, and file names. Ange FTP uses a similar
2087 syntax.
2088
2089 @cindex type-ahead
2090
2091 Unlike opening local files in Emacs, which are instantaneous, opening
2092 remote files in @value{tramp} is slower at first. Sometimes there is
2093 a noticeable delay before the prompts for passwords or authentication
2094 appear in the minibuffer. Hitting @kbd{@key{RET}} or other keys
2095 during this gap will be processed by Emacs. This type-ahead facility
2096 is a feature of Emacs that may cause missed prompts when using
2097 @value{tramp}.
2098
2099 @menu
2100 * File name Syntax:: @value{tramp} file name conventions.
2101 * File name completion:: File name completion.
2102 * Ad-hoc multi-hops:: Declaring multiple hops in the file name.
2103 * Remote processes:: Integration with other Emacs packages.
2104 * Cleanup remote connections:: Cleanup remote connections.
2105 @end menu
2106
2107
2108 @node File name Syntax
2109 @section @value{tramp} file name conventions
2110 @cindex file name syntax
2111 @cindex file name examples
2112
2113 @file{@trampf{host,localfilename}} opens file @var{localfilename} on
2114 the remote host @var{host}, using the default method. @xref{Default
2115 Method}.
2116
2117 @table @file
2118 @item @value{prefix}melancholia@value{postfix}.emacs
2119 For the file @file{.emacs} located in the home directory, on the host
2120 @code{melancholia}.
2121
2122 @item @value{prefix}melancholia.danann.net@value{postfix}.emacs
2123 For the file @file{.emacs} specified using the fully qualified domain name of
2124 the host.
2125
2126 @item @value{prefix}melancholia@value{postfix}~/.emacs
2127 For the file @file{.emacs} specified using the @file{~}, which is expanded.
2128
2129 @item @value{prefix}melancholia@value{postfix}~daniel/.emacs
2130 For the file @file{.emacs} located in @code{daniel}'s home directory
2131 on the host, @code{melancholia}. The @file{~<user>} construct is
2132 expanded to the home directory of that user on the remote host.
2133
2134 @item @value{prefix}melancholia@value{postfix}/etc/squid.conf
2135 For the file @file{/etc/squid.conf} on the host @code{melancholia}.
2136
2137 @end table
2138
2139 @var{host} can take IPv4 or IPv6 address, as in
2140 @file{@trampf{127.0.0.1,.emacs}} or
2141 @file{@trampf{@value{ipv6prefix}::1@value{ipv6postfix},.emacs}}.
2142 @ifset unified
2143 For syntactical reasons, IPv6 addresses must be embedded in square
2144 brackets @file{@value{ipv6prefix}} and @file{@value{ipv6postfix}}.
2145 @end ifset
2146
2147 By default, @value{tramp} will use the current local user name as the
2148 remote user name for log in to the remote host. Specifying a different
2149 name using the proper syntax will override this default behavior:
2150
2151 @example
2152 @trampf{user@@host,path/to.file}
2153 @end example
2154
2155 @file{@trampf{daniel@@melancholia,.emacs}} is for file @file{.emacs}
2156 in @code{daniel}'s home directory on the host, @code{melancholia}.
2157
2158 Specify other file access methods (@pxref{Inline methods},
2159 @pxref{External methods}) as part of the file name.
2160
2161 Method name comes before user name, as in
2162 @file{@value{prefix}@var{method}@value{postfixhop}} (Note the trailing
2163 colon). The syntax specifications for user, host, and file do not
2164 change.
2165
2166 To connect to the host @code{melancholia} as @code{daniel}, using
2167 @option{ssh} method for @file{.emacs} in @code{daniel}'s home
2168 directory, the full specification is:
2169 @file{@trampfn{ssh,daniel@@melancholia,.emacs}}.
2170
2171 A remote file name containing a host name, which is the same string as
2172 a method name, is not allowed.
2173
2174 For specifying port numbers, affix @file{#<port>} to the host
2175 name. For example: @file{@trampfn{ssh,daniel@@melancholia#42,.emacs}}.
2176
2177
2178 @node File name completion
2179 @section File name completion
2180 @cindex file name completion
2181
2182 @value{tramp} can complete the following @value{tramp} file name
2183 components: method names, user names, host names, and file names
2184 located on remote hosts. Enable this by activating partial completion
2185 in @file{.emacs}.
2186 @ifinfo
2187 @xref{Completion Options, , , emacs}.
2188 @end ifinfo
2189
2190 For example, type @kbd{C-x C-f @value{prefix}t @key{TAB}},
2191 @value{tramp} completion choices show up as
2192
2193 @example
2194 @c @multitable {@trampfn{telnet,melancholia.danann.net,}} {@trampfn{telnet,192.168.0.1,}}
2195 @multitable @columnfractions .5 .5
2196 @item @value{prefixhop}telnet@value{postfixhop} @tab tmp/
2197 @item @value{prefixhop}toto@value{postfix} @tab
2198 @end multitable
2199 @end example
2200
2201 @samp{@value{prefixhop}telnet@value{postfixhop}} is a possible
2202 completion for the respective method, @samp{tmp/} stands for the
2203 directory @file{/tmp} on your local host, and
2204 @samp{@value{prefixhop}toto@value{postfix}} might be a host
2205 @value{tramp} has detected in your @file{~/.ssh/known_hosts} file
2206 (when using @option{ssh} as default method).
2207
2208 Type @kbd{e @key{TAB}} for the minibuffer completion to
2209 @samp{@value{prefix}telnet@value{postfixhop}}. Typing @kbd{@key{TAB}}
2210 shows host names @value{tramp} from @file{/etc/hosts} file, for example.
2211
2212 @example
2213 @multitable @columnfractions .5 .5
2214 @c @multitable {@trampfn{telnet,melancholia.danann.net,}} {@trampfn{telnet,192.168.0.1,}}
2215 @item @trampfn{telnet,127.0.0.1,} @tab @trampfn{telnet,192.168.0.1,}
2216 @item @trampfn{telnet,@value{ipv6prefix}::1@value{ipv6postfix},} @tab @trampfn{telnet,localhost,}
2217 @item @trampfn{telnet,melancholia.danann.net,} @tab @trampfn{telnet,melancholia,}
2218 @end multitable
2219 @end example
2220
2221 Choose a host from the above list and then continue to complete file
2222 names on that host.
2223
2224 When the configuration (@pxref{Customizing Completion}) includes user
2225 names, then the completion lists will account for the user names as well.
2226
2227 Remote hosts previously visited or hosts whose connections are kept
2228 persistently (@pxref{Connection caching}) will be included in the
2229 completion lists.
2230
2231 After remote host name completion comes completion of file names on
2232 the remote host. It works the same as with local host file completion
2233 except that killing with double-slash @file{//} kills only the file
2234 name part of the @value{tramp} file name syntax. A triple-slash
2235 stands for the default behavior.
2236 @ifinfo
2237 @xref{Minibuffer File, , , emacs}.
2238 @end ifinfo
2239
2240 @noindent
2241 Example:
2242
2243 @example
2244 @kbd{C-x C-f @trampfn{telnet,melancholia,/usr/local/bin//etc} @key{TAB}}
2245 @print{} @trampfn{telnet,melancholia,/etc}
2246
2247 @kbd{C-x C-f @trampfn{telnet,melancholia,//etc} @key{TAB}}
2248 @print{} /etc
2249
2250 @kbd{C-x C-f @trampfn{telnet,melancholia,/usr/local/bin///etc} @key{TAB}}
2251 @print{} /etc
2252 @end example
2253
2254 During file name completion, remote directory contents are re-read
2255 regularly to account for any changes in the filesystem that may affect
2256 the completion candidates. Such re-reads can account for changes to
2257 the file system by applications outside Emacs (@pxref{Connection
2258 caching}).
2259
2260 @defopt tramp-completion-reread-directory-timeout
2261 @vindex tramp-completion-reread-directory-timeout
2262 The timeout is number of seconds since last remote command for
2263 rereading remote directory contents. 0 re-reads immediately during
2264 file name completion, @code{nil} uses cached directory contents.
2265 @end defopt
2266
2267
2268 @node Ad-hoc multi-hops
2269 @section Declaring multiple hops in the file name
2270 @cindex multi-hop, ad-hoc
2271 @cindex proxy hosts, ad-hoc
2272
2273 @value{tramp} file name syntax can accommodate ad hoc specification of
2274 multiple proxies without using @code{tramp-default-proxies-alist}
2275 configuration setup(@pxref{Multi-hops}).
2276
2277 Each proxy is specified using the same syntax as the remote host
2278 specification minus the file name part. Each hop is separated by a
2279 @samp{|}. Chain the proxies from the starting host to the destination
2280 remote host name and file name. For example, hopping over a single
2281 proxy @samp{bird@@bastion} to a remote file on @samp{you@@remotehost}:
2282
2283 @example
2284 @c @kbd{C-x C-f @trampfn{ssh@value{postfixhop}bird@@bastion|ssh,you,remotehost,/path}}
2285 @kbd{C-x C-f @value{prefix}ssh@value{postfixhop}bird@@bastion|ssh@value{postfixhop}you@@remotehost@value{postfix}/path}
2286 @end example
2287
2288 Proxies can take patterns @code{%h} or @code{%u}.
2289
2290 @value{tramp} adds the ad-hoc definitions on the fly to
2291 @code{tramp-default-proxies-alist} and is available for re-use during
2292 that Emacs session. Subsequent @value{tramp} connections to the same
2293 remote host can then use the shortcut form:
2294 @samp{@trampfn{ssh,you@@remotehost,/path}}.
2295
2296 @defopt tramp-save-ad-hoc-proxies
2297 @vindex tramp-save-ad-hoc-proxies
2298 For ad-hoc definitions to be saved automatically in
2299 @option{tramp-default-proxies-alist} for future Emacs sessions, set
2300 @option{tramp-save-ad-hoc-proxies}.
2301
2302 @lisp
2303 (setq tramp-save-ad-hoc-proxies t)
2304 @end lisp
2305 @end defopt
2306
2307
2308 @node Remote processes
2309 @section Integration with other Emacs packages
2310 @cindex compile
2311 @cindex recompile
2312
2313 @value{tramp} supports starting new running processes on the remote
2314 host for discovering remote file names. Emacs packages on the remote
2315 host need no specific modifications for @value{tramp}'s use.
2316
2317 This type of integration does not work with the @option{ftp} method,
2318 and does not support the pty association as specified in
2319 @code{start-file-process}.
2320
2321 @code{process-file} and @code{start-file-process} work on the remote
2322 host when the variable @code{default-directory} is remote:
2323
2324 @lisp
2325 (let ((default-directory "/ssh:remote.host:"))
2326 (start-file-process "grep" (get-buffer-create "*grep*")
2327 "/bin/sh" "-c" "grep -e tramp *"))
2328 @end lisp
2329
2330 Remote processes do not apply to GVFS (see @ref{GVFS based methods})
2331 because the remote file system is mounted on the local host and
2332 @value{tramp} just accesses by changing the @code{default-directory}.
2333
2334 @value{tramp} starts a remote process when a command is executed in a
2335 remote file or directory buffer. As of now, these packages have been
2336 integrated to work with @value{tramp}: @file{compile.el} (commands
2337 like @code{compile} and @code{grep}) and @file{gud.el} (@code{gdb} or
2338 @code{perldb}).
2339
2340 For @value{tramp} to find the command on the remote, it must be
2341 accessible through the default search path as setup by @value{tramp}
2342 upon first connection. Alternatively, use an absolute path or extend
2343 @code{tramp-remote-path} (see @ref{Remote programs}):
2344
2345 @lisp
2346 (add-to-list 'tramp-remote-path "~/bin")
2347 (add-to-list 'tramp-remote-path "/appli/pub/bin")
2348 @end lisp
2349
2350 Customize @code{tramp-remote-process-environment} to suit the remote
2351 program's environment for the remote host.
2352 @code{tramp-remote-process-environment} is a list of strings
2353 structured similar to @code{process-environment}, where each element
2354 is a string of the form @samp{ENVVARNAME=VALUE}.
2355
2356 To avoid any conflicts with local host variables set through local
2357 configuration files, such as @file{~/.profile}, use @samp{ENVVARNAME=}
2358 to unset them for the remote environment.
2359
2360 @noindent
2361 Use @code{add-to-list} to add entries:
2362
2363 @lisp
2364 (add-to-list 'tramp-remote-process-environment "JAVA_HOME=/opt/java")
2365 @end lisp
2366
2367 Modifying or deleting already existing values in the
2368 @code{tramp-remote-process-environment} list may not be feasible on
2369 restricted remote hosts. For example, some system administrators
2370 disallow changing @env{HISTORY} variable. To accommodate such
2371 restrictions when using @value{tramp}, fix the
2372 @code{tramp-remote-process-environment} by the following code in the
2373 local @file{.emacs} file:
2374
2375 @lisp
2376 (let ((process-environment tramp-remote-process-environment))
2377 (setenv "HISTORY" nil)
2378 (setq tramp-remote-process-environment process-environment))
2379 @end lisp
2380
2381 @value{tramp} does not use the defaults specified in
2382 @code{process-environment} for running @code{process-file} or
2383 @code{start-file-process} on remote hosts. When values from
2384 @code{process-environment} are needed for remote processes, then set
2385 them as follows:
2386
2387 @lisp
2388 (let ((process-environment (cons "HGPLAIN=1" process-environment)))
2389 (process-file @dots{}))
2390 @end lisp
2391
2392 This works only for environment variables not already set in the
2393 @code{process-environment}.
2394
2395 For integrating other Emacs packages so @value{tramp} can execute
2396 remotely, please file a bug report. @xref{Bug Reports}.
2397
2398
2399 @subsection Running remote programs that create local X11 windows
2400
2401 To allow a remote program to create an X11 window on the local host,
2402 set the @env{DISPLAY} environment variable for the remote host as
2403 follows in the local @file{.emacs} file:
2404
2405 @lisp
2406 (add-to-list 'tramp-remote-process-environment
2407 (format "DISPLAY=%s" (getenv "DISPLAY")))
2408 @end lisp
2409
2410 @noindent
2411 @code{(getenv "DISPLAY")} should return a recognizable name for the
2412 local host that the remote host can redirect X11 window
2413 interactions. If querying for a recognizable name is not possible for
2414 whatever reason, then replace @code{(getenv "DISPLAY")} with a
2415 hard-coded, fixed name. Note that using @code{:0} for X11 display name
2416 here will not work as expected.
2417
2418 An alternate approach is specify @code{ForwardX11 yes} or
2419 @code{ForwardX11Trusted yes} in the file @file{~/.ssh/config} on the
2420 local host.
2421
2422
2423 @subsection Running @code{shell} on a remote host
2424 @cindex shell
2425
2426 Set @option{explicit-shell-file-name} to the appropriate shell name
2427 when using @value{tramp} between two hosts with different operating
2428 systems, such as @samp{windows-nt} and @samp{gnu/linux}. This option
2429 ensures the correct name of the remote shell program.
2430
2431 Starting with Emacs 24, when @option{explicit-shell-file-name} is
2432 equal to @code{nil}, calling @code{shell} interactively will prompt
2433 for a shell name.
2434
2435
2436 @subsection Running @code{shell-command} on a remote host
2437 @cindex shell-command
2438
2439 @code{shell-command} executes commands synchronously or asynchronously
2440 on remote hosts and displays output in buffers on the local
2441 host. Example:
2442
2443 @example
2444 @kbd{C-x C-f @trampfn{sudo,,} @key{RET}}
2445 @kbd{M-! tail -f /var/log/syslog.log & @key{RET}}
2446 @end example
2447
2448 @command{tail} command outputs continuously to the local buffer,
2449 @file{*Async Shell Command*}
2450
2451 @kbd{M-x auto-revert-tail-mode} runs similarly showing continuous output.
2452
2453
2454 @subsection Running @code{eshell} on a remote host
2455 @cindex eshell
2456
2457 @value{tramp} is integrated into @file{eshell.el}, which enables
2458 interactive eshell sessions on remote hosts at the command prompt.
2459 You must add the module @code{eshell-tramp} to
2460 @code{eshell-modules-list}. Here's a sample interaction after opening
2461 @kbd{M-x eshell} on a remote host:
2462
2463 @example
2464 @b{~ $} cd @trampfn{sudo,,/etc} @key{RET}
2465 @b{@trampfn{sudo,root@@host,/etc} $} hostname @key{RET}
2466 host
2467 @b{@trampfn{sudo,root@@host,/etc} $} id @key{RET}
2468 uid=0(root) gid=0(root) groups=0(root)
2469 @b{@trampfn{sudo,root@@host,/etc} $} find-file shadow @key{RET}
2470 #<buffer shadow>
2471 @b{@trampfn{sudo,root@@host,/etc} $}
2472 @end example
2473
2474 @code{eshell} in Emacs 23.2 added custom @code{su} and @code{sudo}
2475 commands that set the default directory correctly for the
2476 @file{*eshell*} buffer. @value{tramp} silently updates
2477 @code{tramp-default-proxies-alist} with an entry for this directory
2478 (@pxref{Multi-hops}):
2479
2480 @example
2481 @b{~ $} cd @trampfn{ssh,user@@remotehost,/etc} @key{RET}
2482 @b{@trampfn{ssh,user@@remotehost,/etc} $} find-file shadow @key{RET}
2483 File is not readable: @trampfn{ssh,user@@remotehost,/etc/shadow}
2484 @b{@trampfn{ssh,user@@remotehost,/etc} $} sudo find-file shadow @key{RET}
2485 #<buffer shadow>
2486
2487 @b{@trampfn{ssh,user@@remotehost,/etc} $} su - @key{RET}
2488 @b{@trampfn{su,root@@remotehost,/root} $} id @key{RET}
2489 uid=0(root) gid=0(root) groups=0(root)
2490 @b{@trampfn{su,root@@remotehost,/root} $}
2491 @end example
2492
2493
2494 @anchor{Running a debugger on a remote host}
2495 @subsection Running a debugger on a remote host
2496 @cindex gud
2497 @cindex gdb
2498 @cindex perldb
2499
2500 @file{gud.el} provides a unified interface to symbolic debuggers
2501 @ifinfo
2502 (@ref{Debuggers, , , emacs}).
2503 @end ifinfo
2504 @value{tramp} can run debug on remote hosts by calling @code{gdb}
2505 with a remote file name:
2506
2507 @example
2508 @kbd{M-x gdb @key{RET}}
2509 @b{Run gdb (like this):} gdb --annotate=3 @trampfn{ssh,host,~/myprog} @key{RET}
2510 @end example
2511
2512 Relative file names are based on the remote default directory. When
2513 @file{myprog.pl} exists in @file{@trampfn{ssh,host,/home/user}}, valid
2514 calls include:
2515
2516 @example
2517 @kbd{M-x perldb @key{RET}}
2518 @b{Run perldb (like this):} perl -d myprog.pl @key{RET}
2519 @end example
2520
2521 Just the local part of a remote file name, such as @kbd{perl -d
2522 /home/user/myprog.pl}, is not possible.
2523
2524 Arguments of the program to be debugged must be literal, can take
2525 relative or absolute paths, but not remote paths.
2526
2527
2528 @subsection Running remote processes on Windows hosts
2529 @cindex winexe
2530 @cindex powershell
2531
2532 @command{winexe} runs processes on a remote Windows host, and
2533 @value{tramp} can use it for @code{process-file} and
2534 @code{start-file-process}.
2535
2536 @code{tramp-smb-winexe-program} specifies the local @command{winexe}
2537 command. Powershell V2.0 on the remote host is required to run
2538 processes triggered from @value{tramp}.
2539
2540 @option{explicit-shell-file-name} and @option{explicit-*-args} have to
2541 be set properly so @kbd{M-x shell} can open a proper remote shell on a
2542 Windows host. To open @command{cmd}, set it as follows:
2543
2544 @lisp
2545 (setq explicit-shell-file-name "cmd"
2546 explicit-cmd-args '("/q"))
2547 @end lisp
2548
2549 @noindent
2550 To open @command{powershell} as a remote shell, use this:
2551
2552 @lisp
2553 (setq explicit-shell-file-name "powershell"
2554 explicit-powershell-args '("-file" "-"))
2555 @end lisp
2556
2557
2558 @node Cleanup remote connections
2559 @section Cleanup remote connections
2560 @cindex cleanup
2561
2562 @value{tramp} provides several ways to flush remote connections.
2563
2564 @deffn Command tramp-cleanup-connection vec
2565 This command flushes all connection related objects. @option{vec} is
2566 the internal representation of a remote connection. When called
2567 interactively, this command lists active remote connections in the
2568 minibuffer. Each connection is of the format
2569 @file{@trampfn{method,user@@host,}}. Flushing remote connections also
2570 cleans the password cache (@pxref{Password handling}), file cache,
2571 connection cache (@pxref{Connection caching}), and connection buffers.
2572 @end deffn
2573
2574 @deffn Command tramp-cleanup-this-connection
2575 Flushes only the current buffer's remote connection objects, the same
2576 as in @code{tramp-cleanup-connection}.
2577 @end deffn
2578
2579 @deffn Command tramp-cleanup-all-connections
2580 Flushes all active remote connection objects, the same as in
2581 @code{tramp-cleanup-connection}.
2582 @end deffn
2583
2584 @deffn Command tramp-cleanup-all-buffers
2585 Just as for @code{tramp-cleanup-all-connections}, all remote
2586 connections are cleaned up in addition to killing buffers related to
2587 that remote connection.
2588 @end deffn
2589
2590
2591 @node Bug Reports
2592 @chapter Reporting Bugs and Problems
2593 @cindex bug reports
2594
2595 @value{tramp}'s development team is actively engaged in solving bugs
2596 and problems and looks to feature requests and suggestions.
2597
2598 @value{tramp}'s mailing list is the place for more advice and
2599 information on working with @value{tramp}, solving problems,
2600 discussing, and general discussions about @value{tramp}.
2601
2602 @value{tramp}'s mailing list is moderated but even non-subscribers can
2603 post for moderator approval. Sometimes this approval step may take as
2604 long as 48 hours due to public holidays.
2605
2606 @email{tramp-devel@@gnu.org} is the mailing list. Messages sent to
2607 this address go to all the subscribers. This is @emph{not} the
2608 address to send subscription requests to.
2609
2610 To subscribe to the mailing list, visit:
2611 @uref{http://lists.gnu.org/mailman/listinfo/tramp-devel/, the
2612 @value{tramp} Mail Subscription Page}.
2613
2614 @ifset installchapter
2615 Before sending a bug report, run the test suite first @ref{Testing}.
2616 @end ifset
2617
2618 @findex tramp-bug
2619 Check if the bug or problem is already addressed in @xref{Frequently
2620 Asked Questions}.
2621
2622 Run @kbd{M-x tramp-bug} to generate a buffer with details of the
2623 system along with the details of the @value{tramp}
2624 installation. Please include these details with the bug report.
2625
2626 The bug report must describe in as excruciating detail as possible the
2627 steps required to reproduce the problem. These details must include
2628 the setup of the remote host and any special or unique conditions that
2629 exist.
2630
2631 Include a minimal test case that reproduces the problem. This will
2632 help the development team find the best solution and avoid unrelated
2633 detours.
2634
2635 To exclude cache-related problems, flush all caches before running the
2636 test, @ref{Cleanup remote connections}.
2637
2638 When including @value{tramp}'s messages in the bug report, increase
2639 the verbosity level to 6 (@pxref{Traces and Profiles, Traces}) in the
2640 @file{~/.emacs} file before repeating steps to the bug. Include the
2641 contents of the @file{*tramp/foo*} and @file{*debug tramp/foo*}
2642 buffers with the bug report.
2643
2644 @strong{Note} that a verbosity level greater than 6 is not necessary
2645 at this stage. Also note that a verbosity level of 6 or greater, the
2646 contents of files and directories will be included in the debug
2647 buffer. Passwords typed in @value{tramp} will never be included
2648 there.
2649
2650
2651 @node Frequently Asked Questions
2652 @chapter Frequently Asked Questions
2653 @cindex frequently asked questions
2654 @cindex FAQ
2655
2656 @itemize @bullet
2657 @item
2658 Where is the latest @value{tramp}?
2659
2660 @value{tramp} is available at the GNU URL:
2661
2662 @noindent
2663 @uref{ftp://ftp.gnu.org/gnu/tramp/}
2664
2665 @noindent
2666 @value{tramp}'s GNU project page is located here:
2667
2668 @noindent
2669 @uref{http://savannah.gnu.org/projects/tramp/}
2670
2671
2672 @item
2673 Which systems does it work on?
2674
2675 The package works successfully on Emacs 23, Emacs 24, and Emacs 25.
2676
2677 While Unix and Unix-like systems are the primary remote targets,
2678 @value{tramp} has equal success connecting to other platforms, such as
2679 MS Windows XP/Vista/7.
2680
2681
2682 @item
2683 How to speed up @value{tramp}?
2684
2685 @value{tramp} does many things in the background, some of which
2686 depends on network speeds, response speeds of remote hosts, and
2687 authentication delays. During these operations, @value{tramp}'s
2688 responsiveness slows down. Some suggestions within the scope of
2689 @value{tramp}'s settings include:
2690
2691 Use an external method, such as @option{scp}, which are faster than
2692 internal methods.
2693
2694 Keep the file @code{tramp-persistency-file-name}, which is where
2695 @value{tramp} caches remote information about hosts and files. Caching
2696 is enabled by default. Don't disable it.
2697
2698 Set @code{remote-file-name-inhibit-cache} to @code{nil} if remote
2699 files are not independently updated outside @value{tramp}'s control.
2700 That cache cleanup will be necessary if the remote directories or
2701 files are updated independent of @value{tramp}.
2702
2703 Set @code{tramp-completion-reread-directory-timeout} to @code{nil} to
2704 speed up completions, @ref{File name completion}.
2705
2706 Disable version control to avoid delays:
2707
2708 @lisp
2709 (setq vc-ignore-dir-regexp
2710 (format "\\(%s\\)\\|\\(%s\\)"
2711 vc-ignore-dir-regexp
2712 tramp-file-name-regexp))
2713 @end lisp
2714
2715 Disable excessive traces. Set @code{tramp-verbose} to 3 or lower,
2716 default being 3. Increase trace levels temporarily when hunting for
2717 bugs.
2718
2719 @item
2720 @value{tramp} does not connect to the remote host
2721
2722 Three main reasons for why @value{tramp} does not connect to the remote host:
2723
2724 @itemize @minus
2725 @item
2726 Unknown characters in the prompt
2727
2728 @value{tramp} needs a clean recognizable prompt on the remote host for
2729 accurate parsing. Shell prompts that contain escape sequences for
2730 coloring cause parsing problems. @ref{Remote shell setup} for
2731 customizing prompt detection using regular expressions.
2732
2733 To check if the remote host's prompt is being recognized, use this
2734 test: switch to @value{tramp} connection buffer @file{*tramp/foo*},
2735 put the cursor at the top of the buffer, and then apply the following
2736 expression:
2737
2738 @example
2739 @kbd{M-: (re-search-forward (concat tramp-shell-prompt-pattern "$"))}
2740 @end example
2741
2742 If the cursor has not moved to the prompt at the bottom of the buffer,
2743 then @value{tramp} has failed to recognize the prompt.
2744
2745 When using zsh on remote hosts, disable zsh line editor because zsh
2746 uses left-hand side and right-hand side prompts in parallel. Add the
2747 following line to @file{~/.zshrc}:
2748
2749 @example
2750 [ $TERM = "dumb" ] && unsetopt zle && PS1='$ '
2751 @end example
2752
2753 When using fish shell on remote hosts, disable fancy formatting by
2754 adding the following to @file{~/.config/fish/config.fish}:
2755
2756 @example
2757 function fish_prompt
2758 if test $TERM = "dumb"
2759 echo "\$ "
2760 else
2761 @dots{}
2762 end
2763 end
2764 @end example
2765
2766 When using WinSSHD on remote hosts, @value{tramp} do not recognize the
2767 strange prompt settings.
2768
2769 @item
2770 Echoed characters after login
2771
2772 @value{tramp} suppresses echos from remote hosts with the
2773 @command{stty -echo} command. But sometimes it is too late to suppress
2774 welcome messages from the remote host containing harmful control
2775 characters. Using @option{sshx} or @option{scpx} methods can avoid
2776 this problem because they allocate a pseudo tty. @xref{Inline
2777 methods}.
2778
2779 @item
2780 @value{tramp} stops transferring strings longer than 500 characters
2781
2782 Set @code{tramp-chunksize} to 500 to get around this problem, which is
2783 related to faulty implementation of @code{process-send-string} on
2784 HP-UX, FreeBSD and Tru64 Unix systems. Consult the documentation for
2785 @code{tramp-chunksize} to see when this is necessary.
2786
2787 Set @code{file-precious-flag} to @code{t} for files accessed by
2788 @value{tramp} so the file contents are checked using checksum by
2789 first saving to a temporary file.
2790 @ifinfo
2791 @pxref{Saving Buffers, , , elisp}
2792 @end ifinfo
2793
2794 @lisp
2795 (add-hook
2796 'find-file-hook
2797 (lambda ()
2798 (when (file-remote-p default-directory)
2799 (set (make-local-variable 'file-precious-flag) t))))
2800 @end lisp
2801 @end itemize
2802
2803
2804 @item
2805 @value{tramp} does not recognize if a @command{ssh} session hangs
2806
2807 @command{ssh} sessions on the local host hang when the network is
2808 down. @value{tramp} cannot safely detect such hangs. The network
2809 configuration for @command{ssh} can be configured to kill such hangs
2810 with the following command in the @file{~/.ssh/config}:
2811
2812 @example
2813 Host *
2814 ServerAliveInterval 5
2815 @end example
2816
2817
2818 @item
2819 @value{tramp} does not use default @command{ssh} @code{ControlPath}
2820
2821 @value{tramp} overwrites @code{ControlPath} settings when initiating
2822 @command{ssh} sessions. @value{tramp} does this to fend off a stall
2823 if a master session opened outside the Emacs session is no longer
2824 open. That is why @value{tramp} prompts for the password again even
2825 if there is an @command{ssh} already open.
2826
2827 Some @command{ssh} versions support a @code{ControlPersist} option,
2828 which allows you to set the @code{ControlPath} provided the variable
2829 @code{tramp-ssh-controlmaster-options} is customized as follows:
2830
2831 @lisp
2832 (setq tramp-ssh-controlmaster-options
2833 (concat
2834 "-o ControlPath=/tmp/ssh-ControlPath-%%r@@%%h:%%p "
2835 "-o ControlMaster=auto -o ControlPersist=yes"))
2836 @end lisp
2837
2838 Note how "%r", "%h" and "%p" must be encoded as "%%r", "%%h" and
2839 "%%p".
2840
2841 If the @file{~/.ssh/config} is configured appropriately for the above
2842 behavior, then any changes to @command{ssh} can be suppressed with
2843 this @code{nil} setting:
2844
2845 @lisp
2846 (setq tramp-use-ssh-controlmaster-options nil)
2847 @end lisp
2848
2849
2850 @item
2851 File name completion does not work with @value{tramp}
2852
2853 @acronym{ANSI} escape sequences from the remote shell may cause errors
2854 in @value{tramp}'s parsing of remote buffers.
2855
2856 To test if this is the case, open a remote shell and check if the output
2857 of @command{ls} is in color.
2858
2859 To disable @acronym{ANSI} escape sequences from the remote hosts,
2860 disable @option{--color=yes} or @option{--color=auto} in the remote
2861 host's @file{.bashrc} or @file{.profile}. Turn this alias on and off
2862 to see if file name completion works.
2863
2864 @item
2865 File name completion does not work in directories with large number of
2866 files
2867
2868 This may be related to globbing, which is the use of shell's ability
2869 to expand wild card specifications, such as @samp{*.c}. For
2870 directories with large number of files, globbing might exceed the
2871 shell's limit on length of command lines and hang. @value{tramp} uses
2872 globbing.
2873
2874 To test if globbing hangs, open a shell on the remote host and then
2875 run @samp{ls -d * ..?* > /dev/null}.
2876
2877 When testing, ensure the remote shell is the same shell
2878 (@command{/bin/sh}, @command{ksh} or @command{bash}), that
2879 @value{tramp} uses when connecting to that host.
2880
2881
2882 @item
2883 How to get notified after @value{tramp} completes file transfers?
2884
2885 Make Emacs beep after reading from or writing to the remote host with
2886 the following code in @file{~/.emacs} file.
2887
2888 @lisp
2889 (defadvice tramp-handle-write-region
2890 (after tramp-write-beep-advice activate)
2891 "Make tramp beep after writing a file."
2892 (interactive)
2893 (beep))
2894
2895 (defadvice tramp-handle-do-copy-or-rename-file
2896 (after tramp-copy-beep-advice activate)
2897 "Make tramp beep after copying a file."
2898 (interactive)
2899 (beep))
2900
2901 (defadvice tramp-handle-insert-file-contents
2902 (after tramp-insert-beep-advice activate)
2903 "Make tramp beep after inserting a file."
2904 (interactive)
2905 (beep))
2906 @end lisp
2907
2908
2909 @item
2910 How to get a Visual Warning when working with @samp{root} privileges
2911
2912 Get a modeline indication when working with @samp{root} privileges
2913 with the following code (tested with Emacs 22.1) in @file{~/.emacs}
2914 file:
2915
2916 @lisp
2917 (defun my-mode-line-function ()
2918 (when (string-match "^/su\\(do\\)?:" default-directory)
2919 (setq mode-line-format
2920 (format-mode-line mode-line-format 'font-lock-warning-face))))
2921
2922 (add-hook 'find-file-hook 'my-mode-line-function)
2923 (add-hook 'dired-mode-hook 'my-mode-line-function)
2924 @end lisp
2925
2926
2927 @item
2928 How to get host indication in the mode line?
2929
2930 The following code (tested with Emacs 22.1) in @file{~/.emacs} file
2931 shows it:
2932
2933 @lisp
2934 (defconst my-mode-line-buffer-identification
2935 (list
2936 '(:eval
2937 (let ((host-name
2938 (if (file-remote-p default-directory)
2939 (tramp-file-name-host
2940 (tramp-dissect-file-name default-directory))
2941 (system-name))))
2942 (if (string-match "^[^0-9][^.]*\\(\\..*\\)" host-name)
2943 (substring host-name 0 (match-beginning 1))
2944 host-name)))
2945 ": %12b"))
2946
2947 (setq-default
2948 mode-line-buffer-identification
2949 my-mode-line-buffer-identification)
2950
2951 (add-hook
2952 'dired-mode-hook
2953 (lambda ()
2954 (setq
2955 mode-line-buffer-identification
2956 my-mode-line-buffer-identification)))
2957 @end lisp
2958
2959 The mode line in Emacs 23.1 and later versions now contains an
2960 indication if @code{default-directory} for the current buffer is on a
2961 remote host. Moreover, the corresponding tool-tip shows the remote
2962 host name. The above @code{:eval} clause can also be simplified to
2963 show the host name in the mode line:
2964
2965 @lisp
2966 '(:eval
2967 (let ((host-name
2968 (or (file-remote-p default-directory 'host)
2969 (system-name))))
2970 (if (string-match "^[^0-9][^.]*\\(\\..*\\)" host-name)
2971 (substring host-name 0 (match-beginning 1))
2972 host-name)))
2973 @end lisp
2974
2975
2976 @item
2977 Remote host does not understand default options for directory listing
2978
2979 Emacs computes the @command{dired} options based on the local host but
2980 if the remote host cannot understand the same @command{ls} command,
2981 then set them with a hook as follows:
2982
2983 @lisp
2984 (add-hook
2985 'dired-before-readin-hook
2986 (lambda ()
2987 (when (file-remote-p default-directory)
2988 (setq dired-actual-switches "-al"))))
2989 @end lisp
2990
2991
2992 @item
2993 Why is @file{~/.sh_history} file on the remote host growing?
2994
2995 Due to @command{ksh} saving tilde expansions triggered by
2996 @value{tramp}, the history file is probably growing rapidly. To fix,
2997 turn off saving history by putting this shell code in the
2998 @file{.kshrc} file:
2999
3000 @example
3001 if [ -f $HOME/.sh_history ] ; then
3002 /bin/rm $HOME/.sh_history
3003 fi
3004 if [ "$@{HISTFILE-unset@}" != "unset" ] ; then
3005 unset HISTFILE
3006 fi
3007 if [ "$@{HISTSIZE-unset@}" != "unset" ] ; then
3008 unset HISTSIZE
3009 fi
3010 @end example
3011
3012 For @option{ssh}-based method, add the following line to your
3013 @file{~/.ssh/environment} file:
3014
3015 @example
3016 HISTFILE=/dev/null
3017 @end example
3018
3019
3020 @item
3021 How to shorten long file names when typing in @value{tramp}?
3022
3023 Adapt several of these approaches to reduce typing. If the full name
3024 is @file{@trampfn{ssh,news@@news.my.domain,/opt/news/etc}}, then:
3025
3026 @enumerate
3027
3028 @item
3029 Use default values for method name and user name:
3030
3031 You can define default methods and user names for hosts,
3032 (@pxref{Default Method}, @pxref{Default User}):
3033
3034 @lisp
3035 (setq tramp-default-method "ssh"
3036 tramp-default-user "news")
3037 @end lisp
3038
3039 The reduced typing: @kbd{C-x C-f @trampf{news.my.domain,/opt/news/etc}}.
3040
3041 @strong{Note} that there are some useful shortcuts already. Accessing
3042 your local host as @samp{root} user, is possible just by @kbd{C-x C-f
3043 @trampfn{su,,}}.
3044
3045 @item
3046 Use configuration options of the access method:
3047
3048 Programs used for access methods already offer powerful configurations
3049 (@pxref{Customizing Completion}). For @option{ssh}, configure the
3050 file @file{~/.ssh/config}:
3051
3052 @example
3053 Host xy
3054 HostName news.my.domain
3055 User news
3056 @end example
3057
3058 The reduced typing: @kbd{C-x C-f @trampfn{ssh,xy,/opt/news/etc}}.
3059
3060 Depending on the number of files in the directories, host names
3061 completion can further reduce key strokes: @kbd{C-x C-f
3062 @value{prefix}ssh@value{postfixhop}x @key{TAB}}.
3063
3064 @item
3065 Use environment variables to expand long strings
3066
3067 For long file names, set up environment variables that are expanded in
3068 the minibuffer. Environment variables are set either outside Emacs or
3069 inside Emacs with Lisp:
3070
3071 @lisp
3072 (setenv "xy" "@trampfn{ssh,news@@news.my.domain,/opt/news/etc/}")
3073 @end lisp
3074
3075 The reduced typing: @kbd{C-x C-f $xy @key{RET}}.
3076
3077 @strong{Note} that file name cannot be edited here because the
3078 environment variables are not expanded during editing in the
3079 minibuffer.
3080
3081 @item Define own keys:
3082
3083 Redefine another key sequence in Emacs for @kbd{C-x C-f}:
3084
3085 @lisp
3086 (global-set-key
3087 [(control x) (control y)]
3088 (lambda ()
3089 (interactive)
3090 (find-file
3091 (read-file-name
3092 "Find Tramp file: "
3093 "@trampfn{ssh,news@@news.my.domain,/opt/news/etc/}"))))
3094 @end lisp
3095
3096 Simply typing @kbd{C-x C-y} would prepare minibuffer editing of file
3097 name.
3098
3099 See @uref{http://www.emacswiki.org/cgi-bin/wiki/TrampMode, the Emacs
3100 Wiki} for a more comprehensive example.
3101
3102 @item
3103 Define own abbreviation (1):
3104
3105 Abbreviation list expansion can be used to reduce typing long file names:
3106
3107 @lisp
3108 (add-to-list
3109 'directory-abbrev-alist
3110 '("^/xy" . "@trampfn{ssh,news@@news.my.domain,/opt/news/etc/}"))
3111 @end lisp
3112
3113 The reduced typing: @kbd{C-x C-f /xy @key{RET}}.
3114
3115 @strong{Note} that file name cannot be edited here because the
3116 environment variables are not expanded during editing in the
3117 minibuffer.
3118
3119 @item
3120 Define own abbreviation (2):
3121
3122 The @code{abbrev-mode} gives additional flexibility for editing in the
3123 minibuffer:
3124
3125 @lisp
3126 (define-abbrev-table 'my-tramp-abbrev-table
3127 '(("xy" "@trampfn{ssh,news@@news.my.domain,/opt/news/etc/}")))
3128
3129 (add-hook
3130 'minibuffer-setup-hook
3131 (lambda ()
3132 (abbrev-mode 1)
3133 (setq local-abbrev-table my-tramp-abbrev-table)))
3134
3135 (defadvice minibuffer-complete
3136 (before my-minibuffer-complete activate)
3137 (expand-abbrev))
3138
3139 ;; If you use partial-completion-mode
3140 (defadvice PC-do-completion
3141 (before my-PC-do-completion activate)
3142 (expand-abbrev))
3143 @end lisp
3144
3145 The reduced typing: @kbd{C-x C-f xy @key{TAB}}.
3146
3147 The minibuffer expands for further editing.
3148
3149 @item Use bookmarks:
3150
3151 Use bookmarks to save Tramp file names.
3152 @ifinfo
3153 @pxref{Bookmarks, , , emacs}.
3154 @end ifinfo
3155
3156 Upon visiting a location with @value{tramp}, save it as a bookmark with
3157 @kbd{@key{menu-bar} @key{edit} @key{bookmarks} @key{set}}.
3158
3159 To revisit that bookmark:
3160 @kbd{@key{menu-bar} @key{edit} @key{bookmarks} @key{jump}}.
3161
3162 @item Use recent files:
3163
3164 @file{recentf} remembers visited places.
3165 @ifinfo
3166 @pxref{File Conveniences, , , emacs}.
3167 @end ifinfo
3168
3169 Keep remote file names in the recent list without have to check for
3170 their accessibility through remote access:
3171
3172 @lisp
3173 (recentf-mode 1)
3174 @end lisp
3175
3176 Reaching recently opened files: @kbd{@key{menu-bar} @key{file}
3177 @key{Open Recent}}.
3178
3179 @item Use filecache:
3180
3181 Since @file{filecache} remembers visited places, add the remote
3182 directory to the cache:
3183
3184 @lisp
3185 (eval-after-load "filecache"
3186 '(file-cache-add-directory
3187 "@trampfn{ssh,news@@news.my.domain,/opt/news/etc/}"))
3188 @end lisp
3189
3190 Then use directory completion in the minibuffer with @kbd{C-x C-f
3191 C-@key{TAB}}.
3192
3193 @item Use bbdb:
3194
3195 @file{bbdb} has a built-in feature for Ange FTP files, which also
3196 works for @value{tramp} file names.
3197 @ifinfo
3198 @pxref{bbdb-ftp, Storing FTP sites in the BBDB, , bbdb}.
3199 @end ifinfo
3200
3201 Load @file{bbdb} in Emacs:
3202
3203 @lisp
3204 (require 'bbdb)
3205 (bbdb-initialize)
3206 @end lisp
3207
3208 Create a BBDB entry with @kbd{M-x bbdb-create-ftp-site}. Then specify
3209 a method and user name where needed. Examples:
3210
3211 @example
3212 @kbd{M-x bbdb-create-ftp-site @key{RET}}
3213 @b{Ftp Site:} news.my.domain @key{RET}
3214 @b{Ftp Directory:} /opt/news/etc/ @key{RET}
3215 @b{Ftp Username:} ssh@value{postfixhop}news @key{RET}
3216 @b{Company:} @key{RET}
3217 @b{Additional Comments:} @key{RET}
3218 @end example
3219
3220 In BBDB buffer, access an entry by pressing the key @key{F}.
3221
3222 @end enumerate
3223
3224 Thanks to @value{tramp} users for contributing to these recipes.
3225
3226 @item
3227 Why saved multi-hop file names do not work in a new Emacs session?
3228
3229 When saving ad-hoc multi-hop @value{tramp} file names (@pxref{Ad-hoc
3230 multi-hops}) via bookmarks, recent files, filecache, bbdb, or another
3231 package, use the full ad-hoc file name including all hops, like
3232 @file{@trampfn{ssh,bird@@bastion|ssh@value{postfixhop}news.my.domain,/opt/news/etc}}.
3233
3234 Alternatively, when saving abbreviated multi-hop file names
3235 @file{@trampfn{ssh,news@@news.my.domain,/opt/news/etc}}, the custom
3236 option @code{tramp-save-ad-hoc-proxies} must be set non-@code{nil}
3237 value.
3238
3239
3240 @item
3241 How to connect to a remote Emacs session using @value{tramp}?
3242
3243 Configure Emacs Client
3244 @ifinfo
3245 (@pxref{Emacs Server, , , emacs}).
3246 @end ifinfo
3247
3248 Then on the remote host, start the Emacs Server:
3249
3250 @lisp
3251 (require 'server)
3252 (setq server-host (system-name)
3253 server-use-tcp t)
3254 (server-start)
3255 @end lisp
3256
3257 If @code{(system-name)} of the remote host cannot be resolved on the
3258 local host, use IP address instead.
3259
3260 Copy from the remote host the resulting file
3261 @file{~/.emacs.d/server/server} to the local host, to the same
3262 location.
3263
3264 Then start Emacs Client from the command line:
3265
3266 @example
3267 emacsclient @trampfn{ssh,user@@host,/file/to/edit}
3268 @end example
3269
3270 @code{user} and @code{host} refer to the local host.
3271
3272 To make Emacs Client an editor for other programs, use a wrapper
3273 script @file{emacsclient.sh}:
3274
3275 @example
3276 #!/bin/sh
3277 emacsclient @trampfn{ssh,$(whoami)@@$(hostname --fqdn),$1}
3278 @end example
3279
3280 Then change the environment variable @env{EDITOR} to point to the
3281 wrapper script:
3282
3283 @example
3284 export EDITOR=/path/to/emacsclient.sh
3285 @end example
3286
3287
3288 @item
3289 How to disable other packages from calling @value{tramp}?
3290
3291 There are packages that call @value{tramp} without the user ever
3292 entering a remote file name. Even without applying a remote file
3293 syntax, some packages enable @value{tramp} on their own. How can users
3294 disable such features.
3295
3296 @itemize @minus
3297 @item
3298 @file{ido.el}
3299
3300 Disable @value{tramp} file name completion:
3301
3302 @lisp
3303 (custom-set-variables
3304 '(ido-enable-tramp-completion nil))
3305 @end lisp
3306
3307 @item
3308 @file{rlogin.el}
3309
3310 Disable remote directory tracking mode:
3311
3312 @lisp
3313 (rlogin-directory-tracking-mode -1)
3314 @end lisp
3315 @end itemize
3316
3317
3318 @item
3319 How to disable @value{tramp}?
3320
3321 @itemize @minus
3322 @item
3323 To keep Ange FTP as default the remote files access package, set this
3324 in @file{.emacs}:
3325
3326 @lisp
3327 (setq tramp-default-method "ftp")
3328 @end lisp
3329
3330 @item
3331 To disable both @value{tramp} (and Ange FTP), set @code{tramp-mode} to
3332 @code{nil} in @file{.emacs}.
3333
3334 @lisp
3335 (setq tramp-mode nil)
3336 @end lisp
3337
3338 @item
3339 To unload @value{tramp}, type @kbd{M-x tramp-unload-tramp}. Unloading
3340 @value{tramp} resets Ange FTP plugins also.
3341 @end itemize
3342 @end itemize
3343
3344
3345 @c For the developer
3346 @node Files directories and localnames
3347 @chapter How file names, directories and localnames are mangled and managed.
3348
3349 @menu
3350 * Localname deconstruction:: Splitting a localname into its component parts.
3351 * External packages:: Integrating with external Lisp packages.
3352 @end menu
3353
3354
3355 @node Localname deconstruction
3356 @section Splitting a localname into its component parts
3357
3358 @value{tramp} package redefines lisp functions
3359 @code{file-name-directory} and @code{file-name-nondirectory} to
3360 accommodate the unique file naming syntax that @value{tramp} requires.
3361
3362 The replacements dissect the file name, use the original handler for
3363 the localname, take that result, and then re-build the @value{tramp}
3364 file name. By relying on the original handlers for localnames,
3365 @value{tramp} benefits from platform specific hacks to the original
3366 handlers.
3367
3368
3369 @node External packages
3370 @section Integrating with external Lisp packages
3371 @subsection File name completion.
3372
3373 For name completions in the minibuffer, @value{tramp} depends on the
3374 last input character to decide whether to look for method name
3375 completion or host name completion. For example, @kbd{C-x C-f
3376 @value{prefix}ssh@value{postfixhop} @key{TAB}} is not entirely clear
3377 if @option{ssh} is a method or a host name. But if the last input
3378 character was either @key{TAB}, @key{SPACE} or @kbd{?}, then
3379 @value{tramp} favors file name completion over host name completion.
3380
3381 What about external packages using other characters to trigger file
3382 name completions? They must somehow signal this to @value{tramp}. Use
3383 the variable @code{non-essential} temporarily and bind it to
3384 non-@code{nil} value.
3385
3386 @lisp
3387 (let ((non-essential t))
3388 @dots{})
3389 @end lisp
3390
3391
3392 @subsection File attributes cache.
3393
3394 Keeping a local cache of remote file attributes in sync with the
3395 remote host is a time-consuming operation. Flushing and re-querying
3396 these attributes can tax @value{tramp} to a grinding halt on busy
3397 remote servers.
3398
3399 To get around these types of slow-downs in @value{tramp}'s
3400 responsiveness, set the @code{process-file-side-effects} to @code{nil}
3401 to stop @value{tramp} from flushing the cache. This is helpful in
3402 situations where callers to @code{process-file} know there are no file
3403 attribute changes. The let-bind form to accomplish this:
3404
3405 @lisp
3406 (let (process-file-side-effects)
3407 @dots{})
3408 @end lisp
3409
3410 For asynchronous processes, @value{tramp} uses a process sentinel to
3411 flush file attributes cache. When callers to @code{start-file-process}
3412 know beforehand no file attribute changes are expected, then the
3413 process sentinel should be set to the default state. In cases where
3414 the caller defines its own process sentinel, @value{tramp}'s process
3415 sentinel is overwritten. The caller can still flush the file
3416 attributes cache in its process sentinel with this code:
3417
3418 @lisp
3419 (unless (memq (process-status proc) '(run open))
3420 (dired-uncache remote-directory))
3421 @end lisp
3422
3423 Since @value{tramp} traverses subdirectories starting with the
3424 root-directory, it is most likely sufficient to make the
3425 @code{default-directory} of the process buffer as the root directory.
3426
3427
3428 @node Traces and Profiles
3429 @chapter How to Customize Traces
3430
3431 @value{tramp} messages are raised with verbosity levels ranging from 0
3432 to 10. @value{tramp} does not display all messages; only those with a
3433 verbosity level less than or equal to @code{tramp-verbose}.
3434
3435 The verbosity levels are
3436
3437 @w{ 0} silent (no @value{tramp} messages at all)
3438 @*@indent @w{ 1} errors
3439 @*@indent @w{ 2} warnings
3440 @*@indent @w{ 3} connection to remote hosts (default verbosity)
3441 @*@indent @w{ 4} activities
3442 @*@indent @w{ 5} internal
3443 @*@indent @w{ 6} sent and received strings
3444 @*@indent @w{ 7} file caching
3445 @*@indent @w{ 8} connection properties
3446 @*@indent @w{ 9} test commands
3447 @*@indent @w{10} traces (huge)
3448
3449 With @code{tramp-verbose} greater than or equal to 4, messages are
3450 also written to a @value{tramp} debug buffer. Such debug buffers are
3451 essential to bug and problem analyses. For @value{tramp} bug reports,
3452 set the @code{tramp-verbose} level to 6 (@pxref{Bug Reports}).
3453
3454 The debug buffer is in
3455 @ifinfo
3456 @ref{Outline Mode, , , emacs}.
3457 @end ifinfo
3458 @ifnotinfo
3459 Outline Mode.
3460 @end ifnotinfo
3461 In this buffer, messages can be filtered by their level. To see
3462 messages up to verbosity level 5, enter @kbd{C-u 6 C-c C-q}.
3463 @ifinfo
3464 Other navigation keys are described in
3465 @ref{Outline Visibility, , , emacs}.
3466 @end ifinfo
3467
3468 @value{tramp} handles errors internally. But to get a Lisp backtrace,
3469 both the error and the signal have to be set as follows:
3470
3471 @lisp
3472 (setq debug-on-error t
3473 debug-on-signal t)
3474 @end lisp
3475
3476 To enable stepping through @value{tramp} function call traces, they
3477 have to be specifically enabled as shown in this code:
3478
3479 @lisp
3480 (require 'trace)
3481 (dolist (elt (all-completions "tramp-" obarray 'functionp))
3482 (trace-function-background (intern elt)))
3483 (untrace-function 'tramp-read-passwd)
3484 (untrace-function 'tramp-gw-basic-authentication)
3485 @end lisp
3486
3487 The buffer @file{*trace-output*} contains the output from the function
3488 call traces. Disable @code{tramp-read-passwd} and
3489 @code{tramp-gw-basic-authentication} to stop password strings from
3490 being written to @file{*trace-output*}.
3491
3492
3493 @node GNU Free Documentation License
3494 @appendix GNU Free Documentation License
3495 @include doclicense.texi
3496
3497
3498 @node Function Index
3499 @unnumbered Function Index
3500 @printindex fn
3501
3502
3503 @node Variable Index
3504 @unnumbered Variable Index
3505 @printindex vr
3506
3507
3508 @node Concept Index
3509 @unnumbered Concept Index
3510 @printindex cp
3511
3512 @bye
3513
3514 @c TODO
3515 @c
3516 @c * Say something about the .login and .profile files of the remote
3517 @c shells.
3518 @c * Explain how tramp.el works in principle: open a shell on a remote
3519 @c host and then send commands to it.
3520 @c * Consistent small or capitalized words especially in menus.
3521 @c * Make a unique declaration of @trampfn.