tramp.texi 114 KB

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