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