]> code.delx.au - gnu-emacs/blob - doc/misc/tramp.texi
* tramp.texi (all): Harmonize usage of "external method",
[gnu-emacs] / doc / misc / tramp.texi
1 \input texinfo @c -*-texinfo-*-
2 @setfilename ../../info/tramp
3 @c %**start of header
4 @settitle TRAMP User Manual
5 @setchapternewpage odd
6 @c %**end of header
7
8 @c This is *so* much nicer :)
9 @footnotestyle end
10
11 @c In the Tramp CVS, the version number is auto-frobbed from
12 @c configure.ac, so you should edit that file and run
13 @c "autoconf && ./configure" to change the version number.
14
15 @c Additionally, flags are set with respect to the Emacs flavor; and
16 @c depending whether Tramp is packaged into (X)Emacs, or standalone.
17
18 @include trampver.texi
19
20 @c Macro for formatting a filename according to the repective syntax.
21 @c xxx and yyy are auxiliary macros in order to omit leading and
22 @c trailing whitespace. Not very elegant, but I don't know it better.
23
24 @macro xxx {one}@c
25 @set \one\@c
26 @end macro
27
28 @macro yyy {one, two}@c
29 @xxx{x\one\}@c
30 @ifclear x@c
31 \one\@w{}\two\@c
32 @end ifclear
33 @clear x\one\@c
34 @end macro
35
36 @macro trampfn {method, user, host, localname}@c
37 @value{prefix}@yyy{\method\,@value{postfixhop}}@yyy{\user\,@@}\host\@value{postfix}\localname\@c
38 @end macro
39
40 @copying
41 Copyright @copyright{} 1999, 2000, 2001, 2002, 2003, 2004, 2005,
42 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
43
44 @quotation
45 Permission is granted to copy, distribute and/or modify this document
46 under the terms of the GNU Free Documentation License, Version 1.3 or
47 any later version published by the Free Software Foundation; with no
48 Invariant Sections, with the Front-Cover texts being ``A GNU Manual'',
49 and with the Back-Cover Texts as in (a) below. A copy of the license
50 is included in the section entitled ``GNU Free Documentation License''.
51
52 (a) The FSF's Back-Cover Text is: ``You have the freedom to
53 copy and modify this GNU manual. Buying copies from the FSF
54 supports it in developing GNU and promoting software freedom.''
55 @end quotation
56 @end copying
57
58 @c Entries for @command{install-info} to use
59 @dircategory @value{emacsname}
60 @direntry
61 * TRAMP: (tramp). Transparent Remote Access, Multiple Protocol
62 @value{emacsname} remote file access via rsh and rcp.
63 @end direntry
64
65 @tex
66
67 @titlepage
68 @title @value{tramp} version @value{trampver} User Manual
69
70 @author by Daniel Pittman
71 @author based on documentation by Kai Gro@ss{}johann
72
73 @page
74 @insertcopying
75
76 @end titlepage
77 @page
78
79 @end tex
80
81 @ifnottex
82 @node Top, Overview, (dir), (dir)
83 @top @value{tramp} version @value{trampver} User Manual
84
85 This file documents @value{tramp} version @value{trampver}, a remote file
86 editing package for @value{emacsname}.
87
88 @value{tramp} stands for `Transparent Remote (file) Access, Multiple
89 Protocol'. This package provides remote file editing, similar to
90 @value{ftppackagename}.
91
92 The difference is that @value{ftppackagename} uses FTP to transfer
93 files between the local and the remote host, whereas @value{tramp} uses a
94 combination of @command{rsh} and @command{rcp} or other work-alike
95 programs, such as @command{ssh}/@command{scp}.
96
97 You can find the latest version of this document on the web at
98 @uref{http://www.gnu.org/software/tramp/}.
99
100 @c Pointer to the other Emacs flavor is necessary only in case of
101 @c standalone installation.
102 @ifset installchapter
103 The manual has been generated for @value{emacsname}.
104 @ifinfo
105 If you want to read the info pages for @value{emacsothername}, you
106 should read in @ref{Installation} how to create them.
107 @end ifinfo
108 @ifhtml
109 If you're using the other Emacs flavor, you should read the
110 @uref{@value{emacsotherfilename}, @value{emacsothername}} pages.
111 @end ifhtml
112 @end ifset
113
114 @ifhtml
115 @ifset jamanual
116 This manual is also available as a @uref{@value{japanesemanual},
117 Japanese translation}.
118 @end ifset
119
120 The latest release of @value{tramp} is available for
121 @uref{ftp://ftp.gnu.org/gnu/tramp/, download}, or you may see
122 @ref{Obtaining Tramp} for more details, including the CVS server
123 details.
124
125 @value{tramp} also has a @uref{http://savannah.gnu.org/projects/tramp/,
126 Savannah Project Page}.
127 @end ifhtml
128
129 There is a mailing list for @value{tramp}, available at
130 @email{tramp-devel@@gnu.org}, and archived at
131 @uref{http://lists.gnu.org/archive/html/tramp-devel/, the
132 @value{tramp} Mail Archive}.
133 @ifhtml
134 Older archives are located at
135 @uref{http://sourceforge.net/mailarchive/forum.php?forum=tramp-devel,
136 SourceForge Mail Archive} and
137 @uref{http://www.mail-archive.com/emacs-rcp@@ls6.cs.uni-dortmund.de/,
138 The Mail Archive}.
139 @c in HTML output, there's no new paragraph.
140 @*@*
141 @end ifhtml
142
143 @insertcopying
144
145 @end ifnottex
146
147 @menu
148 * Overview:: What @value{tramp} can and cannot do.
149
150 For the end user:
151
152 * Obtaining Tramp:: How to obtain @value{tramp}.
153 * History:: History of @value{tramp}.
154 @ifset installchapter
155 * Installation:: Installing @value{tramp} with your @value{emacsname}.
156 @end ifset
157 * Configuration:: Configuring @value{tramp} for use.
158 * Usage:: An overview of the operation of @value{tramp}.
159 * Bug Reports:: Reporting Bugs and Problems.
160 * Frequently Asked Questions:: Questions and answers from the mailing list.
161 * Function Index:: @value{tramp} functions.
162 * Variable Index:: User options and variables.
163 * Concept Index:: An item for each concept.
164
165 For the developer:
166
167 * Version Control:: The inner workings of remote version control.
168 * Files directories and localnames:: How file names, directories and localnames are mangled and managed.
169 * Traces and Profiles:: How to Customize Traces.
170 * Issues:: Debatable Issues and What Was Decided.
171
172 * GNU Free Documentation License:: The license for this documentation.
173
174 @detailmenu
175 --- The Detailed Node Listing ---
176 @c
177 @ifset installchapter
178 Installing @value{tramp} with your @value{emacsname}
179
180 * Installation parameters:: Parameters in order to control installation.
181 * Load paths:: How to plug-in @value{tramp} into your environment.
182 * Japanese manual:: Japanese manual.
183
184 @end ifset
185
186 Configuring @value{tramp} for use
187
188 * Connection types:: Types of connections made to remote machines.
189 * Inline methods:: Inline methods.
190 * External methods:: External methods.
191 @ifset emacsgw
192 * Gateway methods:: Gateway methods.
193 @end ifset
194 * Default Method:: Selecting a default method.
195 * Default User:: Selecting a default user.
196 * Default Host:: Selecting a default host.
197 * Multi-hops:: Connecting to a remote host using multiple hops.
198 * Customizing Methods:: Using Non-Standard Methods.
199 * Customizing Completion:: Selecting config files for user/host name completion.
200 * Password handling:: Reusing passwords for several connections.
201 * Connection caching:: Reusing connection related information.
202 * Remote Programs:: How @value{tramp} finds and uses programs on the remote machine.
203 * Remote shell setup:: Remote shell setup hints.
204 * Windows setup hints:: Issues with Cygwin ssh.
205 * Auto-save and Backup:: Auto-save and Backup.
206
207 Using @value{tramp}
208
209 * Filename Syntax:: @value{tramp} filename conventions.
210 * Alternative Syntax:: URL-like filename syntax.
211 * Filename completion:: Filename completion.
212 * Remote processes:: Integration with other @value{emacsname} packages.
213 * Cleanup remote connections:: Cleanup remote connections.
214
215 The inner workings of remote version control
216
217 * Version Controlled Files:: Determining if a file is under version control.
218 * Remote Commands:: Executing the version control commands on the remote machine.
219 * Changed workfiles:: Detecting if the working file has changed.
220 * Checking out files:: Bringing the workfile out of the repository.
221 * Miscellaneous Version Control:: Things related to Version Control that don't fit elsewhere.
222
223 Things related to Version Control that don't fit elsewhere
224
225 * Remote File Ownership:: How VC determines who owns a workfile.
226 * Back-end Versions:: How VC determines what release your RCS is.
227
228 How file names, directories and localnames are mangled and managed
229
230 * Localname deconstruction:: Breaking a localname into its components.
231 @ifset emacs
232 * External packages:: Integration with external Lisp packages.
233 @end ifset
234
235 @end detailmenu
236 @end menu
237
238 @node Overview
239 @chapter An overview of @value{tramp}
240 @cindex overview
241
242 After the installation of @value{tramp} into your @value{emacsname}, you
243 will be able to access files on remote machines as though they were
244 local. Access to the remote file system for editing files, version
245 control, and @code{dired} are transparently enabled.
246
247 Your access to the remote machine can be with the @command{rsh},
248 @command{rlogin}, @command{telnet} programs or with any similar
249 connection method. This connection must pass @acronym{ASCII}
250 successfully to be usable but need not be 8-bit clean.
251
252 The package provides support for @command{ssh} connections out of the
253 box, one of the more common uses of the package. This allows
254 relatively secure access to machines, especially if @command{ftp}
255 access is disabled.
256
257 Under Windows, @value{tramp} is integrated with the PuTTY package,
258 using the @command{plink} program.
259
260 The majority of activity carried out by @value{tramp} requires only that
261 the remote login is possible and is carried out at the terminal. In
262 order to access remote files @value{tramp} needs to transfer their content
263 to the local machine temporarily.
264
265 @value{tramp} can transfer files between the machines in a variety of ways.
266 The details are easy to select, depending on your needs and the
267 machines in question.
268
269 The fastest transfer methods for large files rely on a remote file
270 transfer package such as @command{rcp}, @command{scp}, @command{rsync}
271 or (under Windows) @command{pscp}.
272
273 If the remote copy methods are not suitable for you, @value{tramp} also
274 supports the use of encoded transfers directly through the shell.
275 This requires that the @command{mimencode} or @command{uuencode} tools
276 are available on the remote machine. These methods are generally
277 faster for small files.
278
279 @value{tramp} is still under active development and any problems you encounter,
280 trivial or major, should be reported to the @value{tramp} developers.
281 @xref{Bug Reports}.
282
283
284 @subsubheading Behind the scenes
285 @cindex behind the scenes
286 @cindex details of operation
287 @cindex how it works
288
289 This section tries to explain what goes on behind the scenes when you
290 access a remote file through @value{tramp}.
291
292 Suppose you type @kbd{C-x C-f} and enter part of an @value{tramp} file name,
293 then hit @kbd{@key{TAB}} for completion. Suppose further that this is
294 the first time that @value{tramp} is invoked for the host in question. Here's
295 what happens:
296
297 @itemize
298 @item
299 @value{tramp} discovers that it needs a connection to the host. So it
300 invokes @samp{telnet @var{host}} or @samp{rsh @var{host} -l
301 @var{user}} or a similar tool to connect to the remote host.
302 Communication with this process happens through an
303 @value{emacsname} buffer, that is, the output from the remote end
304 goes into a buffer.
305
306 @item
307 The remote host may prompt for a login name (for @command{telnet}).
308 The login name is given in the file name, so @value{tramp} sends the
309 login name and a newline.
310
311 @item
312 The remote host may prompt for a password or pass phrase (for
313 @command{rsh} or for @command{telnet} after sending the login name).
314 @value{tramp} displays the prompt in the minibuffer, asking you for the
315 password or pass phrase.
316
317 You enter the password or pass phrase. @value{tramp} sends it to the remote
318 host, followed by a newline.
319
320 @item
321 @value{tramp} now waits for the shell prompt or for a message that the login
322 failed.
323
324 If @value{tramp} sees neither of them after a certain period of time
325 (a minute, say), then it issues an error message saying that it
326 couldn't find the remote shell prompt and shows you what the remote
327 host has sent.
328
329 If @value{tramp} sees a @samp{login failed} message, it tells you so,
330 aborts the login attempt and allows you to try again.
331
332 @item
333 Suppose that the login was successful and @value{tramp} sees the shell prompt
334 from the remote host. Now @value{tramp} invokes @command{/bin/sh} because
335 Bourne shells and C shells have different command
336 syntaxes.@footnote{Invoking @command{/bin/sh} will fail if your login
337 shell doesn't recognize @samp{exec /bin/sh} as a valid command.
338 Maybe you use the Scheme shell @command{scsh}@dots{}}
339
340 After the Bourne shell has come up, @value{tramp} sends a few commands to
341 ensure a good working environment. It turns off echoing, it sets the
342 shell prompt, and a few other things.
343
344 @item
345 Now the remote shell is up and it good working order. Remember, what
346 was supposed to happen is that @value{tramp} tries to find out what files exist
347 on the remote host so that it can do filename completion.
348
349 So, @value{tramp} basically issues @command{cd} and @command{ls} commands and
350 also sometimes @command{echo} with globbing. Another command that is
351 often used is @command{test} to find out whether a file is writable or a
352 directory or the like. The output of each command is parsed for the
353 necessary operation.
354
355 @item
356 Suppose you are finished with filename completion, have entered @kbd{C-x
357 C-f}, a full file name and hit @kbd{@key{RET}}. Now comes the time to
358 transfer the file contents from the remote host to the local host so
359 that you can edit them.
360
361 See above for an explanation of how @value{tramp} transfers the file contents.
362
363 For inline transfers, @value{tramp} issues a command like @samp{mimencode -b
364 /path/to/remote/file}, waits until the output has accumulated in the
365 buffer that's used for communication, then decodes that output to
366 produce the file contents.
367
368 For external transfers, @value{tramp} issues a command like the
369 following:
370 @example
371 rcp user@@host:/path/to/remote/file /tmp/tramp.4711
372 @end example
373 It then reads the local temporary file @file{/tmp/tramp.4711} into a
374 buffer and deletes the temporary file.
375
376 @item
377 You now edit the buffer contents, blithely unaware of what has happened
378 behind the scenes. (Unless you have read this section, that is.) When
379 you are finished, you type @kbd{C-x C-s} to save the buffer.
380
381 @item
382 Again, @value{tramp} transfers the file contents to the remote host
383 either inline or external. This is the reverse of what happens when
384 reading the file.
385 @end itemize
386
387 I hope this has provided you with a basic overview of what happens
388 behind the scenes when you open a file with @value{tramp}.
389
390
391 @c For the end user
392 @node Obtaining Tramp
393 @chapter Obtaining Tramp.
394 @cindex obtaining Tramp
395
396 @value{tramp} is freely available on the Internet and the latest
397 release may be downloaded from
398 @uref{ftp://ftp.gnu.org/gnu/tramp/}. This release includes the full
399 documentation and code for @value{tramp}, suitable for installation.
400 But GNU Emacs (22 or later) includes @value{tramp} already, and there
401 is a @value{tramp} package for XEmacs, as well. So maybe it is easier
402 to just use those. But if you want the bleeding edge, read
403 on@dots{...}
404
405 For the especially brave, @value{tramp} is available from CVS. The CVS
406 version is the latest version of the code and may contain incomplete
407 features or new issues. Use these versions at your own risk.
408
409 Instructions for obtaining the latest development version of @value{tramp}
410 from CVS can be found by going to the Savannah project page at the
411 following URL and then clicking on the CVS link in the navigation bar
412 at the top.
413
414 @noindent
415 @uref{http://savannah.gnu.org/projects/tramp/}
416
417 @noindent
418 Or follow the example session below:
419
420 @example
421 ] @strong{cd ~/@value{emacsdir}}
422 ] @strong{export CVS_RSH="ssh"}
423 ] @strong{cvs -z3 -d:ext:anoncvs@@savannah.gnu.org:/cvsroot/tramp co tramp}
424 @end example
425
426 @noindent
427 You should now have a directory @file{~/@value{emacsdir}/tramp}
428 containing the latest version of @value{tramp}. You can fetch the latest
429 updates from the repository by issuing the command:
430
431 @example
432 ] @strong{cd ~/@value{emacsdir}/tramp}
433 ] @strong{export CVS_RSH="ssh"}
434 ] @strong{cvs update -d}
435 @end example
436
437 @noindent
438 Once you've got updated files from the CVS repository, you need to run
439 @command{autoconf} in order to get an up-to-date @file{configure}
440 script:
441
442 @example
443 ] @strong{cd ~/@value{emacsdir}/tramp}
444 ] @strong{autoconf}
445 @end example
446
447 People who have no direct CVS access (maybe because sitting behind a
448 blocking firewall), can try the
449 @uref{http://savannah.gnu.org/cvs-backup/tramp-sources.tar.gz, Nightly
450 CVS Tree Tarball} instead of.
451
452
453 @node History
454 @chapter History of @value{tramp}
455 @cindex history
456 @cindex development history
457
458 Development was started end of November 1998. The package was called
459 @file{rssh.el}, back then. It only provided one method to access a
460 file, using @command{ssh} to log in to a remote host and using
461 @command{scp} to transfer the file contents. After a while, the name
462 was changed to @file{rcp.el}, and now it's @value{tramp}. Along the way,
463 many more methods for getting a remote shell and for transferring the
464 file contents were added. Support for VC was added.
465
466 The most recent addition of major features were the multi-hop methods
467 added in April 2000 and the unification of @value{tramp} and Ange-FTP
468 filenames in July 2002. In July 2004, multi-hop methods have been
469 replaced by proxy hosts. Running commands on remote hosts was
470 introduced in December 2005.
471 @ifset emacsgw
472 Support of gateways exists since April 2007.
473 @end ifset
474
475 In December 2001, @value{tramp} has been added to the XEmacs package
476 repository. Being part of the GNU Emacs repository happened in June
477 2002, the first release including @value{tramp} was GNU Emacs 22.1.
478
479 @value{tramp} is also a GNU/Linux Debian package since February 2001.
480
481
482 @c Installation chapter is necessary only in case of standalone
483 @c installation. Text taken from trampinst.texi.
484 @ifset installchapter
485 @include trampinst.texi
486 @end ifset
487
488 @node Configuration
489 @chapter Configuring @value{tramp} for use
490 @cindex configuration
491
492 @cindex default configuration
493 @value{tramp} is (normally) fully functional when it is initially
494 installed. It is initially configured to use the @command{scp}
495 program to connect to the remote host. So in the easiest case, you
496 just type @kbd{C-x C-f} and then enter the filename
497 @file{@trampfn{, user, machine, /path/to.file}}.
498
499 On some hosts, there are problems with opening a connection. These are
500 related to the behavior of the remote shell. See @xref{Remote shell
501 setup}, for details on this.
502
503 If you do not wish to use these commands to connect to the remote
504 host, you should change the default connection and transfer method
505 that @value{tramp} uses. There are several different methods that @value{tramp}
506 can use to connect to remote machines and transfer files
507 (@pxref{Connection types}).
508
509 If you don't know which method is right for you, see @xref{Default
510 Method}.
511
512
513 @menu
514 * Connection types:: Types of connections made to remote machines.
515 * Inline methods:: Inline methods.
516 * External methods:: External methods.
517 @ifset emacsgw
518 * Gateway methods:: Gateway methods.
519 @end ifset
520 * Default Method:: Selecting a default method.
521 Here we also try to help those who
522 don't have the foggiest which method
523 is right for them.
524 * Default User:: Selecting a default user.
525 * Default Host:: Selecting a default host.
526 * Multi-hops:: Connecting to a remote host using multiple hops.
527 * Customizing Methods:: Using Non-Standard Methods.
528 * Customizing Completion:: Selecting config files for user/host name completion.
529 * Password handling:: Reusing passwords for several connections.
530 * Connection caching:: Reusing connection related information.
531 * Remote Programs:: How @value{tramp} finds and uses programs on the remote machine.
532 * Remote shell setup:: Remote shell setup hints.
533 * Windows setup hints:: Issues with Cygwin ssh.
534 * Auto-save and Backup:: Auto-save and Backup.
535 @end menu
536
537
538 @node Connection types
539 @section Types of connections made to remote machines.
540 @cindex connection types, overview
541
542 There are two basic types of transfer methods, each with its own
543 advantages and limitations. Both types of connection make use of a
544 remote shell access program such as @command{rsh}, @command{ssh} or
545 @command{telnet} to connect to the remote machine.
546
547 This connection is used to perform many of the operations that @value{tramp}
548 requires to make the remote file system transparently accessible from
549 the local machine. It is only when visiting files that the methods
550 differ.
551
552 @cindex inline methods
553 @cindex external methods
554 @cindex methods, inline
555 @cindex methods, external
556 Loading or saving a remote file requires that the content of the file
557 be transfered between the two machines. The content of the file can
558 be transfered using one of two methods: the @dfn{inline method} over
559 the same connection used to log in to the remote machine, or the
560 @dfn{external method} through another connection using a remote copy
561 program such as @command{rcp}, @command{scp} or @command{rsync}.
562
563 The performance of the external methods is generally better than that
564 of the inline methods, at least for large files. This is caused by
565 the need to encode and decode the data when transferring inline.
566
567 The one exception to this rule are the @command{scp} based transfer
568 methods. While these methods do see better performance when actually
569 transferring files, the overhead of the cryptographic negotiation at
570 startup may drown out the improvement in file transfer times.
571
572 External methods should be configured such a way that they don't
573 require a password (with @command{ssh-agent}, or such alike). Modern
574 @command{scp} implementations offer options to reuse existing
575 @command{ssh} connections, see method @command{scpc}. If it isn't
576 possible, you should consider @ref{Password handling}, otherwise you
577 will be prompted for a password every copy action.
578
579
580 @node Inline methods
581 @section Inline methods
582 @cindex inline methods
583 @cindex methods, inline
584
585 The inline methods in @value{tramp} are quite powerful and can work in
586 situations where you cannot use an external transfer program to connect.
587 Inline methods are the only methods that work when connecting to the
588 remote machine via telnet. (There are also strange inline methods which
589 allow you to transfer files between @emph{user identities} rather than
590 hosts, see below.)
591
592 These methods depend on the existence of a suitable encoding and
593 decoding command on remote machine. Locally, @value{tramp} may be able to
594 use features of @value{emacsname} to decode and encode the files or
595 it may require access to external commands to perform that task.
596
597 @cindex uuencode
598 @cindex mimencode
599 @cindex base-64 encoding
600 @value{tramp} checks the availability and usability of commands like
601 @command{mimencode} (part of the @command{metamail} package) or
602 @command{uuencode} on the remote host. The first reliable command
603 will be used. The search path can be customized, see @ref{Remote
604 Programs}.
605
606 If both commands aren't available on the remote host, @value{tramp}
607 transfers a small piece of Perl code to the remote host, and tries to
608 apply it for encoding and decoding.
609
610
611 @table @asis
612 @item @option{rsh}
613 @cindex method rsh
614 @cindex rsh method
615
616 Connect to the remote host with @command{rsh}. Due to the unsecure
617 connection it is recommended for very local host topology only.
618
619 On operating systems which provide the command @command{remsh} instead
620 of @command{rsh}, you can use the method @option{remsh}. This is true
621 for HP-UX or Cray UNICOS, for example.
622
623
624 @item @option{ssh}
625 @cindex method ssh
626 @cindex ssh method
627
628 Connect to the remote host with @command{ssh}. This is identical to
629 the previous option except that the @command{ssh} package is used,
630 making the connection more secure.
631
632 There are also two variants, @option{ssh1} and @option{ssh2}, that
633 call @samp{ssh -1} and @samp{ssh -2}, respectively. This way, you can
634 explicitly select whether you want to use the SSH protocol version 1
635 or 2 to connect to the remote host. (You can also specify in
636 @file{~/.ssh/config}, the SSH configuration file, which protocol
637 should be used, and use the regular @option{ssh} method.)
638
639 Two other variants, @option{ssh1_old} and @option{ssh2_old}, use the
640 @command{ssh1} and @command{ssh2} commands explicitly. If you don't
641 know what these are, you do not need these options.
642
643 All the methods based on @command{ssh} have an additional kludgy
644 feature: you can specify a host name which looks like @file{host#42}
645 (the real host name, then a hash sign, then a port number). This
646 means to connect to the given host but to also pass @code{-p 42} as
647 arguments to the @command{ssh} command.
648
649
650 @item @option{telnet}
651 @cindex method telnet
652 @cindex telnet method
653
654 Connect to the remote host with @command{telnet}. This is as unsecure
655 as the @option{rsh} method.
656
657
658 @item @option{su}
659 @cindex method su
660 @cindex su method
661
662 This method does not connect to a remote host at all, rather it uses
663 the @command{su} program to allow you to edit files as another user.
664 That means, the specified host name in the file name must be either
665 @samp{localhost} or the host name as returned by the function
666 @command{(system-name)}. For an exception of this rule see
667 @ref{Multi-hops}.
668
669
670 @item @option{sudo}
671 @cindex method sudo
672 @cindex sudo method
673
674 This is similar to the @option{su} method, but it uses @command{sudo}
675 rather than @command{su} to become a different user.
676
677 Note that @command{sudo} must be configured to allow you to start a
678 shell as the user. It would be nice if it was sufficient if
679 @command{ls} and @command{mimencode} were allowed, but that is not
680 easy to implement, so I haven't got around to it, yet.
681
682
683 @item @option{sshx}
684 @cindex method sshx
685 @cindex sshx method
686
687 As you would expect, this is similar to @option{ssh}, only a little
688 different. Whereas @option{ssh} opens a normal interactive shell on
689 the remote host, this option uses @samp{ssh -t -t @var{host} -l
690 @var{user} /bin/sh} to open a connection. This is useful for users
691 where the normal login shell is set up to ask them a number of
692 questions when logging in. This procedure avoids these questions, and
693 just gives @value{tramp} a more-or-less `standard' login shell to work
694 with.
695
696 Note that this procedure does not eliminate questions asked by
697 @command{ssh} itself. For example, @command{ssh} might ask ``Are you
698 sure you want to continue connecting?'' if the host key of the remote
699 host is not known. @value{tramp} does not know how to deal with such a
700 question (yet), therefore you will need to make sure that you can log
701 in without such questions.
702
703 This is also useful for Windows users where @command{ssh}, when
704 invoked from an @value{emacsname} buffer, tells them that it is not
705 allocating a pseudo tty. When this happens, the login shell is wont
706 to not print any shell prompt, which confuses @value{tramp} mightily.
707 For reasons unknown, some Windows ports for @command{ssh} require the
708 doubled @samp{-t} option.
709
710 This supports the @samp{-p} kludge.
711
712
713 @item @option{krlogin}
714 @cindex method krlogin
715 @cindex krlogin method
716 @cindex Kerberos (with krlogin method)
717
718 This method is also similar to @option{ssh}. It only uses the
719 @command{krlogin -x} command to log in to the remote host.
720
721
722 @item @option{plink}
723 @cindex method plink
724 @cindex plink method
725
726 This method is mostly interesting for Windows users using the PuTTY
727 implementation of SSH. It uses @samp{plink -ssh} to log in to the
728 remote host.
729
730 This supports the @samp{-P} kludge.
731
732 Additionally, the methods @option{plink1} and @option{plink2} are
733 provided, which call @samp{plink -1 -ssh} or @samp{plink -2 -ssh} in
734 order to use SSH protocol version 1 or 2 explicitly.
735
736 CCC: Do we have to connect to the remote host once from the command
737 line to accept the SSH key? Maybe this can be made automatic?
738
739 CCC: Say something about the first shell command failing. This might
740 be due to a wrong setting of @code{tramp-rsh-end-of-line}.
741
742
743 @item @option{plinkx}
744 @cindex method plinkx
745 @cindex plinkx method
746
747 Another method using PuTTY on Windows. Instead of host names, it
748 expects PuTTY session names, calling @samp{plink -load @var{session}
749 -t"}. User names are relevant only in case the corresponding session
750 hasn't defined a user name. Different port numbers must be defined in
751 the session.
752
753
754 @item @option{fish}
755 @cindex method fish
756 @cindex fish method
757
758 This is an experimental implementation of the fish protocol, known from
759 the GNU Midnight Commander or the KDE Konqueror. @value{tramp} expects
760 the fish server implementation from the KDE kioslave. That means, the
761 file @file{~/.fishsrv.pl} is expected to reside on the remote host.
762
763 The implementation lacks good performance. The code is offered anyway,
764 maybe somebody can improve the performance.
765
766 @end table
767
768
769 @node External methods
770 @section External methods
771 @cindex methods, external
772 @cindex external methods
773
774 The external methods operate through multiple channels, using the
775 remote shell connection for many actions while delegating file
776 transfers to an external transfer utility.
777
778 This saves the overhead of encoding and decoding that multiplexing the
779 transfer through the one connection has with the inline methods.
780
781 Since external methods need their own overhead opening a new channel,
782 all files which are smaller than @var{tramp-copy-size-limit} are still
783 transferred with the corresponding inline method. It should provide a
784 fair trade-off between both approaches.
785
786 @table @asis
787 @item @option{rcp} --- @command{rsh} and @command{rcp}
788 @cindex method rcp
789 @cindex rcp method
790 @cindex rcp (with rcp method)
791 @cindex rsh (with rcp method)
792
793 This method uses the @command{rsh} and @command{rcp} commands to connect
794 to the remote machine and transfer files. This is probably the fastest
795 connection method available.
796
797 The alternative method @option{remcp} uses the @command{remsh} and
798 @command{rcp} commands. It should be applied on machines where
799 @command{remsh} is used instead of @command{rsh}.
800
801
802 @item @option{scp} --- @command{ssh} and @command{scp}
803 @cindex method scp
804 @cindex scp method
805 @cindex scp (with scp method)
806 @cindex ssh (with scp method)
807
808 Using @command{ssh} to connect to the remote host and @command{scp} to
809 transfer files between the machines is the best method for securely
810 connecting to a remote machine and accessing files.
811
812 The performance of this option is also quite good. It may be slower than
813 the inline methods when you often open and close small files however.
814 The cost of the cryptographic handshake at the start of an @command{scp}
815 session can begin to absorb the advantage that the lack of encoding and
816 decoding presents.
817
818 There are also two variants, @option{scp1} and @option{scp2}, that
819 call @samp{ssh -1} and @samp{ssh -2}, respectively. This way, you can
820 explicitly select whether you want to use the SSH protocol version 1
821 or 2 to connect to the remote host. (You can also specify in
822 @file{~/.ssh/config}, the SSH configuration file, which protocol
823 should be used, and use the regular @option{scp} method.)
824
825 Two other variants, @option{scp1_old} and @option{scp2_old}, use the
826 @command{ssh1} and @command{ssh2} commands explicitly. If you don't
827 know what these are, you do not need these options.
828
829 All the @command{ssh} based methods support the kludgy @samp{-p}
830 feature where you can specify a port number to connect to in the host
831 name. For example, the host name @file{host#42} tells @value{tramp} to
832 specify @samp{-p 42} in the argument list for @command{ssh}, and to
833 specify @samp{-P 42} in the argument list for @command{scp}.
834
835
836 @item @option{sftp} --- @command{ssh} and @command{sftp}
837 @cindex method sftp
838 @cindex sftp method
839 @cindex sftp (with sftp method)
840 @cindex ssh (with sftp method)
841
842 That is mostly the same method as @option{scp}, but using
843 @command{sftp} as transfer command. So the same remarks are valid.
844
845 This command does not work like @value{ftppackagename}, where
846 @command{ftp} is called interactively, and all commands are send from
847 within this session. Instead of, @command{ssh} is used for login.
848
849 This method supports the @samp{-p} hack.
850
851
852 @item @option{rsync} --- @command{ssh} and @command{rsync}
853 @cindex method rsync
854 @cindex rsync method
855 @cindex rsync (with rsync method)
856 @cindex ssh (with rsync method)
857
858 Using the @command{ssh} command to connect securely to the remote
859 machine and the @command{rsync} command to transfer files is almost
860 identical to the @option{scp} method.
861
862 While @command{rsync} performs much better than @command{scp} when
863 transferring files that exist on both hosts, this advantage is lost if
864 the file exists only on one side of the connection.
865
866 The @command{rsync} based method may be considerably faster than the
867 @command{rcp} based methods when writing to the remote system. Reading
868 files to the local machine is no faster than with a direct copy.
869
870 This method supports the @samp{-p} hack.
871
872
873 @item @option{scpx} --- @command{ssh} and @command{scp}
874 @cindex method scpx
875 @cindex scpx method
876 @cindex scp (with scpx method)
877 @cindex ssh (with scpx method)
878
879 As you would expect, this is similar to @option{scp}, only a little
880 different. Whereas @option{scp} opens a normal interactive shell on
881 the remote host, this option uses @samp{ssh -t -t @var{host} -l
882 @var{user} /bin/sh} to open a connection. This is useful for users
883 where the normal login shell is set up to ask them a number of
884 questions when logging in. This procedure avoids these questions, and
885 just gives @value{tramp} a more-or-less `standard' login shell to work
886 with.
887
888 This is also useful for Windows users where @command{ssh}, when
889 invoked from an @value{emacsname} buffer, tells them that it is not
890 allocating a pseudo tty. When this happens, the login shell is wont
891 to not print any shell prompt, which confuses @value{tramp} mightily.
892
893 This method supports the @samp{-p} hack.
894
895
896 @item @option{scpc} --- @command{ssh} and @command{scp}
897 @cindex method scpx
898 @cindex scpx method
899 @cindex scp (with scpx method)
900 @cindex ssh (with scpx method)
901
902 Newer versions of @option{ssh} (for example OpenSSH 4) offer an option
903 @option{ControlMaster}. This allows @option{scp} to reuse an existing
904 @option{ssh} channel, which increases performance.
905
906 Before you use this method, you shall check whether your @option{ssh}
907 implementation does support this option. Try from the command line
908
909 @example
910 ssh localhost -o ControlMaster=yes
911 @end example
912
913 This method supports the @samp{-p} hack.
914
915
916 @item @option{pscp} --- @command{plink} and @command{pscp}
917 @cindex method pscp
918 @cindex pscp method
919 @cindex pscp (with pscp method)
920 @cindex plink (with pscp method)
921 @cindex PuTTY (with pscp method)
922
923 This method is similar to @option{scp}, but it uses the
924 @command{plink} command to connect to the remote host, and it uses
925 @command{pscp} for transferring the files. These programs are part
926 of PuTTY, an SSH implementation for Windows.
927
928 This method supports the @samp{-P} hack.
929
930
931 @item @option{psftp} --- @command{plink} and @command{psftp}
932 @cindex method psftp
933 @cindex psftp method
934 @cindex psftp (with psftp method)
935 @cindex plink (with psftp method)
936 @cindex PuTTY (with psftp method)
937
938 As you would expect, this method is similar to @option{sftp}, but it
939 uses the @command{plink} command to connect to the remote host, and it
940 uses @command{psftp} for transferring the files. These programs are
941 part of PuTTY, an SSH implementation for Windows.
942
943 This method supports the @samp{-P} hack.
944
945
946 @item @option{fcp} --- @command{fsh} and @command{fcp}
947 @cindex method fcp
948 @cindex fcp method
949 @cindex fsh (with fcp method)
950 @cindex fcp (with fcp method)
951
952 This method is similar to @option{scp}, but it uses the @command{fsh}
953 command to connect to the remote host, and it uses @command{fcp} for
954 transferring the files. @command{fsh/fcp} are a front-end for
955 @command{ssh} which allow for reusing the same @command{ssh} session
956 for submitting several commands. This avoids the startup overhead of
957 @command{scp} (which has to establish a secure connection whenever it
958 is called). Note, however, that you can also use one of the inline
959 methods to achieve a similar effect.
960
961 This method uses the command @samp{fsh @var{host} -l @var{user}
962 /bin/sh -i} to establish the connection, it does not work to just say
963 @command{fsh @var{host} -l @var{user}}.
964
965 @cindex method fsh
966 @cindex fsh method
967
968 There is no inline method using @command{fsh} as the multiplexing
969 provided by the program is not very useful in our context. @value{tramp}
970 opens just one connection to the remote host and then keeps it open,
971 anyway.
972
973
974 @item @option{ftp}
975 @cindex method ftp
976 @cindex ftp method
977
978 This is not a native @value{tramp} method. Instead of, it forwards all
979 requests to @value{ftppackagename}.
980 @ifset xemacs
981 This works only for unified filenames, see @ref{Issues}.
982 @end ifset
983
984
985 @item @option{smb} --- @command{smbclient}
986 @cindex method smb
987 @cindex smb method
988
989 This is another not natural @value{tramp} method. It uses the
990 @command{smbclient} command on different Unices in order to connect to
991 an SMB server. An SMB server might be a Samba (or CIFS) server on
992 another UNIX host or, more interesting, a host running MS Windows. So
993 far, it is tested towards MS Windows NT, MS Windows 2000, and MS
994 Windows XP.
995
996 The first directory in the localname must be a share name on the remote
997 host. Remember, that the @code{$} character in which default shares
998 usually end, must be written @code{$$} due to environment variable
999 substitution in file names. If no share name is given (i.e. remote
1000 directory @code{/}), all available shares are listed.
1001
1002 Since authorization is done on share level, you will be prompted
1003 always for a password if you access another share on the same host.
1004 This can be suppressed by @ref{Password handling}.
1005
1006 MS Windows uses for authorization both a user name and a domain name.
1007 Because of this, the @value{tramp} syntax has been extended: you can
1008 specify a user name which looks like @code{user%domain} (the real user
1009 name, then a percent sign, then the domain name). So, to connect to
1010 the machine @code{melancholia} as user @code{daniel} of the domain
1011 @code{BIZARRE}, and edit @file{.emacs} in the home directory (share
1012 @code{daniel$}) I would specify the filename @file{@trampfn{smb,
1013 daniel%BIZARRE, melancholia, /daniel$$/.emacs}}.
1014
1015 Depending on the Windows domain configuration, a Windows user might be
1016 considered as domain user per default. In order to connect as local
1017 user, the WINS name of that machine must be given as domain name.
1018 Usually, it is the machine name in capital letters. In the example
1019 above, the local user @code{daniel} would be specified as
1020 @file{@trampfn{smb, daniel%MELANCHOLIA, melancholia, /daniel$$/.emacs}}.
1021
1022 The domain name as well as the user name are optional. If no user
1023 name is specified at all, the anonymous user (without password
1024 prompting) is assumed. This is different from all other @value{tramp}
1025 methods, where in such a case the local user name is taken.
1026
1027 The @option{smb} method supports the @samp{-p} hack.
1028
1029 @strong{Please note:} If @value{emacsname} runs locally under MS
1030 Windows, this method isn't available. Instead of, you can use UNC
1031 file names like @file{//melancholia/daniel$$/.emacs}. The only
1032 disadvantage is that there's no possibility to specify another user
1033 name.
1034
1035 @end table
1036
1037
1038 @ifset emacsgw
1039 @node Gateway methods
1040 @section Gateway methods
1041 @cindex methods, gateway
1042 @cindex gateway methods
1043
1044 Gateway methods are not methods to access a remote host directly.
1045 These methods are intended to pass firewalls or proxy servers.
1046 Therefore, they can be used for proxy host declarations
1047 (@pxref{Multi-hops}) only.
1048
1049 A gateway method must come always along with a method who supports
1050 port setting (referred to as @samp{-p} kludge). This is because
1051 @value{tramp} targets the accompanied method to
1052 @file{localhost#random_port}, from where the firewall or proxy server
1053 is accessed to.
1054
1055 Gateway methods support user name and password declarations. These
1056 are used to authenticate towards the corresponding firewall or proxy
1057 server. They can be passed only if your friendly administrator has
1058 granted your access.
1059
1060 @table @asis
1061 @item @option{tunnel}
1062 @cindex method tunnel
1063 @cindex tunnel method
1064
1065 This method implements an HTTP tunnel via the @command{CONNECT}
1066 command (see RFC 2616, 2817). Any HTTP 1.1 compliant (proxy) server
1067 shall support this command.
1068
1069 As authentication method, only @option{Basic Authentication} (see RFC
1070 2617) is implemented so far. If no port number is given in the
1071 declaration, port @option{8080} is used for the proxy server.
1072
1073
1074 @item @option{socks}
1075 @cindex method socks
1076 @cindex socks method
1077
1078 The @command{socks} method provides access to SOCKSv5 servers (see
1079 RFC 1928). @option{Username/Password Authentication} according to RFC
1080 1929 is supported.
1081
1082 The default port number of the socks server is @option{1080}, if not
1083 specified otherwise.
1084
1085 @end table
1086 @end ifset
1087
1088
1089 @node Default Method
1090 @section Selecting a default method
1091 @cindex default method
1092
1093 @vindex tramp-default-method
1094 When you select an appropriate transfer method for your typical usage
1095 you should set the variable @code{tramp-default-method} to reflect that
1096 choice. This variable controls which method will be used when a method
1097 is not specified in the @value{tramp} file name. For example:
1098
1099 @lisp
1100 (setq tramp-default-method "ssh")
1101 @end lisp
1102
1103 @vindex tramp-default-method-alist
1104 You can also specify different methods for certain user/host
1105 combinations, via the variable @code{tramp-default-method-alist}. For
1106 example, the following two lines specify to use the @option{ssh}
1107 method for all user names matching @samp{john} and the @option{rsync}
1108 method for all host names matching @samp{lily}. The third line
1109 specifies to use the @option{su} method for the user @samp{root} on
1110 the machine @samp{localhost}.
1111
1112 @lisp
1113 (add-to-list 'tramp-default-method-alist '("" "john" "ssh"))
1114 (add-to-list 'tramp-default-method-alist '("lily" "" "rsync"))
1115 (add-to-list 'tramp-default-method-alist
1116 '("\\`localhost\\'" "\\`root\\'" "su"))
1117 @end lisp
1118
1119 @noindent
1120 See the documentation for the variable
1121 @code{tramp-default-method-alist} for more details.
1122
1123 External methods are normally preferable to inline methods, giving
1124 better performance.
1125
1126 @xref{Inline methods}.
1127 @xref{External methods}.
1128
1129 Another consideration with the selection of transfer methods is the
1130 environment you will use them in and, especially when used over the
1131 Internet, the security implications of your preferred method.
1132
1133 The @option{rsh} and @option{telnet} methods send your password as
1134 plain text as you log in to the remote machine, as well as
1135 transferring the files in such a way that the content can easily be
1136 read from other machines.
1137
1138 If you need to connect to remote systems that are accessible from the
1139 Internet, you should give serious thought to using @option{ssh} based
1140 methods to connect. These provide a much higher level of security,
1141 making it a non-trivial exercise for someone to obtain your password
1142 or read the content of the files you are editing.
1143
1144
1145 @subsection Which method is the right one for me?
1146 @cindex choosing the right method
1147
1148 Given all of the above, you are probably thinking that this is all fine
1149 and good, but it's not helping you to choose a method! Right you are.
1150 As a developer, we don't want to boss our users around but give them
1151 maximum freedom instead. However, the reality is that some users would
1152 like to have some guidance, so here I'll try to give you this guidance
1153 without bossing you around. You tell me whether it works @dots{}
1154
1155 My suggestion is to use an inline method. For large files, external
1156 methods might be more efficient, but I guess that most people will
1157 want to edit mostly small files.
1158
1159 I guess that these days, most people can access a remote machine by
1160 using @command{ssh}. So I suggest that you use the @option{ssh}
1161 method. So, type @kbd{C-x C-f @trampfn{ssh, root, otherhost,
1162 /etc/motd} @key{RET}} to edit the @file{/etc/motd} file on the other
1163 host.
1164
1165 If you can't use @option{ssh} to log in to the remote host, then
1166 select a method that uses a program that works. For instance, Windows
1167 users might like the @option{plink} method which uses the PuTTY
1168 implementation of @command{ssh}. Or you use Kerberos and thus like
1169 @option{krlogin}.
1170
1171 For the special case of editing files on the local host as another
1172 user, see the @option{su} or @option{sudo} methods. They offer
1173 shortened syntax for the @samp{root} account, like
1174 @file{@trampfn{su, , , /etc/motd}}.
1175
1176 People who edit large files may want to consider @option{scpc} instead
1177 of @option{ssh}, or @option{pscp} instead of @option{plink}. These
1178 external methods are faster than inline methods for large files.
1179 Note, however, that external methods suffer from some limitations.
1180 Please try first whether you really get a noticeable speed advantage
1181 from using an external method! Maybe even for large files, inline
1182 methods are fast enough.
1183
1184
1185 @node Default User
1186 @section Selecting a default user
1187 @cindex default user
1188
1189 The user part of a @value{tramp} file name can be omitted. Usually,
1190 it is replaced by the user name you are logged in. Often, this is not
1191 what you want. A typical use of @value{tramp} might be to edit some
1192 files with root permissions on the local host. This case, you should
1193 set the variable @code{tramp-default-user} to reflect that choice.
1194 For example:
1195
1196 @lisp
1197 (setq tramp-default-user "root")
1198 @end lisp
1199
1200 @code{tramp-default-user} is regarded as obsolete, and will be removed
1201 soon.
1202
1203 @vindex tramp-default-user-alist
1204 You can also specify different users for certain method/host
1205 combinations, via the variable @code{tramp-default-user-alist}. For
1206 example, if you always have to use the user @samp{john} in the domain
1207 @samp{somewhere.else}, you can specify the following:
1208
1209 @lisp
1210 (add-to-list 'tramp-default-user-alist
1211 '("ssh" ".*\\.somewhere\\.else\\'" "john"))
1212 @end lisp
1213
1214 @noindent
1215 See the documentation for the variable
1216 @code{tramp-default-user-alist} for more details.
1217
1218 One trap to fall in must be known. If @value{tramp} finds a default
1219 user, this user will be passed always to the connection command as
1220 parameter (for example @samp{ssh here.somewhere.else -l john}. If you
1221 have specified another user for your command in its configuration
1222 files, @value{tramp} cannot know it, and the remote access will fail.
1223 If you have specified in the given example in @file{~/.ssh/config} the
1224 lines
1225
1226 @example
1227 Host here.somewhere.else
1228 User lily
1229 @end example
1230
1231 @noindent
1232 than you must discard selecting a default user by @value{tramp}. This
1233 will be done by setting it to @code{nil} (or @samp{lily}, likewise):
1234
1235 @lisp
1236 (add-to-list 'tramp-default-user-alist
1237 '("ssh" "\\`here\\.somewhere\\.else\\'" nil))
1238 @end lisp
1239
1240 The last entry in @code{tramp-default-user-alist} could be your
1241 default user you'll apply predominantly. You shall @emph{append} it
1242 to that list at the end:
1243
1244 @lisp
1245 (add-to-list 'tramp-default-user-alist '(nil nil "jonas") t)
1246 @end lisp
1247
1248
1249 @node Default Host
1250 @section Selecting a default host
1251 @cindex default host
1252
1253 @vindex tramp-default-host
1254 Finally, it is even possible to omit the host name part of a
1255 @value{tramp} file name. This case, the value of the variable
1256 @code{tramp-default-host} is used. Per default, it is initialized
1257 with the host name your local @value{emacsname} is running.
1258
1259 If you, for example, use @value{tramp} mainly to contact the host
1260 @samp{target} as user @samp{john}, you can specify:
1261
1262 @lisp
1263 (setq tramp-default-user "john"
1264 tramp-default-host "target")
1265 @end lisp
1266
1267 Then the simple file name @samp{@trampfn{ssh, , ,}} will connect you
1268 to John's home directory on target.
1269 @ifset emacs
1270 Note, however, that the most simplification @samp{/::} won't work,
1271 because @samp{/:} is the prefix for quoted file names.
1272 @end ifset
1273
1274
1275 @node Multi-hops
1276 @section Connecting to a remote host using multiple hops
1277 @cindex multi-hop
1278 @cindex proxy hosts
1279
1280 Sometimes, the methods described before are not sufficient. Sometimes,
1281 it is not possible to connect to a remote host using a simple command.
1282 For example, if you are in a secured network, you might have to log in
1283 to a `bastion host' first before you can connect to the outside world.
1284 Of course, the target host may also require a bastion host.
1285
1286 @vindex tramp-default-proxies-alist
1287 In order to specify such multiple hops, it is possible to define a proxy
1288 host to pass through, via the variable
1289 @code{tramp-default-proxies-alist}. This variable keeps a list of
1290 triples (@var{host} @var{user} @var{proxy}).
1291
1292 The first matching item specifies the proxy host to be passed for a
1293 file name located on a remote target matching @var{user}@@@var{host}.
1294 @var{host} and @var{user} are regular expressions or @code{nil}, which
1295 is interpreted as a regular expression which always matches.
1296
1297 @var{proxy} must be a Tramp filename which localname part is ignored.
1298 Method and user name on @var{proxy} are optional, which is interpreted
1299 with the default values.
1300 @ifset emacsgw
1301 The method must be an inline or gateway method (@pxref{Inline
1302 methods}, @pxref{Gateway methods}).
1303 @end ifset
1304 @ifclear emacsgw
1305 The method must be an inline method (@pxref{Inline methods}).
1306 @end ifclear
1307 If @var{proxy} is @code{nil}, no additional hop is required reaching
1308 @var{user}@@@var{host}.
1309
1310 If you, for example, must pass the host @samp{bastion.your.domain} as
1311 user @samp{bird} for any remote host which is not located in your local
1312 domain, you can set
1313
1314 @lisp
1315 (add-to-list 'tramp-default-proxies-alist
1316 '("\\." nil "@trampfn{ssh, bird, bastion.your.domain,}"))
1317 (add-to-list 'tramp-default-proxies-alist
1318 '("\\.your\\.domain\\'" nil nil))
1319 @end lisp
1320
1321 Please note the order of the code. @code{add-to-list} adds elements at the
1322 beginning of a list. Therefore, most relevant rules must be added last.
1323
1324 Proxy hosts can be cascaded. If there is another host called
1325 @samp{jump.your.domain}, which is the only one in your local domain who
1326 is allowed connecting @samp{bastion.your.domain}, you can add another
1327 rule:
1328
1329 @lisp
1330 (add-to-list 'tramp-default-proxies-alist
1331 '("\\`bastion\\.your\\.domain\\'"
1332 "\\`bird\\'"
1333 "@trampfn{ssh, , jump.your.domain,}"))
1334 @end lisp
1335
1336 @var{proxy} can contain the patterns @code{%h} or @code{%u}. These
1337 patterns are replaced by the strings matching @var{host} or
1338 @var{user}, respectively.
1339
1340 If you, for example, wants to work as @samp{root} on hosts in the
1341 domain @samp{your.domain}, but login as @samp{root} is disabled for
1342 non-local access, you might add the following rule:
1343
1344 @lisp
1345 (add-to-list 'tramp-default-proxies-alist
1346 '("\\.your\\.domain\\'" "\\`root\\'" "@trampfn{ssh, , %h,}"))
1347 @end lisp
1348
1349 Opening @file{@trampfn{sudo, , randomhost.your.domain,}} would connect
1350 first @samp{randomhost.your.domain} via @code{ssh} under your account
1351 name, and perform @code{sudo -u root} on that host afterwards. It is
1352 important to know that the given method is applied on the host which
1353 has been reached so far. @code{sudo -u root}, applied on your local
1354 host, wouldn't be useful here.
1355
1356 This is the recommended configuration to work as @samp{root} on remote
1357 Ubuntu hosts.
1358
1359 @ifset emacsgw
1360 Finally, @code{tramp-default-proxies-alist} can be used to pass
1361 firewalls or proxy servers. Imagine your local network has a host
1362 @samp{proxy.your.domain} which is used on port 3128 as HTTP proxy to
1363 the outer world. Your friendly administrator has granted you access
1364 under your user name to @samp{host.other.domain} on that proxy
1365 server.@footnote{HTTP tunnels are intended for secure SSL/TLS
1366 communication. Therefore, many proxy server restrict the tunnels to
1367 related target ports. You might need to run your ssh server on your
1368 target host @samp{host.other.domain} on such a port, like 443 (https).
1369 See @uref{http://savannah.gnu.org/maintenance/CvsFromBehindFirewall}
1370 for discussion of ethical issues.} You would need to add the
1371 following rule:
1372
1373 @lisp
1374 (add-to-list 'tramp-default-proxies-alist
1375 '("\\`host\\.other\\.domain\\'" nil
1376 "@trampfn{tunnel, , proxy.your.domain#3128,}"))
1377 @end lisp
1378
1379 Gateway methods can be declared as first hop only in a multiple hop
1380 chain.
1381 @end ifset
1382
1383
1384 @node Customizing Methods
1385 @section Using Non-Standard Methods
1386 @cindex customizing methods
1387 @cindex using non-standard methods
1388 @cindex create your own methods
1389
1390 There is a variable @code{tramp-methods} which you can change if the
1391 predefined methods don't seem right.
1392
1393 For the time being, I'll refer you to the Lisp documentation of that
1394 variable, accessible with @kbd{C-h v tramp-methods @key{RET}}.
1395
1396
1397 @node Customizing Completion
1398 @section Selecting config files for user/host name completion
1399 @cindex customizing completion
1400 @cindex selecting config files
1401 @vindex tramp-completion-function-alist
1402
1403 The variable @code{tramp-completion-function-alist} is intended to
1404 customize which files are taken into account for user and host name
1405 completion (@pxref{Filename completion}). For every method, it keeps
1406 a set of configuration files, accompanied by a Lisp function able to
1407 parse that file. Entries in @code{tramp-completion-function-alist}
1408 have the form (@var{method} @var{pair1} @var{pair2} ...).
1409
1410 Each @var{pair} is composed of (@var{function} @var{file}).
1411 @var{function} is responsible to extract user names and host names
1412 from @var{file} for completion. There are two functions which access
1413 this variable:
1414
1415 @defun tramp-get-completion-function method
1416 This function returns the list of completion functions for @var{method}.
1417
1418 Example:
1419 @example
1420 (tramp-get-completion-function "rsh")
1421
1422 @result{} ((tramp-parse-rhosts "/etc/hosts.equiv")
1423 (tramp-parse-rhosts "~/.rhosts"))
1424 @end example
1425 @end defun
1426
1427 @defun tramp-set-completion-function method function-list
1428 This function sets @var{function-list} as list of completion functions
1429 for @var{method}.
1430
1431 Example:
1432 @example
1433 (tramp-set-completion-function "ssh"
1434 '((tramp-parse-sconfig "/etc/ssh_config")
1435 (tramp-parse-sconfig "~/.ssh/config")))
1436
1437 @result{} ((tramp-parse-sconfig "/etc/ssh_config")
1438 (tramp-parse-sconfig "~/.ssh/config"))
1439 @end example
1440 @end defun
1441
1442 The following predefined functions parsing configuration files exist:
1443
1444 @table @asis
1445 @item @code{tramp-parse-rhosts}
1446 @findex tramp-parse-rhosts
1447
1448 This function parses files which are syntactical equivalent to
1449 @file{~/.rhosts}. It returns both host names and user names, if
1450 specified.
1451
1452 @item @code{tramp-parse-shosts}
1453 @findex tramp-parse-shosts
1454
1455 This function parses files which are syntactical equivalent to
1456 @file{~/.ssh/known_hosts}. Since there are no user names specified
1457 in such files, it can return host names only.
1458
1459 @item @code{tramp-parse-sconfig}
1460 @findex tramp-parse-shosts
1461
1462 This function returns the host nicknames defined by @code{Host} entries
1463 in @file{~/.ssh/config} style files.
1464
1465 @item @code{tramp-parse-shostkeys}
1466 @findex tramp-parse-shostkeys
1467
1468 SSH2 parsing of directories @file{/etc/ssh2/hostkeys/*} and
1469 @file{~/ssh2/hostkeys/*}. Hosts are coded in file names
1470 @file{hostkey_@var{portnumber}_@var{host-name}.pub}. User names
1471 are always @code{nil}.
1472
1473 @item @code{tramp-parse-sknownhosts}
1474 @findex tramp-parse-shostkeys
1475
1476 Another SSH2 style parsing of directories like
1477 @file{/etc/ssh2/knownhosts/*} and @file{~/ssh2/knownhosts/*}. This
1478 case, hosts names are coded in file names
1479 @file{@var{host-name}.@var{algorithm}.pub}. User names are always @code{nil}.
1480
1481 @item @code{tramp-parse-hosts}
1482 @findex tramp-parse-hosts
1483
1484 A function dedicated to @file{/etc/hosts} style files. It returns
1485 host names only.
1486
1487 @item @code{tramp-parse-passwd}
1488 @findex tramp-parse-passwd
1489
1490 A function which parses @file{/etc/passwd} like files. Obviously, it
1491 can return user names only.
1492
1493 @item @code{tramp-parse-netrc}
1494 @findex tramp-parse-netrc
1495
1496 Finally, a function which parses @file{~/.netrc} like files.
1497 @end table
1498
1499 If you want to keep your own data in a file, with your own structure,
1500 you might provide such a function as well. This function must meet
1501 the following conventions:
1502
1503 @defun my-tramp-parse file
1504 @var{file} must be either a file name on your host, or @code{nil}.
1505 The function must return a list of (@var{user} @var{host}), which are
1506 taken as candidates for user and host name completion.
1507
1508 Example:
1509 @example
1510 (my-tramp-parse "~/.my-tramp-hosts")
1511
1512 @result{} ((nil "toto") ("daniel" "melancholia"))
1513 @end example
1514 @end defun
1515
1516
1517 @node Password handling
1518 @section Reusing passwords for several connections.
1519 @cindex passwords
1520
1521 Sometimes it is necessary to connect to the same remote host several
1522 times. Reentering passwords again and again would be annoying, when
1523 the chosen method does not support access without password prompt
1524 through own configuration.
1525
1526 The best recommendation is to use the method's own mechanism for
1527 password handling. Consider @command{ssh-agent} for @option{ssh}-like
1528 methods, or @command{pageant} for @option{plink}-like methods.
1529
1530 However, if you cannot apply such native password handling,
1531 @value{tramp} offers altenatives.
1532
1533
1534 @anchor{auth-sources}
1535 @subsection Using an authentication file
1536
1537 @vindex auth-sources
1538 The package @file{auth-source.el}, originally developed in No Gnus,
1539 offers the possibility to read passwords from a file, like FTP does it
1540 from @file{~/.netrc}. The default authentication file is
1541 @file{~/.authinfo.gpg}, this can be changed via the variable
1542 @code{auth-sources}.
1543
1544 @noindent
1545 A typical entry in the authentication file would be
1546
1547 @example
1548 machine melancholia port scp login daniel password geheim
1549 @end example
1550
1551 The port can be any @value{tramp} method (@pxref{Inline methods},
1552 @pxref{External methods}), to match only this method. When you omit
1553 the port, you match all @value{tramp} methods.
1554
1555
1556 @anchor{password-cache}
1557 @subsection Caching passwords
1558
1559 If there is no authentication file, @value{tramp} caches the passwords
1560 entered by you. They will be reused next time if a connection needs
1561 them for the same user name and host name, independently of the
1562 connection method.
1563
1564 @vindex password-cache-expiry
1565 Passwords are not saved permanently, that means the password caching
1566 is limited to the lifetime of your @value{emacsname} session. You
1567 can influence the lifetime of password caching by customizing the
1568 variable @code{password-cache-expiry}. The value is the number of
1569 seconds how long passwords are cached. Setting it to @code{nil}
1570 disables the expiration.
1571
1572 @vindex password-cache
1573 If you don't like this feature for security reasons, password caching
1574 can be disabled totally by customizing the variable
1575 @code{password-cache} (setting it to @code{nil}).
1576
1577 Implementation Note: password caching is based on the package
1578 @file{password-cache.el}. For the time being, it is activated only
1579 when this package is seen in the @code{load-path} while loading
1580 @value{tramp}.
1581 @ifset installchapter
1582 If you don't use No Gnus, you can take @file{password.el} from the
1583 @value{tramp} @file{contrib} directory, see @ref{Installation
1584 parameters}.
1585 @end ifset
1586
1587
1588 @node Connection caching
1589 @section Reusing connection related information.
1590 @cindex caching
1591
1592 @vindex tramp-persistency-file-name
1593 In order to reduce initial connection time, @value{tramp} stores
1594 connection related information persistently. The variable
1595 @code{tramp-persistency-file-name} keeps the file name where these
1596 information are written. Its default value is
1597 @ifset emacs
1598 @file{~/.emacs.d/tramp}.
1599 @end ifset
1600 @ifset xemacs
1601 @file{~/.xemacs/tramp}.
1602 @end ifset
1603 It is recommended to choose a local file name.
1604
1605 @value{tramp} reads this file during startup, and writes it when
1606 exiting @value{emacsname}. You can simply remove this file if
1607 @value{tramp} shall be urged to recompute these information next
1608 @value{emacsname} startup time.
1609
1610 Using such persistent information can be disabled by setting
1611 @code{tramp-persistency-file-name} to @code{nil}.
1612
1613 Once consequence of reusing connection related information is that
1614 @var{tramp} needs to distinguish hosts. If you, for example, run a
1615 local @code{sshd} on port 3001, which tunnels @command{ssh} to another
1616 host, you could access both @file{@trampfn{ssh, , localhost,}} and
1617 @file{@trampfn{ssh, , localhost#3001,}}. @var{tramp} would use the
1618 same host related information (like paths, Perl variants, etc) for
1619 both connections, although the information is valid only for one of
1620 them.
1621
1622 In order to avoid trouble, you must use another host name for one of
1623 the connections, like introducing a @option{Host} section in
1624 @file{~/.ssh/config} (@pxref{Frequently Asked Questions}) or applying
1625 multiple hops (@pxref{Multi-hops}).
1626
1627 When @value{tramp} detects a changed operating system version on a
1628 remote host (via the command @command{uname -sr}), it flushes all
1629 connection related information for this host, and opens the
1630 connection, again.
1631
1632
1633 @node Remote Programs
1634 @section How @value{tramp} finds and uses programs on the remote machine.
1635
1636 @value{tramp} depends on a number of programs on the remote host in order to
1637 function, including @command{ls}, @command{test}, @command{find} and
1638 @command{cat}.
1639
1640 In addition to these required tools, there are various tools that may be
1641 required based on the connection method. See @ref{Inline methods} and
1642 @ref{External methods} for details on these.
1643
1644 Certain other tools, such as @command{perl} (or @command{perl5}) and
1645 @command{grep} will be used if they can be found. When they are
1646 available, they are used to improve the performance and accuracy of
1647 remote file access.
1648
1649 @vindex tramp-remote-path
1650 When @value{tramp} connects to the remote machine, it searches for the
1651 programs that it can use. The variable @code{tramp-remote-path}
1652 controls the directories searched on the remote machine.
1653
1654 By default, this is set to a reasonable set of defaults for most
1655 machines. The symbol @code{tramp-default-remote-path} is a place
1656 holder, it is replaced by the list of directories received via the
1657 command @command{getconf PATH} on your remote machine. For example,
1658 on GNU Debian this is @file{/bin:/usr/bin}, whereas on Solaris this is
1659 @file{/usr/xpg4/bin:/usr/ccs/bin:/usr/bin:/opt/SUNWspro/bin}. It is
1660 recommended to apply this symbol on top of @code{tramp-remote-path}.
1661
1662 It is possible, however, that your local (or remote ;) system
1663 administrator has put the tools you want in some obscure local
1664 directory.
1665
1666 In this case, you can still use them with @value{tramp}. You simply
1667 need to add code to your @file{.emacs} to add the directory to the
1668 remote path. This will then be searched by @value{tramp} when you
1669 connect and the software found.
1670
1671 To add a directory to the remote search path, you could use code such
1672 as:
1673
1674 @lisp
1675 @i{;; We load @value{tramp} to define the variable.}
1676 (require 'tramp)
1677 @i{;; We have @command{perl} in "/usr/local/perl/bin"}
1678 (add-to-list 'tramp-remote-path "/usr/local/perl/bin")
1679 @end lisp
1680
1681 @value{tramp} caches several information, like the Perl binary
1682 location. The changed remote search path wouldn't affect these
1683 settings. In order to force @value{tramp} to recompute these values,
1684 you must exit @value{emacsname}, remove your persistency file
1685 (@pxref{Connection caching}), and restart @value{emacsname}.
1686
1687
1688 @node Remote shell setup
1689 @section Remote shell setup hints
1690 @cindex remote shell setup
1691 @cindex @file{.profile} file
1692 @cindex @file{.login} file
1693 @cindex shell init files
1694
1695 As explained in the @ref{Overview} section, @value{tramp} connects to the
1696 remote host and talks to the shell it finds there. Of course, when you
1697 log in, the shell executes its init files. Suppose your init file
1698 requires you to enter the birth date of your mother; clearly @value{tramp}
1699 does not know this and hence fails to log you in to that host.
1700
1701 There are different possible strategies for pursuing this problem. One
1702 strategy is to enable @value{tramp} to deal with all possible situations.
1703 This is a losing battle, since it is not possible to deal with
1704 @emph{all} situations. The other strategy is to require you to set up
1705 the remote host such that it behaves like @value{tramp} expects. This might
1706 be inconvenient because you have to invest a lot of effort into shell
1707 setup before you can begin to use @value{tramp}.
1708
1709 The package, therefore, pursues a combined approach. It tries to
1710 figure out some of the more common setups, and only requires you to
1711 avoid really exotic stuff. For example, it looks through a list of
1712 directories to find some programs on the remote host. And also, it
1713 knows that it is not obvious how to check whether a file exists, and
1714 therefore it tries different possibilities. (On some hosts and
1715 shells, the command @command{test -e} does the trick, on some hosts
1716 the shell builtin doesn't work but the program @command{/usr/bin/test
1717 -e} or @command{/bin/test -e} works. And on still other hosts,
1718 @command{ls -d} is the right way to do this.)
1719
1720 Below you find a discussion of a few things that @value{tramp} does not deal
1721 with, and that you therefore have to set up correctly.
1722
1723 @table @asis
1724 @item @var{shell-prompt-pattern}
1725 @vindex shell-prompt-pattern
1726
1727 After logging in to the remote host, @value{tramp} has to wait for the remote
1728 shell startup to finish before it can send commands to the remote
1729 shell. The strategy here is to wait for the shell prompt. In order to
1730 recognize the shell prompt, the variable @code{shell-prompt-pattern} has
1731 to be set correctly to recognize the shell prompt on the remote host.
1732
1733 Note that @value{tramp} requires the match for @code{shell-prompt-pattern}
1734 to be at the end of the buffer. Many people have something like the
1735 following as the value for the variable: @code{"^[^>$][>$] *"}. Now
1736 suppose your shell prompt is @code{a <b> c $ }. In this case,
1737 @value{tramp} recognizes the @code{>} character as the end of the prompt,
1738 but it is not at the end of the buffer.
1739
1740 @item @var{tramp-shell-prompt-pattern}
1741 @vindex tramp-shell-prompt-pattern
1742
1743 This regular expression is used by @value{tramp} in the same way as
1744 @code{shell-prompt-pattern}, to match prompts from the remote shell.
1745 This second variable exists because the prompt from the remote shell
1746 might be different from the prompt from a local shell --- after all,
1747 the whole point of @value{tramp} is to log in to remote hosts as a
1748 different user. The default value of
1749 @code{tramp-shell-prompt-pattern} is the same as the default value of
1750 @code{shell-prompt-pattern}, which is reported to work well in many
1751 circumstances.
1752
1753 @item @var{tramp-password-prompt-regexp}
1754 @vindex tramp-password-prompt-regexp
1755 @vindex tramp-wrong-passwd-regexp
1756
1757 During login, @value{tramp} might be forced to enter a password or a
1758 passphrase. The difference between both is that a password is
1759 requested from the shell on the remote host, while a passphrase is
1760 needed for accessing local authentication information, like your ssh
1761 key.
1762
1763 @var{tramp-password-prompt-regexp} handles the detection of such
1764 requests for English environments. When you use another localization
1765 of your (local or remote) host, you might need to adapt this. Example:
1766
1767 @lisp
1768 (setq
1769 tramp-password-prompt-regexp
1770 (concat
1771 "^.*"
1772 (regexp-opt
1773 '("passphrase" "Passphrase"
1774 ;; English
1775 "password" "Password"
1776 ;; Deutsch
1777 "passwort" "Passwort"
1778 ;; Fran@,{c}ais
1779 "mot de passe" "Mot de passe") t)
1780 ".*: