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