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