tramp.texi 137 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036
  1. \input texinfo @c -*-texinfo-*-
  2. @setfilename ../../info/tramp.info
  3. @c %**start of header
  4. @settitle TRAMP User Manual
  5. @documentencoding UTF-8
  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 syntax.
  16. @c xxx and yyy are auxiliary macros in order to omit leading and
  17. @c trailing whitespace. Not very elegant, but I don't know it better.
  18. @c There are subtle differences between texinfo 4.13 and 5.0. We must
  19. @c declare two versions of the macro. This will be improved, hopefully.
  20. @c Texinfo 5.0.
  21. @ifset txicommandconditionals
  22. @macro xxx {one}
  23. @set \one\
  24. @end macro
  25. @macro yyy {one, two}
  26. @xxx{x\one\}@c
  27. @ifclear x
  28. \one\@w{}\two\@c
  29. @end ifclear
  30. @clear x\one\
  31. @end macro
  32. @macro trampfn {method, user, host, localname}
  33. @value{prefix}@c
  34. @yyy{\method\,@value{postfixhop}}@c
  35. @yyy{\user\,@@}@c
  36. \host\@value{postfix}\localname\
  37. @end macro
  38. @end ifset
  39. @c Texinfo 4.13.
  40. @ifclear txicommandconditionals
  41. @macro xxx {one}@c
  42. @set \one\@c
  43. @end macro
  44. @macro yyy {one, two}@c
  45. @xxx{x\one\}@c
  46. @ifclear x@c
  47. \one\@w{}\two\@c
  48. @end ifclear
  49. @clear x\one\@c
  50. @end macro
  51. @macro trampfn {method, user, host, localname}@c
  52. @value{prefix}@yyy{\method\,@value{postfixhop}}@yyy{\user\,@@}\host\@value{postfix}\localname\@c
  53. @end macro
  54. @end ifclear
  55. @copying
  56. Copyright @copyright{} 1999--2015 Free Software Foundation, Inc.
  57. @quotation
  58. Permission is granted to copy, distribute and/or modify this document
  59. under the terms of the GNU Free Documentation License, Version 1.3 or
  60. any later version published by the Free Software Foundation; with no
  61. Invariant Sections, with the Front-Cover Texts being ``A GNU Manual'',
  62. and with the Back-Cover Texts as in (a) below. A copy of the license
  63. is included in the section entitled ``GNU Free Documentation License''.
  64. (a) The FSF's Back-Cover Text is: ``You have the freedom to
  65. copy and modify this GNU manual.''
  66. @end quotation
  67. @end copying
  68. @c Entries for @command{install-info} to use
  69. @dircategory @value{emacsname} network features
  70. @direntry
  71. * TRAMP: (tramp). Transparent Remote Access, Multiple Protocol
  72. @value{emacsname} remote file access via ssh and scp.
  73. @end direntry
  74. @titlepage
  75. @title @value{tramp} version @value{trampver} User Manual
  76. @author by Daniel Pittman
  77. @author based on documentation by Kai Gro@ss{}johann
  78. @page
  79. @insertcopying
  80. @end titlepage
  81. @contents
  82. @ifnottex
  83. @node Top, Overview, (dir), (dir)
  84. @top @value{tramp} version @value{trampver} User Manual
  85. This file documents @value{tramp} version @value{trampver}, a remote file
  86. editing package for @value{emacsname}.
  87. @value{tramp} stands for ``Transparent Remote (file) Access, Multiple
  88. Protocol''. This package provides remote file editing, similar to
  89. @value{ftppackagename}.
  90. The difference is that @value{ftppackagename} uses FTP to transfer
  91. files between the local and the remote host, whereas @value{tramp} uses a
  92. combination of @command{rsh} and @command{rcp} or other work-alike
  93. programs, such as @command{ssh}/@command{scp}.
  94. You can find the latest version of this document on the web at
  95. @uref{http://www.gnu.org/software/tramp/}.
  96. @c Pointer to the other Emacs flavor is necessary only in case of
  97. @c standalone installation.
  98. @ifset installchapter
  99. The manual has been generated for @value{emacsname}.
  100. @ifinfo
  101. If you want to read the info pages for @value{emacsothername}, you
  102. should read in @ref{Installation} how to create them.
  103. @end ifinfo
  104. @ifhtml
  105. If you're using the other Emacs flavor, you should read the
  106. @uref{@value{emacsotherfilename}, @value{emacsothername}} pages.
  107. @end ifhtml
  108. @end ifset
  109. @ifhtml
  110. The latest release of @value{tramp} is available for
  111. @uref{ftp://ftp.gnu.org/gnu/tramp/, download}, or you may see
  112. @ref{Obtaining Tramp} for more details, including the Git server
  113. details.
  114. @value{tramp} also has a @uref{http://savannah.gnu.org/projects/tramp/,
  115. Savannah Project Page}.
  116. @end ifhtml
  117. There is a mailing list for @value{tramp}, available at
  118. @email{tramp-devel@@gnu.org}, and archived at
  119. @uref{http://lists.gnu.org/archive/html/tramp-devel/, the
  120. @value{tramp} Mail Archive}.
  121. @ifhtml
  122. Older archives are located at
  123. @uref{http://sourceforge.net/mailarchive/forum.php?forum=tramp-devel,
  124. SourceForge Mail Archive} and
  125. @uref{http://www.mail-archive.com/emacs-rcp@@ls6.cs.uni-dortmund.de/,
  126. The Mail Archive}.
  127. @c in HTML output, there's no new paragraph.
  128. @*@*
  129. @end ifhtml
  130. @insertcopying
  131. @end ifnottex
  132. @menu
  133. * Overview:: What @value{tramp} can and cannot do.
  134. For the end user:
  135. * Obtaining Tramp:: How to obtain @value{tramp}.
  136. * History:: History of @value{tramp}.
  137. @ifset installchapter
  138. * Installation:: Installing @value{tramp} with your @value{emacsname}.
  139. @end ifset
  140. * Configuration:: Configuring @value{tramp} for use.
  141. * Usage:: An overview of the operation of @value{tramp}.
  142. * Bug Reports:: Reporting Bugs and Problems.
  143. * Frequently Asked Questions:: Questions and answers from the mailing list.
  144. For the developer:
  145. * Files directories and localnames:: How file names, directories and localnames are mangled and managed.
  146. * Traces and Profiles:: How to Customize Traces.
  147. * Issues:: Debatable Issues and What Was Decided.
  148. * GNU Free Documentation License:: The license for this documentation.
  149. * Function Index:: @value{tramp} functions.
  150. * Variable Index:: User options and variables.
  151. * Concept Index:: An item for each concept.
  152. @detailmenu
  153. --- The Detailed Node Listing ---
  154. @c
  155. @ifset installchapter
  156. Installing @value{tramp} with your @value{emacsname}
  157. * Installation parameters:: Parameters in order to control installation.
  158. * Load paths:: How to plug-in @value{tramp} into your environment.
  159. @end ifset
  160. Configuring @value{tramp} for use
  161. * Connection types:: Types of connections made to remote hosts.
  162. * Inline methods:: Inline methods.
  163. * External methods:: External methods.
  164. @ifset emacsgvfs
  165. * GVFS based methods:: GVFS based external methods.
  166. @end ifset
  167. @ifset emacsgw
  168. * Gateway methods:: Gateway methods.
  169. @end ifset
  170. * Default Method:: Selecting a default method.
  171. * Default User:: Selecting a default user.
  172. * Default Host:: Selecting a default host.
  173. * Multi-hops:: Connecting to a remote host using multiple hops.
  174. * Customizing Methods:: Using Non-Standard Methods.
  175. * Customizing Completion:: Selecting config files for user/host name completion.
  176. * Password handling:: Reusing passwords for several connections.
  177. * Connection caching:: Reusing connection related information.
  178. * Predefined connection information::
  179. Setting own connection related information.
  180. * Remote Programs:: How @value{tramp} finds and uses programs on the remote host.
  181. * Remote shell setup:: Remote shell setup hints.
  182. * Android shell setup:: Android shell setup hints.
  183. * Auto-save and Backup:: Auto-save and Backup.
  184. * Windows setup hints:: Issues with Cygwin ssh.
  185. Using @value{tramp}
  186. * File name Syntax:: @value{tramp} file name conventions.
  187. * File name completion:: File name completion.
  188. * Ad-hoc multi-hops:: Declaring multiple hops in the file name.
  189. * Remote processes:: Integration with other @value{emacsname} packages.
  190. * Cleanup remote connections:: Cleanup remote connections.
  191. How file names, directories and localnames are mangled and managed
  192. * Localname deconstruction:: Breaking a localname into its components.
  193. @ifset emacs
  194. * External packages:: Integration with external Lisp packages.
  195. @end ifset
  196. @end detailmenu
  197. @end menu
  198. @node Overview
  199. @chapter An overview of @value{tramp}
  200. @cindex overview
  201. After the installation of @value{tramp} into your @value{emacsname}, you
  202. will be able to access files on remote hosts as though they were
  203. local. Access to the remote file system for editing files, version
  204. control, and @code{dired} are transparently enabled.
  205. Your access to the remote host can be with the @command{rsh},
  206. @command{rlogin}, @command{telnet} programs or with any similar
  207. connection method. This connection must pass @acronym{ASCII}
  208. successfully to be usable but need not be 8-bit clean.
  209. The package provides support for @command{ssh} connections out of the
  210. box, one of the more common uses of the package. This allows
  211. relatively secure access to hosts, especially if @command{ftp}
  212. access is disabled.
  213. Under Windows, @value{tramp} is integrated with the PuTTY package,
  214. using the @command{plink} program.
  215. The majority of activity carried out by @value{tramp} requires only that
  216. the remote login is possible and is carried out at the terminal. In
  217. order to access remote files @value{tramp} needs to transfer their content
  218. to the local host temporarily.
  219. @value{tramp} can transfer files between the hosts in a variety of ways.
  220. The details are easy to select, depending on your needs and the
  221. hosts in question.
  222. The fastest transfer methods for large files rely on a remote file
  223. transfer package such as @command{rcp}, @command{scp}, @command{rsync}
  224. or (under Windows) @command{pscp}.
  225. If the remote copy methods are not suitable for you, @value{tramp} also
  226. supports the use of encoded transfers directly through the shell.
  227. This requires that the @command{mimencode} or @command{uuencode} tools
  228. are available on the remote host. These methods are generally
  229. faster for small files.
  230. @value{tramp} is still under active development and any problems you encounter,
  231. trivial or major, should be reported to the @value{tramp} developers.
  232. @xref{Bug Reports}.
  233. @subsubheading Behind the scenes
  234. @cindex behind the scenes
  235. @cindex details of operation
  236. @cindex how it works
  237. This section tries to explain what goes on behind the scenes when you
  238. access a remote file through @value{tramp}.
  239. Suppose you type @kbd{C-x C-f} and enter part of an @value{tramp} file name,
  240. then hit @kbd{@key{TAB}} for completion. Suppose further that this is
  241. the first time that @value{tramp} is invoked for the host in question. Here's
  242. what happens:
  243. @itemize
  244. @item
  245. @value{tramp} discovers that it needs a connection to the host. So it
  246. invokes @samp{telnet @var{host}} or @samp{rsh @var{host} -l
  247. @var{user}} or a similar tool to connect to the remote host.
  248. Communication with this process happens through an
  249. @value{emacsname} buffer, that is, the output from the remote end
  250. goes into a buffer.
  251. @item
  252. The remote host may prompt for a login name (for @command{telnet}).
  253. The login name is given in the file name, so @value{tramp} sends the
  254. login name and a newline.
  255. @item
  256. The remote host may prompt for a password or pass phrase (for
  257. @command{rsh} or for @command{telnet} after sending the login name).
  258. @value{tramp} displays the prompt in the minibuffer, asking you for the
  259. password or pass phrase.
  260. You enter the password or pass phrase. @value{tramp} sends it to the remote
  261. host, followed by a newline.
  262. @item
  263. @value{tramp} now waits for the shell prompt or for a message that the login
  264. failed.
  265. If @value{tramp} sees neither of them after a certain period of time
  266. (a minute, say), then it issues an error message saying that it
  267. couldn't find the remote shell prompt and shows you what the remote
  268. host has sent.
  269. If @value{tramp} sees a @samp{login failed} message, it tells you so,
  270. aborts the login attempt and allows you to try again.
  271. @item
  272. Suppose that the login was successful and @value{tramp} sees the shell prompt
  273. from the remote host. Now @value{tramp} invokes @command{/bin/sh} because
  274. Bourne shells and C shells have different command
  275. syntaxes.@footnote{Invoking @command{/bin/sh} will fail if your login
  276. shell doesn't recognize @samp{exec /bin/sh} as a valid command.
  277. Maybe you use the Scheme shell @command{scsh}@dots{}}
  278. After the Bourne shell has come up, @value{tramp} sends a few commands to
  279. ensure a good working environment. It turns off echoing, it sets the
  280. shell prompt, and a few other things.
  281. @item
  282. Now the remote shell is up and it good working order. Remember, what
  283. was supposed to happen is that @value{tramp} tries to find out what files exist
  284. on the remote host so that it can do file name completion.
  285. So, @value{tramp} basically issues @command{cd} and @command{ls} commands and
  286. also sometimes @command{echo} with globbing. Another command that is
  287. often used is @command{test} to find out whether a file is writable or a
  288. directory or the like. The output of each command is parsed for the
  289. necessary operation.
  290. @item
  291. Suppose you are finished with file name completion, have entered @kbd{C-x
  292. C-f}, a full file name and hit @kbd{@key{RET}}. Now comes the time to
  293. transfer the file contents from the remote host to the local host so
  294. that you can edit them.
  295. See above for an explanation of how @value{tramp} transfers the file contents.
  296. For inline transfers, @value{tramp} issues a command like @samp{mimencode -b
  297. /path/to/remote/file}, waits until the output has accumulated in the
  298. buffer that's used for communication, then decodes that output to
  299. produce the file contents.
  300. For external transfers, @value{tramp} issues a command like the
  301. following:
  302. @example
  303. rcp user@@host:/path/to/remote/file /tmp/tramp.4711
  304. @end example
  305. It then reads the local temporary file @file{/tmp/tramp.4711} into a
  306. buffer and deletes the temporary file.
  307. @item
  308. You now edit the buffer contents, blithely unaware of what has happened
  309. behind the scenes. (Unless you have read this section, that is.) When
  310. you are finished, you type @kbd{C-x C-s} to save the buffer.
  311. @item
  312. Again, @value{tramp} transfers the file contents to the remote host
  313. either inline or external. This is the reverse of what happens when
  314. reading the file.
  315. @end itemize
  316. I hope this has provided you with a basic overview of what happens
  317. behind the scenes when you open a file with @value{tramp}.
  318. @c For the end user
  319. @node Obtaining Tramp
  320. @chapter Obtaining Tramp.
  321. @cindex obtaining Tramp
  322. @value{tramp} is freely available on the Internet and the latest
  323. release may be downloaded from @uref{ftp://ftp.gnu.org/gnu/tramp/}.
  324. This release includes the full documentation and code for
  325. @value{tramp}, suitable for installation. But Emacs (22 or later)
  326. includes @value{tramp} already, and there is a @value{tramp} package
  327. for XEmacs, as well. So maybe it is easier to just use those. But if
  328. you want the bleeding edge, read on@dots{}
  329. For the especially brave, @value{tramp} is available from Git. The Git
  330. version is the latest version of the code and may contain incomplete
  331. features or new issues. Use these versions at your own risk.
  332. Instructions for obtaining the latest development version of @value{tramp}
  333. from Git can be found by going to the Savannah project page at the
  334. following URL and then clicking on the Git link in the navigation bar
  335. at the top.
  336. @noindent
  337. @uref{http://savannah.gnu.org/projects/tramp/}
  338. @noindent
  339. Or follow the example session below:
  340. @example
  341. ] @strong{cd ~/@value{emacsdir}}
  342. ] @strong{git clone git://git.savannah.gnu.org/tramp.git}
  343. @end example
  344. @noindent
  345. Tramp developers use instead
  346. @example
  347. ] @strong{git clone login@@git.sv.gnu.org:/srv/git/tramp.git}
  348. @end example
  349. @noindent
  350. You should now have a directory @file{~/@value{emacsdir}/tramp}
  351. containing the latest version of @value{tramp}. You can fetch the latest
  352. updates from the repository by issuing the command:
  353. @example
  354. ] @strong{cd ~/@value{emacsdir}/tramp}
  355. ] @strong{git pull}
  356. @end example
  357. @noindent
  358. Once you've got updated files from the Git repository, you need to run
  359. @command{autoconf} in order to get an up-to-date @file{configure}
  360. script:
  361. @example
  362. ] @strong{cd ~/@value{emacsdir}/tramp}
  363. ] @strong{autoconf}
  364. @end example
  365. @node History
  366. @chapter History of @value{tramp}
  367. @cindex history
  368. @cindex development history
  369. Development was started end of November 1998. The package was called
  370. @file{rssh.el}, back then. It only provided one method to access a
  371. file, using @command{ssh} to log in to a remote host and using
  372. @command{scp} to transfer the file contents. After a while, the name
  373. was changed to @file{rcp.el}, and now it's @value{tramp}. Along the way,
  374. many more methods for getting a remote shell and for transferring the
  375. file contents were added. Support for VC was added.
  376. After that, there were added the multi-hop methods in April 2000 and
  377. the unification of @value{tramp} and Ange-FTP file names in July 2002.
  378. In July 2004, multi-hop methods have been replaced by proxy hosts.
  379. Running commands on remote hosts was introduced in December 2005.
  380. @ifset emacsgw
  381. Support of gateways exists since April 2007.
  382. @end ifset
  383. @ifset emacsgvfs
  384. GVFS integration started in February 2009.
  385. @end ifset
  386. @ifset emacs
  387. Remote commands on Windows hosts are available since September 2011.
  388. @end ifset
  389. Ad-hoc multi-hop methods (with a changed syntax) have been reenabled
  390. in November 2011. In November 2012, Juergen Hoetzel's
  391. @file{tramp-adb.el} has been added.
  392. In December 2001, @value{tramp} has been added to the XEmacs package
  393. repository. Being part of the Emacs repository happened in June 2002,
  394. the first release including @value{tramp} was Emacs 22.1.
  395. @value{tramp} is also a Debian GNU/Linux package since February 2001.
  396. @c Installation chapter is necessary only in case of standalone
  397. @c installation. Text taken from trampinst.texi.
  398. @ifset installchapter
  399. @include trampinst.texi
  400. @end ifset
  401. @node Configuration
  402. @chapter Configuring @value{tramp} for use
  403. @cindex configuration
  404. @cindex default configuration
  405. @value{tramp} is (normally) fully functional when it is initially
  406. installed. It is initially configured to use the @command{scp}
  407. program to connect to the remote host. So in the easiest case, you
  408. just type @kbd{C-x C-f} and then enter the file name
  409. @file{@trampfn{, user, host, /path/to.file}}.
  410. On some hosts, there are problems with opening a connection. These are
  411. related to the behavior of the remote shell. See @xref{Remote shell
  412. setup}, for details on this.
  413. If you do not wish to use these commands to connect to the remote
  414. host, you should change the default connection and transfer method
  415. that @value{tramp} uses. There are several different methods that @value{tramp}
  416. can use to connect to remote hosts and transfer files
  417. (@pxref{Connection types}).
  418. If you don't know which method is right for you, see @xref{Default
  419. Method}.
  420. @menu
  421. * Connection types:: Types of connections made to remote hosts.
  422. * Inline methods:: Inline methods.
  423. * External methods:: External methods.
  424. @ifset emacsgvfs
  425. * GVFS based methods:: GVFS based external methods.
  426. @end ifset
  427. @ifset emacsgw
  428. * Gateway methods:: Gateway methods.
  429. @end ifset
  430. * Default Method:: Selecting a default method.
  431. Here we also try to help those who
  432. don't have the foggiest which method
  433. is right for them.
  434. * Default User:: Selecting a default user.
  435. * Default Host:: Selecting a default host.
  436. * Multi-hops:: Connecting to a remote host using multiple hops.
  437. * Customizing Methods:: Using Non-Standard Methods.
  438. * Customizing Completion:: Selecting config files for user/host name completion.
  439. * Password handling:: Reusing passwords for several connections.
  440. * Connection caching:: Reusing connection related information.
  441. * Predefined connection information::
  442. Setting own connection related information.
  443. * Remote Programs:: How @value{tramp} finds and uses programs on the remote host.
  444. * Remote shell setup:: Remote shell setup hints.
  445. * Android shell setup:: Android shell setup hints.
  446. * Auto-save and Backup:: Auto-save and Backup.
  447. * Windows setup hints:: Issues with Cygwin ssh.
  448. @end menu
  449. @node Connection types
  450. @section Types of connections made to remote hosts
  451. @cindex connection types, overview
  452. There are two basic types of transfer methods, each with its own
  453. advantages and limitations. Both types of connection make use of a
  454. remote shell access program such as @command{rsh}, @command{ssh} or
  455. @command{telnet} to connect to the remote host.
  456. This connection is used to perform many of the operations that @value{tramp}
  457. requires to make the remote file system transparently accessible from
  458. the local host. It is only when visiting files that the methods
  459. differ.
  460. @cindex inline methods
  461. @cindex external methods
  462. @cindex methods, inline
  463. @cindex methods, external
  464. Loading or saving a remote file requires that the content of the file
  465. be transferred between the two hosts. The content of the file can
  466. be transferred using one of two methods: the @dfn{inline method} over
  467. the same connection used to log in to the remote host, or the
  468. @dfn{external method} through another connection using a remote copy
  469. program such as @command{rcp}, @command{scp} or @command{rsync}.
  470. The performance of the external methods is generally better than that
  471. of the inline methods, at least for large files. This is caused by
  472. the need to encode and decode the data when transferring inline.
  473. The one exception to this rule are the @command{scp} based transfer
  474. methods. While these methods do see better performance when actually
  475. transferring files, the overhead of the cryptographic negotiation at
  476. startup may drown out the improvement in file transfer times.
  477. External methods should be configured such a way that they don't
  478. require a password (with @command{ssh-agent}, or such alike). Modern
  479. @command{scp} implementations offer options to reuse existing
  480. @command{ssh} connections, which will be enabled by default if
  481. available. If it isn't possible, you should consider @ref{Password
  482. handling}, otherwise you will be prompted for a password every copy
  483. action.
  484. @node Inline methods
  485. @section Inline methods
  486. @cindex inline methods
  487. @cindex methods, inline
  488. The inline methods in @value{tramp} are quite powerful and can work in
  489. situations where you cannot use an external transfer program to
  490. connect. There are also strange inline methods which allow you to
  491. transfer files between @emph{user identities} rather than hosts, see
  492. below.
  493. These methods depend on the existence of a suitable encoding and
  494. decoding command on remote host. Locally, @value{tramp} may be able to
  495. use features of @value{emacsname} to decode and encode the files or
  496. it may require access to external commands to perform that task.
  497. @cindex uuencode
  498. @cindex mimencode
  499. @cindex base-64 encoding
  500. @value{tramp} checks the availability and usability of commands like
  501. @command{mimencode} (part of the @command{metamail} package) or
  502. @command{uuencode} on the remote host. The first reliable command
  503. will be used. The search path can be customized, see @ref{Remote
  504. Programs}.
  505. If both commands aren't available on the remote host, @value{tramp}
  506. transfers a small piece of Perl code to the remote host, and tries to
  507. apply it for encoding and decoding.
  508. The variable @var{tramp-inline-compress-start-size} controls, whether
  509. a file shall be compressed before encoding. This could increase
  510. transfer speed for large text files.
  511. @table @asis
  512. @item @option{rsh}
  513. @cindex method rsh
  514. @cindex rsh method
  515. Connect to the remote host with @command{rsh}. Due to the unsecure
  516. connection it is recommended for very local host topology only.
  517. On operating systems which provide the command @command{remsh} instead
  518. of @command{rsh}, you can use the method @option{remsh}. This is true
  519. for HP-UX or Cray UNICOS, for example.
  520. @item @option{ssh}
  521. @cindex method ssh
  522. @cindex ssh method
  523. Connect to the remote host with @command{ssh}. This is identical to
  524. the previous option except that the @command{ssh} package is used,
  525. making the connection more secure.
  526. All the methods based on @command{ssh} have an additional feature: you
  527. can specify a host name which looks like @file{host#42} (the real host
  528. name, then a hash sign, then a port number). This means to connect to
  529. the given host but to also pass @code{-p 42} as arguments to the
  530. @command{ssh} command.
  531. @item @option{telnet}
  532. @cindex method telnet
  533. @cindex telnet method
  534. Connect to the remote host with @command{telnet}. This is as unsecure
  535. as the @option{rsh} method.
  536. @item @option{su}
  537. @cindex method su
  538. @cindex su method
  539. This method does not connect to a remote host at all, rather it uses
  540. the @command{su} program to allow you to edit files as another user.
  541. That means, the specified host name in the file name must be either
  542. @samp{localhost} or the host name as returned by the function
  543. @command{(system-name)}. For an exception of this rule see
  544. @ref{Multi-hops}.
  545. @item @option{sudo}
  546. @cindex method sudo
  547. @cindex sudo method
  548. This is similar to the @option{su} method, but it uses @command{sudo}
  549. rather than @command{su} to become a different user.
  550. Note that @command{sudo} must be configured to allow you to start a
  551. shell as the user. It would be nice if it was sufficient if
  552. @command{ls} and @command{mimencode} were allowed, but that is not
  553. easy to implement, so I haven't got around to it, yet.
  554. @item @option{sshx}
  555. @cindex method sshx
  556. @cindex sshx method
  557. As you would expect, this is similar to @option{ssh}, only a little
  558. different. Whereas @option{ssh} opens a normal interactive shell on
  559. the remote host, this option uses @samp{ssh -t -t @var{host} -l
  560. @var{user} /bin/sh} to open a connection. This is useful for users
  561. where the normal login shell is set up to ask them a number of
  562. questions when logging in. This procedure avoids these questions, and
  563. just gives @value{tramp} a more-or-less ``standard'' login shell to work
  564. with.
  565. Note that this procedure does not eliminate questions asked by
  566. @command{ssh} itself. For example, @command{ssh} might ask ``Are you
  567. sure you want to continue connecting?'' if the host key of the remote
  568. host is not known. @value{tramp} does not know how to deal with such a
  569. question (yet), therefore you will need to make sure that you can log
  570. in without such questions.
  571. This is also useful for Windows users where @command{ssh}, when
  572. invoked from an @value{emacsname} buffer, tells them that it is not
  573. allocating a pseudo tty. When this happens, the login shell is wont
  574. to not print any shell prompt, which confuses @value{tramp} mightily.
  575. This supports the @samp{-p} argument.
  576. @item @option{krlogin}
  577. @cindex method krlogin
  578. @cindex krlogin method
  579. @cindex Kerberos (with krlogin method)
  580. This method is also similar to @option{ssh}. It only uses the
  581. @command{krlogin -x} command to log in to the remote host.
  582. @item @option{ksu}
  583. @cindex method ksu
  584. @cindex ksu method
  585. @cindex Kerberos (with ksu method)
  586. This is another method from the Kerberos suite. It behaves like @option{su}.
  587. @item @option{plink}
  588. @cindex method plink
  589. @cindex plink method
  590. This method is mostly interesting for Windows users using the PuTTY
  591. implementation of SSH@. It uses @samp{plink -ssh} to log in to the
  592. remote host.
  593. With a recent PuTTY, it is recommended to check the @samp{Share SSH
  594. connections if possible} control for that session.
  595. This method supports the @samp{-P} argument.
  596. @item @option{plinkx}
  597. @cindex method plinkx
  598. @cindex plinkx method
  599. Another method using PuTTY on Windows. Instead of host names, it
  600. expects PuTTY session names, calling @samp{plink -load @var{session}
  601. -t}. User names and port numbers must be defined in the session.
  602. With a recent PuTTY, it is recommended to check the @samp{Share SSH
  603. connections if possible} control for that session.
  604. @end table
  605. @node External methods
  606. @section External methods
  607. @cindex methods, external
  608. @cindex external methods
  609. The external methods operate through multiple channels, using the
  610. remote shell connection for many actions while delegating file
  611. transfers to an external transfer utility.
  612. This saves the overhead of encoding and decoding that multiplexing the
  613. transfer through the one connection has with the inline methods.
  614. Since external methods need their own overhead opening a new channel,
  615. all files which are smaller than @var{tramp-copy-size-limit} are still
  616. transferred with the corresponding inline method. It should provide a
  617. fair trade-off between both approaches.
  618. @table @asis
  619. @item @option{rcp}---@command{rsh} and @command{rcp}
  620. @cindex method rcp
  621. @cindex rcp method
  622. @cindex rcp (with rcp method)
  623. @cindex rsh (with rcp method)
  624. This method uses the @command{rsh} and @command{rcp} commands to connect
  625. to the remote host and transfer files. This is probably the fastest
  626. connection method available.
  627. The alternative method @option{remcp} uses the @command{remsh} and
  628. @command{rcp} commands. It should be applied on hosts where
  629. @command{remsh} is used instead of @command{rsh}.
  630. @item @option{scp}---@command{ssh} and @command{scp}
  631. @cindex method scp
  632. @cindex scp method
  633. @cindex scp (with scp method)
  634. @cindex ssh (with scp method)
  635. Using @command{ssh} to connect to the remote host and @command{scp} to
  636. transfer files between the hosts is the best method for securely
  637. connecting to a remote host and accessing files.
  638. The performance of this option is also quite good. It may be slower than
  639. the inline methods when you often open and close small files however.
  640. The cost of the cryptographic handshake at the start of an @command{scp}
  641. session can begin to absorb the advantage that the lack of encoding and
  642. decoding presents.
  643. All the @command{ssh} based methods support the @samp{-p} feature
  644. where you can specify a port number to connect to in the host name.
  645. For example, the host name @file{host#42} tells @value{tramp} to
  646. specify @samp{-p 42} in the argument list for @command{ssh}, and to
  647. specify @samp{-P 42} in the argument list for @command{scp}.
  648. @item @option{rsync}---@command{ssh} and @command{rsync}
  649. @cindex method rsync
  650. @cindex rsync method
  651. @cindex rsync (with rsync method)
  652. @cindex ssh (with rsync method)
  653. Using the @command{ssh} command to connect securely to the remote
  654. host and the @command{rsync} command to transfer files is almost
  655. identical to the @option{scp} method.
  656. While @command{rsync} performs much better than @command{scp} when
  657. transferring files that exist on both hosts, this advantage is lost if
  658. the file exists only on one side of the connection. A file can exists
  659. on both the remote and local host, when you copy a file from/to a
  660. remote host. When you just open a file from the remote host (or write
  661. a file there), a temporary file on the local side is kept as long as
  662. the corresponding buffer, visiting this file, is alive.
  663. This method supports the @samp{-p} argument.
  664. @item @option{scpx}---@command{ssh} and @command{scp}
  665. @cindex method scpx
  666. @cindex scpx method
  667. @cindex scp (with scpx method)
  668. @cindex ssh (with scpx method)
  669. As you would expect, this is similar to @option{scp}, only a little
  670. different. Whereas @option{scp} opens a normal interactive shell on
  671. the remote host, this option uses @samp{ssh -t -t @var{host} -l
  672. @var{user} /bin/sh} to open a connection. This is useful for users
  673. where the normal login shell is set up to ask them a number of
  674. questions when logging in. This procedure avoids these questions, and
  675. just gives @value{tramp} a more-or-less ``standard'' login shell to work
  676. with.
  677. This is also useful for Windows users where @command{ssh}, when
  678. invoked from an @value{emacsname} buffer, tells them that it is not
  679. allocating a pseudo tty. When this happens, the login shell is wont
  680. to not print any shell prompt, which confuses @value{tramp} mightily.
  681. This method supports the @samp{-p} argument.
  682. @item @option{pscp}---@command{plink} and @command{pscp}
  683. @item @option{psftp}---@command{plink} and @command{psftp}
  684. @cindex method pscp
  685. @cindex pscp method
  686. @cindex pscp (with pscp method)
  687. @cindex plink (with pscp method)
  688. @cindex PuTTY (with pscp method)
  689. @cindex method psftp
  690. @cindex psftp method
  691. @cindex pscp (with psftp method)
  692. @cindex plink (with psftp method)
  693. @cindex PuTTY (with psftp method)
  694. These methods are similar to @option{scp} or @option{sftp}, but they
  695. use the @command{plink} command to connect to the remote host, and
  696. they use @command{pscp} or @command{psftp} for transferring the files.
  697. These programs are part of PuTTY, an SSH implementation for Windows.
  698. With a recent PuTTY, it is recommended to configure the @samp{Share
  699. SSH connections if possible} control for that session.
  700. These methods support the @samp{-P} argument.
  701. @item @option{fcp}---@command{fsh} and @command{fcp}
  702. @cindex method fcp
  703. @cindex fcp method
  704. @cindex fsh (with fcp method)
  705. @cindex fcp (with fcp method)
  706. This method is similar to @option{scp}, but it uses the @command{fsh}
  707. command to connect to the remote host, and it uses @command{fcp} for
  708. transferring the files. @command{fsh/fcp} are a front-end for
  709. @command{ssh} which allow for reusing the same @command{ssh} session
  710. for submitting several commands. This avoids the startup overhead of
  711. @command{scp} (which has to establish a secure connection whenever it
  712. is called). Note, however, that you can also use one of the inline
  713. methods to achieve a similar effect.
  714. This method uses the command @samp{fsh @var{host} -l @var{user}
  715. /bin/sh -i} to establish the connection, it does not work to just say
  716. @command{fsh @var{host} -l @var{user}}.
  717. @cindex method fsh
  718. @cindex fsh method
  719. There is no inline method using @command{fsh} as the multiplexing
  720. provided by the program is not very useful in our context. @value{tramp}
  721. opens just one connection to the remote host and then keeps it open,
  722. anyway.
  723. @item @option{nc}---@command{telnet} and @command{nc}
  724. @cindex method nc
  725. @cindex nc method
  726. @cindex nc (with nc method)
  727. @cindex telnet (with nc method)
  728. Using @command{telnet} to connect to the remote host and @command{nc}
  729. for file transfer is often the only possibility to access dumb
  730. devices, like routers or NAS hosts. Those hosts have just a
  731. restricted @command{busybox} as local shell, and there is no program
  732. to encode and decode files for transfer.
  733. @item @option{ftp}
  734. @cindex method ftp
  735. @cindex ftp method
  736. This is not a native @value{tramp} method. Instead, it forwards all
  737. requests to @value{ftppackagename}.
  738. @ifset xemacs
  739. This works only for unified file names, see @ref{Issues}.
  740. @end ifset
  741. @item @option{smb}---@command{smbclient}
  742. @cindex method smb
  743. @cindex smb method
  744. This is another not native @value{tramp} method. It uses the
  745. @command{smbclient} command on different Unices in order to connect to
  746. an SMB server. An SMB server might be a Samba (or CIFS) server on
  747. another UNIX host or, more interesting, a host running MS Windows. So
  748. far, it is tested against MS Windows NT, MS Windows 2000, MS Windows
  749. XP, MS Windows Vista, and MS Windows 7.
  750. The first directory in the localname must be a share name on the remote
  751. host. Remember that the @code{$} character, in which default shares
  752. usually end, must be written @code{$$} due to environment variable
  753. substitution in file names. If no share name is given (i.e., remote
  754. directory @code{/}), all available shares are listed.
  755. Since authorization is done on share level, you will always be
  756. prompted for a password if you access another share on the same host.
  757. This can be suppressed by @ref{Password handling}.
  758. For authorization, MS Windows uses both a user name and a domain name.
  759. Because of this, the @value{tramp} syntax has been extended: you can
  760. specify a user name which looks like @code{user%domain} (the real user
  761. name, then a percent sign, then the domain name). So, to connect to
  762. the host @code{melancholia} as user @code{daniel} of the domain
  763. @code{BIZARRE}, and edit @file{.emacs} in the home directory (share
  764. @code{daniel$}) I would specify the file name @file{@trampfn{smb,
  765. daniel%BIZARRE, melancholia, /daniel$$/.emacs}}.
  766. Depending on the Windows domain configuration, a Windows user might be
  767. considered as domain user per default. In order to connect as local
  768. user, the WINS name of that host must be given as domain name.
  769. Usually, it is the host name in capital letters. In the example
  770. above, the local user @code{daniel} would be specified as
  771. @file{@trampfn{smb, daniel%MELANCHOLIA, melancholia, /daniel$$/.emacs}}.
  772. The domain name as well as the user name are optional. If no user
  773. name is specified at all, the anonymous user (without password
  774. prompting) is assumed. This is different from all other @value{tramp}
  775. methods, where in such a case the local user name is taken.
  776. The @option{smb} method supports the @samp{-p} argument.
  777. @strong{Please note:} If @value{emacsname} runs locally under MS
  778. Windows, this method isn't available. Instead, you can use UNC
  779. file names like @file{//melancholia/daniel$$/.emacs}. The only
  780. disadvantage is that there's no possibility to specify another user
  781. name.
  782. @item @option{adb}
  783. @cindex method adb
  784. @cindex adb method
  785. This special method uses the Android Debug Bridge for accessing
  786. Android devices. The Android Debug Bridge must be installed locally.
  787. Some GNU/Linux distributions offer it for installation, otherwise it
  788. can be installed as part of the Android SDK@. If the @command{adb}
  789. program is not found via the @env{PATH} environment variable, the
  790. variable @var{tramp-adb-program} must point to its absolute path.
  791. @value{tramp} does not connect Android devices to @command{adb},
  792. unless the customer option @option{tramp-adb-connect-if-not-connected}
  793. is non-@code{nil}. If there is exactly one Android device connected
  794. to @command{adb}, a host name is not needed in the remote file name.
  795. The default @value{tramp} name to be used is @file{@trampfn{adb, , ,}},
  796. therefore. Otherwise, one could find potential host names with the
  797. command @command{adb devices}.
  798. Usually, the @command{adb} method does not need any user name. It
  799. runs under the permissions of the @command{adbd} process on the
  800. Android device. If a user name is specified, @value{tramp} applies an
  801. @command{su} on the device. This does not work with all Android
  802. devices, especially with unrooted ones. In that case, an error
  803. message is displayed.
  804. If a device shall be connected via TCP/IP, it is possible to declare
  805. the port number to be used like @file{device#42}. Without a port
  806. number, the default value as declared in @command{adb} will be used.
  807. Port numbers are not applicable to Android devices connected via USB.
  808. @end table
  809. @ifset emacsgvfs
  810. @node GVFS based methods
  811. @section GVFS based external methods
  812. @cindex methods, gvfs
  813. @cindex gvfs based methods
  814. @cindex dbus
  815. The connection methods described in this section are based on GVFS
  816. @uref{http://en.wikipedia.org/wiki/GVFS}. Via GVFS, the remote
  817. filesystem is mounted locally through FUSE@. @value{tramp} uses
  818. this local mounted directory internally.
  819. The communication with GVFS is implemented via D-Bus messages.
  820. Therefore, your @value{emacsname} must have D-Bus integration,
  821. @pxref{Top, , D-Bus, dbus}.
  822. @table @asis
  823. @item @option{dav}
  824. @cindex method dav
  825. @cindex method davs
  826. @cindex dav method
  827. @cindex davs method
  828. This method provides access to WebDAV files and directories. There
  829. exists also the external method @option{davs}, which uses SSL
  830. encryption for the access.
  831. Both methods support the port number specification as discussed above.
  832. @item @option{obex}
  833. @cindex method obex
  834. @cindex obex method
  835. OBEX is an FTP-like access protocol for simple devices, like cell
  836. phones. For the time being, @value{tramp} only supports OBEX over Bluetooth.
  837. @item @option{sftp}
  838. @cindex method sftp
  839. @cindex sftp method
  840. As you might expect, this method uses @command{sftp} in order to
  841. access the remote host. Contrary to the @option{ssh} and @option{scp}
  842. methods, it doesn't open an @command{ssh} session for login.
  843. Therefore, it could be used to access to remote hosts which refuse
  844. @command{ssh} for security reasons.
  845. @item @option{synce}
  846. @cindex method synce
  847. @cindex synce method
  848. The @option{synce} method allows communication with Windows Mobile
  849. devices. Beside GVFS for mounting remote files and directories via
  850. FUSE, it also needs the SYNCE-GVFS plugin.
  851. @end table
  852. @vindex tramp-gvfs-methods
  853. @defopt tramp-gvfs-methods
  854. This customer option, a list, defines the external methods which shall
  855. be used with GVFS@. Per default, these are @option{dav},
  856. @option{davs}, @option{obex}, @option{sftp} and @option{synce}. Other
  857. possible values are @option{ftp} and @option{smb}.
  858. @end defopt
  859. @end ifset
  860. @ifset emacsgw
  861. @node Gateway methods
  862. @section Gateway methods
  863. @cindex methods, gateway
  864. @cindex gateway methods
  865. Gateway methods are not methods to access a remote host directly.
  866. These methods are intended to pass firewalls or proxy servers.
  867. Therefore, they can be used for proxy host declarations
  868. (@pxref{Multi-hops}) only.
  869. A gateway method must always come along with a method which supports
  870. port setting. This is because @value{tramp} targets the accompanied
  871. method to @file{localhost#random_port}, from where the firewall or
  872. proxy server is accessed.
  873. Gateway methods support user name and password declarations. These
  874. are used to authenticate towards the corresponding firewall or proxy
  875. server. They can be passed only if your friendly administrator has
  876. granted your access.
  877. @table @asis
  878. @item @option{tunnel}
  879. @cindex method tunnel
  880. @cindex tunnel method
  881. This method implements an HTTP tunnel via the @command{CONNECT}
  882. command (see RFC 2616, 2817). Any HTTP 1.1 compliant (proxy) server
  883. shall support this command.
  884. As authentication method, only @option{Basic Authentication} (see RFC
  885. 2617) is implemented so far. If no port number is given in the
  886. declaration, port @option{8080} is used for the proxy server.
  887. @item @option{socks}
  888. @cindex method socks
  889. @cindex socks method
  890. The @command{socks} method provides access to SOCKSv5 servers (see
  891. RFC 1928). @option{Username/Password Authentication} according to RFC
  892. 1929 is supported.
  893. The default port number of the socks server is @option{1080}, if not
  894. specified otherwise.
  895. @end table
  896. @end ifset
  897. @node Default Method
  898. @section Selecting a default method
  899. @cindex default method
  900. @vindex tramp-default-method
  901. When you select an appropriate transfer method for your typical usage
  902. you should set the variable @code{tramp-default-method} to reflect that
  903. choice. This variable controls which method will be used when a method
  904. is not specified in the @value{tramp} file name. For example:
  905. @lisp
  906. (setq tramp-default-method "ssh")
  907. @end lisp
  908. @vindex tramp-default-method-alist
  909. You can also specify different methods for certain user/host
  910. combinations, via the variable @code{tramp-default-method-alist}. For
  911. example, the following two lines specify to use the @option{ssh}
  912. method for all user names matching @samp{john} and the @option{rsync}
  913. method for all host names matching @samp{lily}. The third line
  914. specifies to use the @option{su} method for the user @samp{root} on
  915. the host @samp{localhost}.
  916. @lisp
  917. (add-to-list 'tramp-default-method-alist '("" "john" "ssh"))
  918. (add-to-list 'tramp-default-method-alist '("lily" "" "rsync"))
  919. (add-to-list 'tramp-default-method-alist
  920. '("\\`localhost\\'" "\\`root\\'" "su"))
  921. @end lisp
  922. @noindent
  923. See the documentation for the variable
  924. @code{tramp-default-method-alist} for more details.
  925. External methods are normally preferable to inline methods, giving
  926. better performance.
  927. @xref{Inline methods}.
  928. @xref{External methods}.
  929. Another consideration with the selection of transfer methods is the
  930. environment you will use them in and, especially when used over the
  931. Internet, the security implications of your preferred method.
  932. The @option{rsh} and @option{telnet} methods send your password as
  933. plain text as you log in to the remote host, as well as
  934. transferring the files in such a way that the content can easily be
  935. read from other hosts.
  936. If you need to connect to remote systems that are accessible from the
  937. Internet, you should give serious thought to using @option{ssh} based
  938. methods to connect. These provide a much higher level of security,
  939. making it a non-trivial exercise for someone to obtain your password
  940. or read the content of the files you are editing.
  941. @subsection Which method is the right one for me?
  942. @cindex choosing the right method
  943. Given all of the above, you are probably thinking that this is all fine
  944. and good, but it's not helping you to choose a method! Right you are.
  945. As a developer, we don't want to boss our users around but give them
  946. maximum freedom instead. However, the reality is that some users would
  947. like to have some guidance, so here I'll try to give you this guidance
  948. without bossing you around. You tell me whether it works @dots{}
  949. My suggestion is to use an inline method. For large files, external
  950. methods might be more efficient, but I guess that most people will
  951. want to edit mostly small files. And if you access large text files,
  952. compression (driven by @var{tramp-inline-compress-start-size}) shall
  953. still result in good performance.
  954. I guess that these days, most people can access a remote host by
  955. using @command{ssh}. So I suggest that you use the @option{ssh}
  956. method. So, type @kbd{C-x C-f @trampfn{ssh, root, otherhost,
  957. /etc/motd} @key{RET}} to edit the @file{/etc/motd} file on the other
  958. host.
  959. If you can't use @option{ssh} to log in to the remote host, then
  960. select a method that uses a program that works. For instance, Windows
  961. users might like the @option{plink} method which uses the PuTTY
  962. implementation of @command{ssh}. Or you use Kerberos and thus like
  963. @option{krlogin}.
  964. For the special case of editing files on the local host as another
  965. user, see the @option{su} or @option{sudo} methods. They offer
  966. shortened syntax for the @samp{root} account, like
  967. @file{@trampfn{su, , , /etc/motd}}.
  968. People who edit large files may want to consider @option{scp} instead
  969. of @option{ssh}, or @option{pscp} instead of @option{plink}. These
  970. external methods are faster than inline methods for large files.
  971. Note, however, that external methods suffer from some limitations.
  972. Please try first whether you really get a noticeable speed advantage
  973. from using an external method! Maybe even for large files, inline
  974. methods are fast enough.
  975. @node Default User
  976. @section Selecting a default user
  977. @cindex default user
  978. The user part of a @value{tramp} file name can be omitted. Usually,
  979. it is replaced by the user name you are logged in. Often, this is not
  980. what you want. A typical use of @value{tramp} might be to edit some
  981. files with root permissions on the local host. This case, you should
  982. set the variable @code{tramp-default-user} to reflect that choice.
  983. For example:
  984. @lisp
  985. (setq tramp-default-user "root")
  986. @end lisp
  987. @code{tramp-default-user} is regarded as obsolete, and will be removed
  988. soon.
  989. @vindex tramp-default-user-alist
  990. You can also specify different users for certain method/host
  991. combinations, via the variable @code{tramp-default-user-alist}. For
  992. example, if you always have to use the user @samp{john} in the domain
  993. @samp{somewhere.else}, you can specify the following:
  994. @lisp
  995. (add-to-list 'tramp-default-user-alist
  996. '("ssh" ".*\\.somewhere\\.else\\'" "john"))
  997. @end lisp
  998. @noindent
  999. See the documentation for the variable @code{tramp-default-user-alist}
  1000. for more details.
  1001. One trap to fall in must be known. If @value{tramp} finds a default
  1002. user, this user will be passed always to the connection command as
  1003. parameter (for example @command{ssh here.somewhere.else -l john}. If
  1004. you have specified another user for your command in its configuration
  1005. files, @value{tramp} cannot know it, and the remote access will fail.
  1006. If you have specified in the given example in @file{~/.ssh/config} the
  1007. lines
  1008. @example
  1009. Host here.somewhere.else
  1010. User lily
  1011. @end example
  1012. @noindent
  1013. than you must discard selecting a default user by @value{tramp}. This
  1014. will be done by setting it to @code{nil} (or @samp{lily}, likewise):
  1015. @lisp
  1016. (add-to-list 'tramp-default-user-alist
  1017. '("ssh" "\\`here\\.somewhere\\.else\\'" nil))
  1018. @end lisp
  1019. The last entry in @code{tramp-default-user-alist} could be your
  1020. default user you'll apply predominantly. You shall @emph{append} it
  1021. to that list at the end:
  1022. @lisp
  1023. (add-to-list 'tramp-default-user-alist '(nil nil "jonas") t)
  1024. @end lisp
  1025. @node Default Host
  1026. @section Selecting a default host
  1027. @cindex default host
  1028. @vindex tramp-default-host
  1029. Finally, it is even possible to omit the host name part of a
  1030. @value{tramp} file name. This case, the value of the variable
  1031. @code{tramp-default-host} is used. Per default, it is initialized
  1032. with the host name your local @value{emacsname} is running.
  1033. If you, for example, use @value{tramp} mainly to contact the host
  1034. @samp{target} as user @samp{john}, you can specify:
  1035. @lisp
  1036. (setq tramp-default-user "john"
  1037. tramp-default-host "target")
  1038. @end lisp
  1039. Then the simple file name @samp{@trampfn{ssh, , ,}} will connect you
  1040. to John's home directory on target.
  1041. @ifset emacs
  1042. Note, however, that the most simplification @samp{/::} won't work,
  1043. because @samp{/:} is the prefix for quoted file names.
  1044. @end ifset
  1045. @vindex tramp-default-host-alist
  1046. Like with methods and users, you can also specify different default
  1047. hosts for certain method/user combinations via the variable
  1048. @code{tramp-default-host-alist}. Usually, this isn't necessary,
  1049. because @code{tramp-default-host} should be sufficient. For some
  1050. methods, like @option{adb}, that default value must be overwritten,
  1051. which is already the initial value of @code{tramp-default-host-alist}.
  1052. @noindent
  1053. See the documentation for the variable @code{tramp-default-host-alist}
  1054. for more details.
  1055. @node Multi-hops
  1056. @section Connecting to a remote host using multiple hops
  1057. @cindex multi-hop
  1058. @cindex proxy hosts
  1059. Sometimes, the methods described before are not sufficient.
  1060. Sometimes, it is not possible to connect to a remote host using a
  1061. simple command. For example, if you are in a secured network, you
  1062. might have to log in to a bastion host first before you can connect to
  1063. the outside world. Of course, the target host may also require a
  1064. bastion host.
  1065. @vindex tramp-default-proxies-alist
  1066. @defopt tramp-default-proxies-alist
  1067. In order to specify multiple hops, it is possible to define a proxy
  1068. host to pass through, via the customer option
  1069. @option{tramp-default-proxies-alist}. This variable keeps a list of
  1070. triples (@var{host} @var{user} @var{proxy}).
  1071. The first matching item specifies the proxy host to be passed for a
  1072. file name located on a remote target matching @var{user}@@@var{host}.
  1073. @var{host} and @var{user} are regular expressions or @code{nil}, which
  1074. is interpreted as a regular expression which always matches.
  1075. @var{proxy} must be a Tramp file name which localname part is ignored.
  1076. Method and user name on @var{proxy} are optional, which is interpreted
  1077. with the default values.
  1078. @ifset emacsgw
  1079. The method must be an inline or gateway method (@pxref{Inline
  1080. methods}, @pxref{Gateway methods}).
  1081. @end ifset
  1082. @ifclear emacsgw
  1083. The method must be an inline method (@pxref{Inline methods}).
  1084. @end ifclear
  1085. If @var{proxy} is @code{nil}, no additional hop is required reaching
  1086. @var{user}@@@var{host}.
  1087. If you, for example, must pass the host @samp{bastion.your.domain} as
  1088. user @samp{bird} for any remote host which is not located in your local
  1089. domain, you can set
  1090. @lisp
  1091. (add-to-list 'tramp-default-proxies-alist
  1092. '("\\." nil "@trampfn{ssh, bird, bastion.your.domain,}"))
  1093. (add-to-list 'tramp-default-proxies-alist
  1094. '("\\.your\\.domain\\'" nil nil))
  1095. @end lisp
  1096. Please note the order of the code. @code{add-to-list} adds elements at the
  1097. beginning of a list. Therefore, most relevant rules must be added last.
  1098. Proxy hosts can be cascaded. If there is another host called
  1099. @samp{jump.your.domain}, which is the only one in your local domain who
  1100. is allowed connecting @samp{bastion.your.domain}, you can add another
  1101. rule:
  1102. @lisp
  1103. (add-to-list 'tramp-default-proxies-alist
  1104. '("\\`bastion\\.your\\.domain\\'"
  1105. "\\`bird\\'"
  1106. "@trampfn{ssh, , jump.your.domain,}"))
  1107. @end lisp
  1108. @var{proxy} can contain the patterns @code{%h} or @code{%u}. These
  1109. patterns are replaced by the strings matching @var{host} or
  1110. @var{user}, respectively.
  1111. If you, for example, wants to work as @samp{root} on hosts in the
  1112. domain @samp{your.domain}, but login as @samp{root} is disabled for
  1113. non-local access, you might add the following rule:
  1114. @lisp
  1115. (add-to-list 'tramp-default-proxies-alist
  1116. '("\\.your\\.domain\\'" "\\`root\\'" "@trampfn{ssh, , %h,}"))
  1117. @end lisp
  1118. Opening @file{@trampfn{sudo, , randomhost.your.domain,}} would connect
  1119. first @samp{randomhost.your.domain} via @code{ssh} under your account
  1120. name, and perform @code{sudo -u root} on that host afterwards. It is
  1121. important to know that the given method is applied on the host which
  1122. has been reached so far. @code{sudo -u root}, applied on your local
  1123. host, wouldn't be useful here.
  1124. @var{host}, @var{user} and @var{proxy} can also be Lisp forms. These
  1125. forms are evaluated, and must return a string, or @code{nil}. The
  1126. previous example could be generalized then: For all hosts except my
  1127. local one connect via @command{ssh} first, and apply @command{sudo -u
  1128. root} afterwards:
  1129. @lisp
  1130. (add-to-list 'tramp-default-proxies-alist
  1131. '(nil "\\`root\\'" "@trampfn{ssh, , %h,}"))
  1132. (add-to-list 'tramp-default-proxies-alist
  1133. '((regexp-quote (system-name)) nil nil))
  1134. @end lisp
  1135. This is the recommended configuration to work as @samp{root} on remote
  1136. Ubuntu hosts.
  1137. @ifset emacsgw
  1138. Finally, @code{tramp-default-proxies-alist} can be used to pass
  1139. firewalls or proxy servers. Imagine your local network has a host
  1140. @samp{proxy.your.domain} which is used on port 3128 as HTTP proxy to
  1141. the outer world. Your friendly administrator has granted you access
  1142. under your user name to @samp{host.other.domain} on that proxy
  1143. server.@footnote{HTTP tunnels are intended for secure SSL/TLS
  1144. communication. Therefore, many proxy server restrict the tunnels to
  1145. related target ports. You might need to run your ssh server on your
  1146. target host @samp{host.other.domain} on such a port, like 443 (https).
  1147. See @uref{http://savannah.gnu.org/maintenance/CvsFromBehindFirewall}
  1148. for discussion of ethical issues.} You would need to add the
  1149. following rule:
  1150. @lisp
  1151. (add-to-list 'tramp-default-proxies-alist
  1152. '("\\`host\\.other\\.domain\\'" nil
  1153. "@trampfn{tunnel, , proxy.your.domain#3128,}"))
  1154. @end lisp
  1155. Gateway methods can be declared as first hop only in a multiple hop
  1156. chain.
  1157. @end ifset
  1158. @end defopt
  1159. Hops to be passed tend to be restricted firewalls and alike.
  1160. Sometimes they offer limited features only, like running @command{rbash}
  1161. (restricted bash). This must be told to @value{tramp}.
  1162. @vindex tramp-restricted-shell-hosts-alist
  1163. @defopt tramp-restricted-shell-hosts-alist
  1164. This customer option keeps a list of regular expressions, which denote
  1165. hosts running a registered shell like @command{rbash}. Those hosts
  1166. can be used as proxies only.
  1167. If the bastion host from the example above runs a restricted shell,
  1168. you shall apply
  1169. @lisp
  1170. (add-to-list 'tramp-restricted-shell-hosts-alist
  1171. "\\`bastion\\.your\\.domain\\'")
  1172. @end lisp
  1173. @end defopt
  1174. @node Customizing Methods
  1175. @section Using Non-Standard Methods
  1176. @cindex customizing methods
  1177. @cindex using non-standard methods
  1178. @cindex create your own methods
  1179. There is a variable @code{tramp-methods} which you can change if the
  1180. predefined methods don't seem right.
  1181. For the time being, I'll refer you to the Lisp documentation of that
  1182. variable, accessible with @kbd{C-h v tramp-methods @key{RET}}.
  1183. @node Customizing Completion
  1184. @section Selecting config files for user/host name completion
  1185. @cindex customizing completion
  1186. @cindex selecting config files
  1187. @vindex tramp-completion-function-alist
  1188. The variable @code{tramp-completion-function-alist} is intended to
  1189. customize which files are taken into account for user and host name
  1190. completion (@pxref{File name completion}). For every method, it keeps
  1191. a set of configuration files, accompanied by a Lisp function able to
  1192. parse that file. Entries in @code{tramp-completion-function-alist}
  1193. have the form (@var{method} @var{pair1} @var{pair2} @dots{}).
  1194. Each @var{pair} is composed of (@var{function} @var{file}).
  1195. @var{function} is responsible to extract user names and host names
  1196. from @var{file} for completion. There are two functions which access
  1197. this variable:
  1198. @defun tramp-get-completion-function method
  1199. This function returns the list of completion functions for @var{method}.
  1200. Example:
  1201. @example
  1202. (tramp-get-completion-function "rsh")
  1203. @result{} ((tramp-parse-rhosts "/etc/hosts.equiv")
  1204. (tramp-parse-rhosts "~/.rhosts"))
  1205. @end example
  1206. @end defun
  1207. @defun tramp-set-completion-function method function-list
  1208. This function sets @var{function-list} as list of completion functions
  1209. for @var{method}.
  1210. Example:
  1211. @example
  1212. (tramp-set-completion-function "ssh"
  1213. '((tramp-parse-sconfig "/etc/ssh_config")
  1214. (tramp-parse-sconfig "~/.ssh/config")))
  1215. @result{} ((tramp-parse-sconfig "/etc/ssh_config")
  1216. (tramp-parse-sconfig "~/.ssh/config"))
  1217. @end example
  1218. @end defun
  1219. The following predefined functions parsing configuration files exist:
  1220. @table @asis
  1221. @item @code{tramp-parse-rhosts}
  1222. @findex tramp-parse-rhosts
  1223. This function parses files which are syntactical equivalent to
  1224. @file{~/.rhosts}. It returns both host names and user names, if
  1225. specified.
  1226. @item @code{tramp-parse-shosts}
  1227. @findex tramp-parse-shosts
  1228. This function parses files which are syntactical equivalent to
  1229. @file{~/.ssh/known_hosts}. Since there are no user names specified
  1230. in such files, it can return host names only.
  1231. @item @code{tramp-parse-sconfig}
  1232. @findex tramp-parse-shosts
  1233. This function returns the host nicknames defined by @code{Host} entries
  1234. in @file{~/.ssh/config} style files.
  1235. @item @code{tramp-parse-shostkeys}
  1236. @findex tramp-parse-shostkeys
  1237. SSH2 parsing of directories @file{/etc/ssh2/hostkeys/*} and
  1238. @file{~/ssh2/hostkeys/*}. Hosts are coded in file names
  1239. @file{hostkey_@var{portnumber}_@var{host-name}.pub}. User names
  1240. are always @code{nil}.
  1241. @item @code{tramp-parse-sknownhosts}
  1242. @findex tramp-parse-shostkeys
  1243. Another SSH2 style parsing of directories like
  1244. @file{/etc/ssh2/knownhosts/*} and @file{~/ssh2/knownhosts/*}. This
  1245. case, hosts names are coded in file names
  1246. @file{@var{host-name}.@var{algorithm}.pub}. User names are always @code{nil}.
  1247. @item @code{tramp-parse-hosts}
  1248. @findex tramp-parse-hosts
  1249. A function dedicated to @file{/etc/hosts} style files. It returns
  1250. host names only.
  1251. @item @code{tramp-parse-passwd}
  1252. @findex tramp-parse-passwd
  1253. A function which parses @file{/etc/passwd} like files. Obviously, it
  1254. can return user names only.
  1255. @item @code{tramp-parse-netrc}
  1256. @findex tramp-parse-netrc
  1257. Finally, a function which parses @file{~/.netrc} like files. This
  1258. includes also @file{~/.authinfo}-style files.
  1259. @end table
  1260. If you want to keep your own data in a file, with your own structure,
  1261. you might provide such a function as well. This function must meet
  1262. the following conventions:
  1263. @defun my-tramp-parse file
  1264. @var{file} must be either a file name on your host, or @code{nil}.
  1265. The function must return a list of (@var{user} @var{host}), which are
  1266. taken as candidates for user and host name completion.
  1267. Example:
  1268. @example
  1269. (my-tramp-parse "~/.my-tramp-hosts")
  1270. @result{} ((nil "toto") ("daniel" "melancholia"))
  1271. @end example
  1272. @end defun
  1273. @node Password handling
  1274. @section Reusing passwords for several connections
  1275. @cindex passwords
  1276. Sometimes it is necessary to connect to the same remote host several
  1277. times. Reentering passwords again and again would be annoying, when
  1278. the chosen method does not support access without password prompt
  1279. through own configuration.
  1280. The best recommendation is to use the method's own mechanism for
  1281. password handling. Consider @command{ssh-agent} for @option{ssh}-like
  1282. methods, or @command{pageant} for @option{plink}-like methods.
  1283. However, if you cannot apply such native password handling,
  1284. @value{tramp} offers alternatives.
  1285. @anchor{Using an authentication file}
  1286. @subsection Using an authentication file
  1287. @vindex auth-sources
  1288. The package @file{auth-source.el}, originally developed in No Gnus,
  1289. offers the possibility to read passwords from a file, like FTP does it
  1290. from @file{~/.netrc}. The default authentication file is
  1291. @file{~/.authinfo.gpg}, this can be changed via the variable
  1292. @code{auth-sources}.
  1293. @noindent
  1294. A typical entry in the authentication file would be
  1295. @example
  1296. machine melancholia port scp login daniel password geheim
  1297. @end example
  1298. The port can be any @value{tramp} method (@pxref{Inline methods},
  1299. @pxref{External methods}), to match only this method. When you omit
  1300. the port, you match all @value{tramp} methods.
  1301. In case of problems, setting @code{auth-source-debug} to @code{t}
  1302. gives useful debug messages.
  1303. @anchor{Caching passwords}
  1304. @subsection Caching passwords
  1305. If there is no authentication file, @value{tramp} caches the passwords
  1306. entered by you. They will be reused next time if a connection needs
  1307. them for the same user name and host name, independently of the
  1308. connection method.
  1309. @vindex password-cache-expiry
  1310. Passwords are not saved permanently, that means the password caching
  1311. is limited to the lifetime of your @value{emacsname} session. You
  1312. can influence the lifetime of password caching by customizing the
  1313. variable @code{password-cache-expiry}. The value is the number of
  1314. seconds how long passwords are cached. Setting it to @code{nil}
  1315. disables the expiration.
  1316. @vindex password-cache
  1317. If you don't like this feature for security reasons, password caching
  1318. can be disabled totally by customizing the variable
  1319. @code{password-cache} (setting it to @code{nil}).
  1320. Implementation Note: password caching is based on the package
  1321. @file{password-cache.el}. For the time being, it is activated only
  1322. when this package is seen in the @code{load-path} while loading
  1323. @value{tramp}.
  1324. @ifset installchapter
  1325. If you don't use No Gnus, you can take @file{password.el} from the
  1326. @value{tramp} @file{contrib} directory, see @ref{Installation
  1327. parameters}.
  1328. @end ifset
  1329. @node Connection caching
  1330. @section Reusing connection related information
  1331. @cindex caching
  1332. @vindex tramp-persistency-file-name
  1333. In order to reduce initial connection time, @value{tramp} stores
  1334. connection related information persistently. The variable
  1335. @code{tramp-persistency-file-name} keeps the file name where these
  1336. information are written. Its default value is
  1337. @ifset emacs
  1338. @file{~/.emacs.d/tramp}.
  1339. @end ifset
  1340. @ifset xemacs
  1341. @file{~/.xemacs/tramp}.
  1342. @end ifset
  1343. It is recommended to choose a local file name.
  1344. @value{tramp} reads this file during startup, and writes it when
  1345. exiting @value{emacsname}. You can simply remove this file if
  1346. @value{tramp} shall be urged to recompute these information next
  1347. @value{emacsname} startup time.
  1348. Using such persistent information can be disabled by setting
  1349. @code{tramp-persistency-file-name} to @code{nil}.
  1350. Once consequence of reusing connection related information is that
  1351. @var{tramp} needs to distinguish hosts. If you, for example, run a
  1352. local @code{sshd} on port 3001, which tunnels @command{ssh} to another
  1353. host, you could access both @file{@trampfn{ssh, , localhost,}} and
  1354. @file{@trampfn{ssh, , localhost#3001,}}. @var{tramp} would use the
  1355. same host related information (like paths, Perl variants, etc) for
  1356. both connections, although the information is valid only for one of
  1357. them.
  1358. In order to avoid trouble, you must use another host name for one of
  1359. the connections, like introducing a @option{Host} section in
  1360. @file{~/.ssh/config} (@pxref{Frequently Asked Questions}) or applying
  1361. multiple hops (@pxref{Multi-hops}).
  1362. When @value{tramp} detects a changed operating system version on a
  1363. remote host (via the command @command{uname -sr}), it flushes all
  1364. connection related information for this host, and opens the
  1365. connection again.
  1366. @node Predefined connection information
  1367. @section Setting own connection related information
  1368. Sometimes, @var{tramp} is not able to detect correct connection
  1369. related information. In such cases, you could tell @var{tramp} which
  1370. value it has to take. Since this could result in errors, it has to be
  1371. used with care.
  1372. @vindex tramp-connection-properties
  1373. Such settings can be performed via the list
  1374. @code{tramp-connection-properties}. An entry in this list has the
  1375. form @code{(@var{regexp} @var{property} @var{value})}. @var{regexp}
  1376. matches remote file names for which a property shall be predefined.
  1377. It can be @code{nil}. @var{property} is a string, and @var{value} the
  1378. corresponding value. @var{property} could be any property found in
  1379. the file @code{tramp-persistency-file-name}.
  1380. A special property is @code{"busybox"}. This must be set, if the
  1381. remote host runs a very restricted busybox as shell, which closes the
  1382. connection at will. Since there is no reliable test for this,
  1383. @var{tramp} must be indicated this way. Example:
  1384. @lisp
  1385. (add-to-list 'tramp-connection-properties
  1386. (list (regexp-quote "@trampfn{ssh, user, randomhost.your.domain,}")
  1387. "busybox" t))
  1388. @end lisp
  1389. @node Remote Programs
  1390. @section How @value{tramp} finds and uses programs on the remote host
  1391. @value{tramp} depends on a number of programs on the remote host in order to
  1392. function, including @command{ls}, @command{test}, @command{find} and
  1393. @command{cat}.
  1394. In addition to these required tools, there are various tools that may be
  1395. required based on the connection method. See @ref{Inline methods} and
  1396. @ref{External methods} for details on these.
  1397. Certain other tools, such as @command{perl} (or @command{perl5}) and
  1398. @command{grep} will be used if they can be found. When they are
  1399. available, they are used to improve the performance and accuracy of
  1400. remote file access.
  1401. @vindex tramp-remote-path
  1402. @vindex tramp-default-remote-path
  1403. @vindex tramp-own-remote-path
  1404. @defopt tramp-remote-path
  1405. When @value{tramp} connects to the remote host, it searches for the
  1406. programs that it can use. The customer option
  1407. @option{tramp-remote-path} controls the directories searched on the
  1408. remote host.
  1409. By default, this is set to a reasonable set of defaults for most
  1410. hosts. The symbol @code{tramp-default-remote-path} is a place
  1411. holder, it is replaced by the list of directories received via the
  1412. command @command{getconf PATH} on your remote host. For example,
  1413. on Debian GNU/Linux this is @file{/bin:/usr/bin}, whereas on Solaris
  1414. this is @file{/usr/xpg4/bin:/usr/ccs/bin:/usr/bin:/opt/SUNWspro/bin}.
  1415. It is recommended to apply this symbol on top of
  1416. @option{tramp-remote-path}.
  1417. It is possible, however, that your local (or remote ;) system
  1418. administrator has put the tools you want in some obscure local
  1419. directory.
  1420. In this case, you can still use them with @value{tramp}. You simply
  1421. need to add code to your @file{.emacs} to add the directory to the
  1422. remote path. This will then be searched by @value{tramp} when you
  1423. connect and the software found.
  1424. To add a directory to the remote search path, you could use code such
  1425. as:
  1426. @lisp
  1427. @i{;; We load @value{tramp} to define the variable.}
  1428. (require 'tramp)
  1429. @i{;; We have @command{perl} in "/usr/local/perl/bin"}
  1430. (add-to-list 'tramp-remote-path "/usr/local/perl/bin")
  1431. @end lisp
  1432. Another possibility is to reuse the path settings of your remote
  1433. account when you log in. Usually, these settings are overwritten,
  1434. because they might not be useful for @value{tramp}. The place holder
  1435. @code{tramp-own-remote-path} preserves these settings. You can
  1436. activate it via
  1437. @lisp
  1438. (add-to-list 'tramp-remote-path 'tramp-own-remote-path)
  1439. @end lisp
  1440. @end defopt
  1441. @value{tramp} caches several information, like the Perl binary
  1442. location. The changed remote search path wouldn't affect these
  1443. settings. In order to force @value{tramp} to recompute these values,
  1444. you must exit @value{emacsname}, remove your persistency file
  1445. (@pxref{Connection caching}), and restart @value{emacsname}.
  1446. @node Remote shell setup
  1447. @section Remote shell setup hints
  1448. @cindex remote shell setup
  1449. @cindex @file{.profile} file
  1450. @cindex @file{.login} file
  1451. @cindex shell init files
  1452. As explained in the @ref{Overview} section, @value{tramp} connects to the
  1453. remote host and talks to the shell it finds there. Of course, when you
  1454. log in, the shell executes its init files. Suppose your init file
  1455. requires you to enter the birth date of your mother; clearly @value{tramp}
  1456. does not know this and hence fails to log you in to that host.
  1457. There are different possible strategies for pursuing this problem. One
  1458. strategy is to enable @value{tramp} to deal with all possible situations.
  1459. This is a losing battle, since it is not possible to deal with
  1460. @emph{all} situations. The other strategy is to require you to set up
  1461. the remote host such that it behaves like @value{tramp} expects. This might
  1462. be inconvenient because you have to invest a lot of effort into shell
  1463. setup before you can begin to use @value{tramp}.
  1464. The package, therefore, pursues a combined approach. It tries to
  1465. figure out some of the more common setups, and only requires you to
  1466. avoid really exotic stuff. For example, it looks through a list of
  1467. directories to find some programs on the remote host. And also, it
  1468. knows that it is not obvious how to check whether a file exists, and
  1469. therefore it tries different possibilities. (On some hosts and
  1470. shells, the command @command{test -e} does the trick, on some hosts
  1471. the shell builtin doesn't work but the program @command{/usr/bin/test
  1472. -e} or @command{/bin/test -e} works. And on still other hosts,
  1473. @command{ls -d} is the right way to do this.)
  1474. Below you find a discussion of a few things that @value{tramp} does not deal
  1475. with, and that you therefore have to set up correctly.
  1476. @table @asis
  1477. @item @var{shell-prompt-pattern}
  1478. @vindex shell-prompt-pattern
  1479. After logging in to the remote host, @value{tramp} has to wait for the remote
  1480. shell startup to finish before it can send commands to the remote
  1481. shell. The strategy here is to wait for the shell prompt. In order to
  1482. recognize the shell prompt, the variable @code{shell-prompt-pattern} has
  1483. to be set correctly to recognize the shell prompt on the remote host.
  1484. Note that @value{tramp} requires the match for @code{shell-prompt-pattern}
  1485. to be at the end of the buffer. Many people have something like the
  1486. following as the value for the variable: @code{"^[^>$][>$] *"}. Now
  1487. suppose your shell prompt is @code{a <b> c $ }. In this case,
  1488. @value{tramp} recognizes the @code{>} character as the end of the prompt,
  1489. but it is not at the end of the buffer.
  1490. @item @var{tramp-shell-prompt-pattern}
  1491. @vindex tramp-shell-prompt-pattern
  1492. This regular expression is used by @value{tramp} in the same way as
  1493. @code{shell-prompt-pattern}, to match prompts from the remote shell.
  1494. This second variable exists because the prompt from the remote shell
  1495. might be different from the prompt from a local shell---after all,
  1496. the whole point of @value{tramp} is to log in to remote hosts as a
  1497. different user. The default value of
  1498. @code{tramp-shell-prompt-pattern} is the same as the default value of
  1499. @code{shell-prompt-pattern}, which is reported to work well in many
  1500. circumstances.
  1501. @item @var{tramp-password-prompt-regexp}
  1502. @vindex tramp-password-prompt-regexp
  1503. @vindex tramp-wrong-passwd-regexp
  1504. During login, @value{tramp} might be forced to enter a password or a
  1505. passphrase. The difference between both is that a password is
  1506. requested from the shell on the remote host, while a passphrase is
  1507. needed for accessing local authentication information, like your ssh
  1508. key.
  1509. @var{tramp-password-prompt-regexp} handles the detection of such
  1510. requests for English environments. When you use another localization
  1511. of your (local or remote) host, you might need to adapt this. Example:
  1512. @lisp
  1513. (setq
  1514. tramp-password-prompt-regexp
  1515. (concat
  1516. "^.*"
  1517. (regexp-opt
  1518. '("passphrase" "Passphrase"
  1519. ;; English
  1520. "password" "Password"
  1521. ;; Deutsch
  1522. "passwort" "Passwort"
  1523. ;; Fran@,{c}ais
  1524. "mot de passe" "Mot de passe") t)
  1525. ".*:\0? *"))
  1526. @end lisp
  1527. In parallel, it might also be necessary to adapt
  1528. @var{tramp-wrong-passwd-regexp}.
  1529. @item @command{tset} and other questions
  1530. @cindex Unix command tset
  1531. @cindex tset Unix command
  1532. Some people invoke the @command{tset} program from their shell startup
  1533. scripts which asks the user about the terminal type of the shell.
  1534. Maybe some shells ask other questions when they are started.
  1535. @value{tramp} does not know how to answer these questions. There are
  1536. two approaches for dealing with this problem. One approach is to take
  1537. care that the shell does not ask any questions when invoked from
  1538. @value{tramp}. You can do this by checking the @env{TERM}
  1539. environment variable, it will be set to @code{dumb} when connecting.
  1540. @vindex tramp-terminal-type
  1541. The variable @code{tramp-terminal-type} can be used to change this value
  1542. to @code{dumb}.
  1543. @vindex tramp-actions-before-shell
  1544. The other approach is to teach @value{tramp} about these questions. See
  1545. the variable @code{tramp-actions-before-shell}. Example:
  1546. @lisp
  1547. (defconst my-tramp-prompt-regexp
  1548. (concat (regexp-opt '("Enter the birth date of your mother:") t)
  1549. "\\s-*")
  1550. "Regular expression matching my login prompt question.")
  1551. (defun my-tramp-action (proc vec)
  1552. "Enter \"19000101\" in order to give a correct answer."
  1553. (save-window-excursion
  1554. (with-current-buffer (tramp-get-connection-buffer vec)
  1555. (tramp-message vec 6 "\n%s" (buffer-string))
  1556. (tramp-send-string vec "19000101"))))
  1557. (add-to-list 'tramp-actions-before-shell
  1558. '(my-tramp-prompt-regexp my-tramp-action))
  1559. @end lisp
  1560. @item Environment variables named like users in @file{.profile}
  1561. If you have a user named frumple and set the variable @env{FRUMPLE} in
  1562. your shell environment, then this might cause trouble. Maybe rename
  1563. the variable to @env{FRUMPLE_DIR} or the like.
  1564. This weird effect was actually reported by a @value{tramp} user!
  1565. @item Non-Bourne commands in @file{.profile}
  1566. After logging in to the remote host, @value{tramp} issues the command
  1567. @command{exec /bin/sh}. (Actually, the command is slightly
  1568. different.) When @command{/bin/sh} is executed, it reads some init
  1569. files, such as @file{~/.shrc} or @file{~/.profile}.
  1570. Now, some people have a login shell which is not @code{/bin/sh} but a
  1571. Bourne-ish shell such as bash or ksh. Some of these people might put
  1572. their shell setup into the files @file{~/.shrc} or @file{~/.profile}.
  1573. This way, it is possible for non-Bourne constructs to end up in those
  1574. files. Then, @command{exec /bin/sh} might cause the Bourne shell to
  1575. barf on those constructs.
  1576. As an example, imagine somebody putting @command{export FOO=bar} into
  1577. the file @file{~/.profile}. The standard Bourne shell does not
  1578. understand this syntax and will emit a syntax error when it reaches
  1579. this line.
  1580. Another example is the tilde (@code{~}) character, say when adding
  1581. @file{~/bin} to @env{PATH}. Many Bourne shells will not expand this
  1582. character, and since there is usually no directory whose name consists
  1583. of the single character tilde, strange things will happen.
  1584. What can you do about this?
  1585. Well, one possibility is to make sure that everything in
  1586. @file{~/.shrc} and @file{~/.profile} on all remote hosts is
  1587. Bourne-compatible. In the above example, instead of @command{export
  1588. FOO=bar}, you might use @command{FOO=bar; export FOO} instead.
  1589. The other possibility is to put your non-Bourne shell setup into some
  1590. other files. For example, bash reads the file @file{~/.bash_profile}
  1591. instead of @file{~/.profile}, if the former exists. So bash
  1592. aficionados just rename their @file{~/.profile} to
  1593. @file{~/.bash_profile} on all remote hosts, and Bob's your uncle.
  1594. The @value{tramp} developers would like to circumvent this problem, so
  1595. if you have an idea about it, please tell us. However, we are afraid
  1596. it is not that simple: before saying @command{exec /bin/sh},
  1597. @value{tramp} does not know which kind of shell it might be talking
  1598. to. It could be a Bourne-ish shell like ksh or bash, or it could be a
  1599. csh derivative like tcsh, or it could be zsh, or even rc. If the
  1600. shell is Bourne-ish already, then it might be prudent to omit the
  1601. @command{exec /bin/sh} step. But how to find out if the shell is
  1602. Bourne-ish?
  1603. @item Interactive shell prompt
  1604. @value{tramp} redefines the shell prompt in order to parse the shell's
  1605. output robustly. When calling an interactive shell by @kbd{M-x
  1606. shell}, this doesn't look nice.
  1607. You can redefine the shell prompt by checking the environment variable
  1608. @env{INSIDE_EMACS}, which is set by @value{tramp}, in your startup
  1609. script @file{~/.emacs_SHELLNAME}. @env{SHELLNAME} might be the string
  1610. @code{bash} or similar, in case of doubt you could set it the
  1611. environment variable @env{ESHELL} in your @file{.emacs}:
  1612. @lisp
  1613. (setenv "ESHELL" "bash")
  1614. @end lisp
  1615. Your file @file{~/.emacs_SHELLNAME} could contain code like
  1616. @example
  1617. # Reset the prompt for remote Tramp shells.
  1618. if [ "$@{INSIDE_EMACS/*tramp*/tramp@}" == "tramp" ] ; then
  1619. PS1="[\u@@\h \w]$ "
  1620. fi
  1621. @end example
  1622. @ifinfo
  1623. @ifset emacs
  1624. @xref{Interactive Shell, , , @value{emacsdir}}.
  1625. @end ifset
  1626. @end ifinfo
  1627. @item @command{busybox} / @command{nc}
  1628. @cindex Unix command nc
  1629. @cindex nc Unix command
  1630. The @command{nc} command will be used with the @option{nc} method. On
  1631. the remote host, a listener will be installed. Unfortunately, the
  1632. command line syntax for this has been changed with the different
  1633. @command{busybox} versions. @value{tramp} uses the following syntax
  1634. (see @code{tramp-methods}):
  1635. @example
  1636. # nc -l -p 42
  1637. @end example
  1638. If your remote @command{nc} refuses to accept the @command{-p}
  1639. parameter, you could overwrite the syntax with the following form:
  1640. @lisp
  1641. (add-to-list
  1642. 'tramp-connection-properties
  1643. `(,(regexp-quote "192.168.0.1") "remote-copy-args" (("-l") ("%r"))))
  1644. @end lisp
  1645. @noindent
  1646. with @samp{192.168.0.1} being the IP address of your remote host
  1647. (@pxref{Predefined connection information}).
  1648. @end table
  1649. @node Android shell setup
  1650. @section Android shell setup hints
  1651. @cindex android shell setup
  1652. Android devices use a restricted shell. They can be accessed via the
  1653. @option{adb} method. However, this restricts the access to a USB
  1654. connection, and it requires the installation of the Android SDK on the
  1655. local host.
  1656. When an @command{sshd} process runs on the Android device, like
  1657. provided by the @code{SSHDroid} app, any @option{ssh}-based method can
  1658. be used. This requires some special settings.
  1659. The default shell @code{/bin/sh} does not exist. Instead, you shall
  1660. use just @code{sh}, which invokes the shell installed on the device.
  1661. You can instruct @value{tramp} by this form:
  1662. @lisp
  1663. (add-to-list 'tramp-connection-properties
  1664. (list (regexp-quote "192.168.0.26") "remote-shell" "sh"))
  1665. @end lisp
  1666. @noindent
  1667. with @samp{192.168.0.26} being the IP address of your Android device
  1668. (@pxref{Predefined connection information}).
  1669. The user settings for the @env{PATH} environment variable must be
  1670. preserved. It has also been reported, that the commands in
  1671. @file{/system/xbin} are better suited than the ones in
  1672. @file{/system/bin}. Add these setting:
  1673. @lisp
  1674. (add-to-list 'tramp-remote-path 'tramp-own-remote-path)
  1675. (add-to-list 'tramp-remote-path "/system/xbin")
  1676. @end lisp
  1677. @noindent
  1678. If the Android device is not @samp{rooted}, you must give the shell a
  1679. writable directory for temporary files:
  1680. @lisp
  1681. (add-to-list 'tramp-remote-process-environment "TMPDIR=$HOME")
  1682. @end lisp
  1683. @noindent
  1684. Now you shall be able to open a remote connection with @kbd{C-x C-f
  1685. @trampfn{ssh, , 192.168.0.26#2222, }}, given that @command{sshd}
  1686. listens on port @samp{2222}.
  1687. It is also recommended to add a corresponding entry to your
  1688. @file{~/.ssh/config} for that connection, like
  1689. @example
  1690. Host android
  1691. HostName 192.168.0.26
  1692. User root
  1693. Port 2222
  1694. @end example
  1695. @noindent
  1696. In this case, you must change the setting for the remote shell to
  1697. @lisp
  1698. (add-to-list 'tramp-connection-properties
  1699. (list (regexp-quote "android") "remote-shell" "sh"))
  1700. @end lisp
  1701. @noindent
  1702. You would open the connection with @kbd{C-x C-f @trampfn{ssh, ,
  1703. android, }} then.
  1704. @node Auto-save and Backup
  1705. @section Auto-save and Backup configuration
  1706. @cindex auto-save
  1707. @cindex backup
  1708. @ifset emacs
  1709. @vindex backup-directory-alist
  1710. @end ifset
  1711. @ifset xemacs
  1712. @vindex bkup-backup-directory-info
  1713. @end ifset
  1714. Normally, @value{emacsname} writes backup files to the same directory
  1715. as the original files, but this behavior can be changed via the
  1716. variable
  1717. @ifset emacs
  1718. @code{backup-directory-alist}.
  1719. @end ifset
  1720. @ifset xemacs
  1721. @code{bkup-backup-directory-info}.
  1722. @end ifset
  1723. In connection with @value{tramp}, this can have unexpected side
  1724. effects. Suppose that you specify that all backups should go to the
  1725. directory @file{~/.emacs.d/backups/}, and then you edit the file
  1726. @file{@trampfn{su, root, localhost, /etc/secretfile}}. The effect is
  1727. that the backup file will be owned by you and not by root, thus
  1728. possibly enabling others to see it even if they were not intended to
  1729. see it.
  1730. When
  1731. @ifset emacs
  1732. @code{backup-directory-alist}
  1733. @end ifset
  1734. @ifset xemacs
  1735. @code{bkup-backup-directory-info}
  1736. @end ifset
  1737. is @code{nil} (the default), such problems do not occur.
  1738. Therefore, it is useful to set special values for @value{tramp}
  1739. files. For example, the following statement effectively ``turns off''
  1740. the effect of
  1741. @ifset emacs
  1742. @code{backup-directory-alist}
  1743. @end ifset
  1744. @ifset xemacs
  1745. @code{bkup-backup-directory-info}
  1746. @end ifset
  1747. for @value{tramp} files:
  1748. @ifset emacs
  1749. @lisp
  1750. (add-to-list 'backup-directory-alist
  1751. (cons tramp-file-name-regexp nil))
  1752. @end lisp
  1753. @end ifset
  1754. @ifset xemacs
  1755. @lisp
  1756. (require 'backup-dir)
  1757. (add-to-list 'bkup-backup-directory-info
  1758. (list tramp-file-name-regexp ""))
  1759. @end lisp
  1760. @end ifset
  1761. @ifset emacs
  1762. It is also possible to disable backups depending on the used method.
  1763. The following code disables backups for the @option{su} and
  1764. @option{sudo} methods:
  1765. @lisp
  1766. (setq backup-enable-predicate
  1767. (lambda (name)
  1768. (and (normal-backup-enable-predicate name)
  1769. (not
  1770. (let ((method (file-remote-p name 'method)))
  1771. (when (stringp method)
  1772. (member method '("su" "sudo"))))))))
  1773. @end lisp
  1774. @end ifset
  1775. Another possibility is to use the @value{tramp} variable
  1776. @ifset emacs
  1777. @code{tramp-backup-directory-alist}.
  1778. @end ifset
  1779. @ifset xemacs
  1780. @code{tramp-bkup-backup-directory-info}.
  1781. @end ifset
  1782. This variable has the same meaning like
  1783. @ifset emacs
  1784. @code{backup-directory-alist}.
  1785. @end ifset
  1786. @ifset xemacs
  1787. @code{bkup-backup-directory-info}.
  1788. @end ifset
  1789. If a @value{tramp} file is backed up, and DIRECTORY is an absolute
  1790. local file name, DIRECTORY is prepended with the @value{tramp} file
  1791. name prefix of the file to be backed up.
  1792. @noindent
  1793. Example:
  1794. @ifset emacs
  1795. @lisp
  1796. (add-to-list 'backup-directory-alist
  1797. (cons "." "~/.emacs.d/backups/"))
  1798. (setq tramp-backup-directory-alist backup-directory-alist)
  1799. @end lisp
  1800. @end ifset
  1801. @ifset xemacs
  1802. @lisp
  1803. (require 'backup-dir)
  1804. (add-to-list 'bkup-backup-directory-info
  1805. (list "." "~/.emacs.d/backups/" 'full-path))
  1806. (setq tramp-bkup-backup-directory-info bkup-backup-directory-info)
  1807. @end lisp
  1808. @end ifset
  1809. @noindent
  1810. The backup file name of @file{@trampfn{su, root, localhost,
  1811. /etc/secretfile}} would be
  1812. @ifset emacs
  1813. @file{@trampfn{su, root, localhost,
  1814. ~/.emacs.d/backups/!su:root@@localhost:!etc!secretfile~}}
  1815. @end ifset
  1816. @ifset xemacs
  1817. @file{@trampfn{su, root, localhost,
  1818. ~/.emacs.d/backups/![su!root@@localhost]!etc!secretfile~}}
  1819. @end ifset
  1820. The same problem can happen with auto-saving files.
  1821. @ifset emacs
  1822. The variable @code{auto-save-file-name-transforms} keeps information,
  1823. on which directory an auto-saved file should go. By default, it is
  1824. initialized for @value{tramp} files to the local temporary directory.
  1825. On some versions of @value{emacsname}, namely the version built for
  1826. Debian GNU/Linux, the variable @code{auto-save-file-name-transforms}
  1827. contains the directory where @value{emacsname} was built. A
  1828. workaround is to manually set the variable to a sane value.
  1829. If auto-saved files should go into the same directory as the original
  1830. files, @code{auto-save-file-name-transforms} should be set to @code{nil}.
  1831. Another possibility is to set the variable
  1832. @code{tramp-auto-save-directory} to a proper value.
  1833. @end ifset
  1834. @ifset xemacs
  1835. For this purpose you can set the variable @code{auto-save-directory}
  1836. to a proper value.
  1837. @end ifset
  1838. @node Windows setup hints
  1839. @section Issues with Cygwin ssh
  1840. @cindex Cygwin, issues
  1841. This section needs a lot of work! Please help.
  1842. @cindex method sshx with Cygwin
  1843. @cindex sshx method with Cygwin
  1844. The recent Cygwin installation of @command{ssh} works only with a
  1845. Cygwinized @value{emacsname}. You can check it by typing @kbd{M-x
  1846. eshell}, and starting @kbd{ssh test.host}. The problem is evident
  1847. if you see a message like this:
  1848. @example
  1849. Pseudo-terminal will not be allocated because stdin is not a terminal.
  1850. @end example
  1851. Older @command{ssh} versions of Cygwin are told to cooperate with
  1852. @value{tramp} selecting @option{sshx} as the connection method. You
  1853. can find information about setting up Cygwin in their FAQ at
  1854. @uref{http://cygwin.com/faq/}.
  1855. @cindex method scpx with Cygwin
  1856. @cindex scpx method with Cygwin
  1857. If you wish to use the @option{scpx} connection method, then you might
  1858. have the problem that @value{emacsname} calls @command{scp} with a
  1859. Windows file name such as @code{c:/foo}. The Cygwin version of
  1860. @command{scp} does not know about Windows file names and interprets
  1861. this as a remote file name on the host @code{c}.
  1862. One possible workaround is to write a wrapper script for @option{scp}
  1863. which converts the Windows file name to a Cygwinized file name.
  1864. @cindex Cygwin and ssh-agent
  1865. @cindex SSH_AUTH_SOCK and @value{emacsname} on Windows
  1866. If you want to use either @option{ssh} based method on Windows, then
  1867. you might encounter problems with @command{ssh-agent}. Using this
  1868. program, you can avoid typing the pass-phrase every time you log in.
  1869. However, if you start @value{emacsname} from a desktop shortcut, then
  1870. the environment variable @env{SSH_AUTH_SOCK} is not set and so
  1871. @value{emacsname} and thus @value{tramp} and thus @command{ssh} and
  1872. @command{scp} started from @value{tramp} cannot communicate with
  1873. @command{ssh-agent}. It works better to start @value{emacsname} from
  1874. the shell.
  1875. If anyone knows how to start @command{ssh-agent} under Windows in such a
  1876. way that desktop shortcuts can profit, please holler. I don't really
  1877. know anything at all about Windows@dots{}
  1878. @node Usage
  1879. @chapter Using @value{tramp}
  1880. @cindex using @value{tramp}
  1881. Once you have installed @value{tramp} it will operate fairly
  1882. transparently. You will be able to access files on any remote host
  1883. that you can log in to as though they were local.
  1884. Files are specified to @value{tramp} using a formalized syntax specifying the
  1885. details of the system to connect to. This is similar to the syntax used
  1886. by the @value{ftppackagename} package.
  1887. @cindex type-ahead
  1888. Something that might happen which surprises you is that
  1889. @value{emacsname} remembers all your keystrokes, so if you see a
  1890. password prompt from @value{emacsname}, say, and hit @kbd{@key{RET}}
  1891. twice instead of once, then the second keystroke will be processed by
  1892. @value{emacsname} after @value{tramp} has done its thing. Why, this
  1893. type-ahead is normal behavior, you say. Right you are, but be aware
  1894. that opening a remote file might take quite a while, maybe half a
  1895. minute when a connection needs to be opened. Maybe after half a
  1896. minute you have already forgotten that you hit that key!
  1897. @menu
  1898. * File name Syntax:: @value{tramp} file name conventions.
  1899. * File name completion:: File name completion.
  1900. * Ad-hoc multi-hops:: Declaring multiple hops in the file name.
  1901. * Remote processes:: Integration with other @value{emacsname} packages.
  1902. * Cleanup remote connections:: Cleanup remote connections.
  1903. @end menu
  1904. @node File name Syntax
  1905. @section @value{tramp} file name conventions
  1906. @cindex file name syntax
  1907. @cindex file name examples
  1908. To access the file @var{localname} on the remote host @var{host}
  1909. you would specify the file name @file{@trampfn{, , host,
  1910. localname}}. This will connect to @var{host} and transfer the file
  1911. using the default method. @xref{Default Method}.
  1912. Some examples of @value{tramp} file names are shown below.
  1913. @table @file
  1914. @item @value{prefix}melancholia@value{postfix}.emacs
  1915. Edit the file @file{.emacs} in your home directory on the host
  1916. @code{melancholia}.
  1917. @item @value{prefix}melancholia.danann.net@value{postfix}.emacs
  1918. This edits the same file, using the fully qualified domain name of
  1919. the host.
  1920. @item @value{prefix}melancholia@value{postfix}~/.emacs
  1921. This also edits the same file; the @file{~} is expanded to your
  1922. home directory on the remote host, just like it is locally.
  1923. @item @value{prefix}melancholia@value{postfix}~daniel/.emacs
  1924. This edits the file @file{.emacs} in the home directory of the user
  1925. @code{daniel} on the host @code{melancholia}. The @file{~<user>}
  1926. construct is expanded to the home directory of that user on the remote
  1927. host.
  1928. @item @value{prefix}melancholia@value{postfix}/etc/squid.conf
  1929. This edits the file @file{/etc/squid.conf} on the host
  1930. @code{melancholia}.
  1931. @end table
  1932. @var{host} can also be an IPv4 or IPv6 address, like in
  1933. @file{@trampfn{, , 127.0.0.1, .emacs}} or @file{@trampfn{, ,
  1934. @value{ipv6prefix}::1@value{ipv6postfix}, .emacs}}.
  1935. @ifset emacs
  1936. For syntactical reasons, IPv6 addresses must be embedded in square
  1937. brackets @file{@value{ipv6prefix}} and @file{@value{ipv6postfix}}.
  1938. @end ifset
  1939. Unless you specify a different name to use, @value{tramp} will use the
  1940. current local user name as the remote user name to log in with. If you
  1941. need to log in as a different user, you can specify the user name as
  1942. part of the file name.
  1943. To log in to the remote host as a specific user, you use the syntax
  1944. @file{@trampfn{, user, host, path/to.file}}. That means that
  1945. connecting to @code{melancholia} as @code{daniel} and editing
  1946. @file{.emacs} in your home directory you would specify
  1947. @file{@trampfn{, daniel, melancholia, .emacs}}.
  1948. It is also possible to specify other file transfer methods
  1949. (@pxref{Inline methods}, @pxref{External methods}) as part of the
  1950. file name.
  1951. @ifset emacs
  1952. This is done by putting the method before the user and host name, as
  1953. in @file{@value{prefix}@var{method}@value{postfixhop}} (Note the
  1954. trailing colon).
  1955. @end ifset
  1956. @ifset xemacs
  1957. This is done by replacing the initial @file{@value{prefix}} with
  1958. @file{@value{prefix}<method>@value{postfixhop}}. (Note the trailing
  1959. slash!).
  1960. @end ifset
  1961. The user, host and file specification remain the same.
  1962. So, to connect to the host @code{melancholia} as @code{daniel},
  1963. using the @option{ssh} method to transfer files, and edit
  1964. @file{.emacs} in my home directory I would specify the file name
  1965. @file{@trampfn{ssh, daniel, melancholia, .emacs}}.
  1966. @ifset emacs
  1967. A remote file name containing a host name only, which is equal to a
  1968. method name, is not allowed. If such a host name is used, it must
  1969. always be preceded by an explicit method name, like
  1970. @file{@value{prefix}ssh@value{postfixhop}ssh@value{postfix}}.
  1971. @end ifset
  1972. Finally, for some methods it is possible to specify a different port
  1973. number than the default one, given by the method. This is specified
  1974. by adding @file{#<port>} to the host name, like in @file{@trampfn{ssh,
  1975. daniel, melancholia#42, .emacs}}.
  1976. @node File name completion
  1977. @section File name completion
  1978. @cindex file name completion
  1979. File name completion works with @value{tramp} for completion of method
  1980. names, of user names and of host names as well as for completion of
  1981. file names on remote hosts.
  1982. @ifset emacs
  1983. In order to enable this, partial completion must be activated in your
  1984. @file{.emacs}.
  1985. @ifinfo
  1986. @xref{Completion Options, , , @value{emacsdir}}.
  1987. @end ifinfo
  1988. @end ifset
  1989. If you, for example, type @kbd{C-x C-f @value{prefix}t
  1990. @key{TAB}}, @value{tramp} might give you as result the choice for
  1991. @example
  1992. @c @multitable {@trampfn{telnet, , melancholia.danann.net,}} {@trampfn{telnet, , 192.168.0.1,}}
  1993. @multitable @columnfractions .5 .5
  1994. @ifset emacs
  1995. @item @value{prefixhop}telnet@value{postfixhop} @tab tmp/
  1996. @item @value{prefixhop}toto@value{postfix} @tab
  1997. @end ifset
  1998. @ifset xemacs
  1999. @item @value{prefixhop}telnet@value{postfixhop} @tab @value{prefixhop}toto@value{postfix}
  2000. @end ifset
  2001. @end multitable
  2002. @end example
  2003. @samp{@value{prefixhop}telnet@value{postfixhop}}
  2004. is a possible completion for the respective method,
  2005. @ifset emacs
  2006. @samp{tmp/} stands for the directory @file{/tmp} on your local host,
  2007. @end ifset
  2008. and @samp{@value{prefixhop}toto@value{postfix}}
  2009. might be a host @value{tramp} has detected in your @file{~/.ssh/known_hosts}
  2010. file (given you're using default method @option{ssh}).
  2011. If you go on to type @kbd{e @key{TAB}}, the minibuffer is completed to
  2012. @samp{@value{prefix}telnet@value{postfixhop}}.
  2013. Next @kbd{@key{TAB}} brings you all host names @value{tramp} detects in
  2014. your @file{/etc/hosts} file, let's say
  2015. @example
  2016. @multitable @columnfractions .5 .5
  2017. @c @multitable {@trampfn{telnet, , melancholia.danann.net,}} {@trampfn{telnet, , 192.168.0.1,}}
  2018. @item @trampfn{telnet, , 127.0.0.1,} @tab @trampfn{telnet, , 192.168.0.1,}
  2019. @item @trampfn{telnet, , @value{ipv6prefix}::1@value{ipv6postfix},} @tab @trampfn{telnet, , localhost,}
  2020. @item @trampfn{telnet, , melancholia.danann.net,} @tab @trampfn{telnet, , melancholia,}
  2021. @end multitable
  2022. @end example
  2023. Now you can choose the desired host, and you can continue to
  2024. complete file names on that host.
  2025. If the configuration files (@pxref{Customizing Completion}), which
  2026. @value{tramp} uses for analysis of completion, offer user names, those user
  2027. names will be taken into account as well.
  2028. Remote hosts which have been visited in the past and kept
  2029. persistently (@pxref{Connection caching}) will be offered too.
  2030. Once the remote host identification is completed, it comes to
  2031. file name completion on the remote host. This works pretty much like
  2032. for files on the local host, with the exception that minibuffer
  2033. killing via a double-slash works only on the file name part, except
  2034. that file name part starts with @file{//}.
  2035. @ifset emacs
  2036. A triple-slash stands for the default behavior.
  2037. @end ifset
  2038. @ifinfo
  2039. @xref{Minibuffer File, , , @value{emacsdir}}.
  2040. @end ifinfo
  2041. @noindent
  2042. Example:
  2043. @example
  2044. @ifset emacs
  2045. @kbd{C-x C-f @trampfn{telnet, , melancholia, /usr/local/bin//etc} @key{TAB}}
  2046. @print{} @trampfn{telnet, , melancholia, /etc}
  2047. @kbd{C-x C-f @trampfn{telnet, , melancholia, //etc} @key{TAB}}
  2048. @print{} /etc
  2049. @kbd{C-x C-f @trampfn{telnet, , melancholia, /usr/local/bin///etc} @key{TAB}}
  2050. @print{} /etc
  2051. @end ifset
  2052. @ifset xemacs
  2053. @kbd{C-x C-f @trampfn{telnet, , melancholia, /usr/local/bin//}}
  2054. @print{} @trampfn{telnet, , melancholia, /}
  2055. @kbd{C-x C-f @trampfn{telnet, , melancholia, //}}
  2056. @print{} /
  2057. @end ifset
  2058. @end example
  2059. A remote directory might have changed its contents out of
  2060. @value{emacsname} control, for example by creation or deletion of
  2061. files by other processes. Therefore, during file name completion, the
  2062. remote directory contents are reread regularly in order to detect such
  2063. changes, which would be invisible otherwise (@pxref{Connection caching}).
  2064. @vindex tramp-completion-reread-directory-timeout
  2065. @defopt tramp-completion-reread-directory-timeout
  2066. This customer option defines the number of seconds since last remote
  2067. command before rereading a directory contents. A value of 0 would
  2068. require an immediate reread during file name completion, @code{nil}
  2069. means to use always cached values for the directory contents.
  2070. @end defopt
  2071. @node Ad-hoc multi-hops
  2072. @section Declaring multiple hops in the file name
  2073. @cindex multi-hop, ad-hoc
  2074. @cindex proxy hosts, ad-hoc
  2075. Multiple hops are configured with the variable
  2076. @code{tramp-default-proxies-alist} (@pxref{Multi-hops}). However,
  2077. sometimes it is desirable to reach a remote host immediately, without
  2078. configuration changes. This can be reached by an ad-hoc specification
  2079. of the proxies.
  2080. A proxy looks like a remote file name specification without the local
  2081. file name part. It is prepended to the target remote file name,
  2082. separated by @samp{|}. As an example, a remote file on
  2083. @samp{you@@remotehost}, passing the proxy @samp{bird@@bastion}, could
  2084. be opened by
  2085. @example
  2086. @c @kbd{C-x C-f @trampfn{ssh@value{postfixhop}bird@@bastion|ssh, you,
  2087. @c remotehost, /path}}
  2088. @kbd{C-x C-f @value{prefix}ssh@value{postfixhop}bird@@bastion|ssh@value{postfixhop}you@@remotehost@value{postfix}/path}
  2089. @end example
  2090. Multiple hops can be cascaded, separating all proxies by @samp{|}.
  2091. The proxies can also contain the patterns @code{%h} or @code{%u}.
  2092. The ad-hoc definition is added on the fly to
  2093. @code{tramp-default-proxies-alist}. Therefore, during the lifetime of
  2094. the @value{emacsname} session it is not necessary to enter this ad-hoc
  2095. specification, again. The remote file name @samp{@trampfn{ssh, you,
  2096. remotehost, /path}} would be sufficient from now on.
  2097. @vindex tramp-save-ad-hoc-proxies
  2098. @defopt tramp-save-ad-hoc-proxies
  2099. This customer option controls whether ad-hoc definitions are kept
  2100. persistently in @option{tramp-default-proxies-alist}. That means,
  2101. those definitions are available also for future @value{emacsname}
  2102. sessions.
  2103. @end defopt
  2104. @node Remote processes
  2105. @section Integration with other @value{emacsname} packages
  2106. @cindex compile
  2107. @cindex recompile
  2108. @value{tramp} supports running processes on a remote host. This
  2109. allows to exploit @value{emacsname} packages without modification for
  2110. remote file names. It does not work for the @option{ftp} method.
  2111. Association of a pty, as specified in @code{start-file-process}, is
  2112. not supported.
  2113. @code{process-file} and @code{start-file-process} work on the remote
  2114. host when the variable @code{default-directory} is remote:
  2115. @lisp
  2116. (let ((default-directory "/ssh:remote.host:"))
  2117. (start-file-process "grep" (get-buffer-create "*grep*")
  2118. "/bin/sh" "-c" "grep -e tramp *"))
  2119. @end lisp
  2120. @ifset emacsgvfs
  2121. If the remote host is mounted via GVFS (see @ref{GVFS based methods}),
  2122. the remote filesystem is mounted locally. Therefore, there are no
  2123. remote processes; all processes run still locally on your host with
  2124. an adapted @code{default-directory}. This section does not apply for
  2125. such connection methods.
  2126. @end ifset
  2127. Remote processes are started when a corresponding command is executed
  2128. from a buffer belonging to a remote file or directory. Up to now, the
  2129. packages @file{compile.el} (commands like @code{compile} and
  2130. @code{grep}) and @file{gud.el} (@code{gdb} or @code{perldb}) have been
  2131. integrated. Integration of further packages is planned, any help for
  2132. this is welcome!
  2133. When your program is not found in the default search path
  2134. @value{tramp} sets on the remote host, you should either use an
  2135. absolute path, or extend @code{tramp-remote-path} (see @ref{Remote
  2136. Programs}):
  2137. @lisp
  2138. (add-to-list 'tramp-remote-path "~/bin")
  2139. (add-to-list 'tramp-remote-path "/appli/pub/bin")
  2140. @end lisp
  2141. The environment for your program can be adapted by customizing
  2142. @code{tramp-remote-process-environment}. This variable is a list of
  2143. strings. It is structured like @code{process-environment}. Each
  2144. element is a string of the form @code{"ENVVARNAME=VALUE"}. An entry
  2145. @code{"ENVVARNAME="} disables the corresponding environment variable,
  2146. which might have been set in your init file like @file{~/.profile}.
  2147. @noindent
  2148. Adding an entry can be performed via @code{add-to-list}:
  2149. @lisp
  2150. (add-to-list 'tramp-remote-process-environment "JAVA_HOME=/opt/java")
  2151. @end lisp
  2152. Changing or removing an existing entry is not encouraged. The default
  2153. values are chosen for proper @value{tramp} work. Nevertheless, if for
  2154. example a paranoid system administrator disallows changing the
  2155. @env{HISTORY} environment variable, you can customize
  2156. @code{tramp-remote-process-environment}, or you can apply the
  2157. following code in your @file{.emacs}:
  2158. @lisp
  2159. (let ((process-environment tramp-remote-process-environment))
  2160. (setenv "HISTORY" nil)
  2161. (setq tramp-remote-process-environment process-environment))
  2162. @end lisp
  2163. When running @code{process-file} or @code{start-file-process} on a
  2164. remote @code{default-directory}, the default settings in
  2165. @code{process-environment} are not used as it is the case for local
  2166. processes. However, if you need environment variables other than set
  2167. in @code{tramp-remote-process-environment}, you can let-bind them to
  2168. @code{process-environment}. Only those variables will be set then:
  2169. @lisp
  2170. (let ((process-environment (cons "HGPLAIN=1" process-environment)))
  2171. (process-file @dots{}))
  2172. @end lisp
  2173. This works only for environment variables which are not set already in
  2174. @code{process-environment}.
  2175. If you use other @value{emacsname} packages which do not run
  2176. out-of-the-box on a remote host, please let us know. We will try to
  2177. integrate them as well. @xref{Bug Reports}.
  2178. @subsection Running remote programs that create local X11 windows
  2179. If you want to run a remote program, which shall connect the X11
  2180. server you are using with your local host, you can set the
  2181. @env{DISPLAY} environment variable on the remote host:
  2182. @lisp
  2183. (add-to-list 'tramp-remote-process-environment
  2184. (format "DISPLAY=%s" (getenv "DISPLAY")))
  2185. @end lisp
  2186. @noindent
  2187. @code{(getenv "DISPLAY")} shall return a string containing a host
  2188. name, which can be interpreted on the remote host; otherwise you might
  2189. use a fixed host name. Strings like @code{:0} cannot be used properly
  2190. on the remote host.
  2191. Another trick might be that you put @code{ForwardX11 yes} or
  2192. @code{ForwardX11Trusted yes} to your @file{~/.ssh/config} file for
  2193. that host.
  2194. @subsection Running @code{shell} on a remote host
  2195. @cindex shell
  2196. Calling @kbd{M-x shell} in a buffer related to a remote host runs the
  2197. local shell as defined in @option{shell-file-name}. This might be
  2198. also a valid file name for a shell to be applied on the remote host,
  2199. but it will fail at least when your local and remote hosts belong to
  2200. different system types, like @samp{windows-nt} and @samp{gnu/linux}.
  2201. You must set the variable @option{explicit-shell-file-name} to the
  2202. shell file name on the remote host, in order to start that shell on
  2203. the remote host.
  2204. @ifset emacs
  2205. Starting with Emacs 24 this won't be necessary, if you call
  2206. @code{shell} interactively. You will be asked for the remote shell
  2207. file name, if you are on a remote buffer, and if
  2208. @option{explicit-shell-file-name} is equal to @code{nil}.
  2209. @end ifset
  2210. @subsection Running @code{shell-command} on a remote host
  2211. @cindex shell-command
  2212. @code{shell-command} allows to execute commands in a shell, either
  2213. synchronously, either asynchronously. This works also on remote
  2214. hosts. Example:
  2215. @example
  2216. @kbd{C-x C-f @trampfn{sudo, , , } @key{RET}}
  2217. @kbd{M-! tail -f /var/log/syslog.log & @key{RET}}
  2218. @end example
  2219. You will see the buffer @file{*Async Shell Command*}, containing the
  2220. continuous output of the @command{tail} command.
  2221. @ifset emacs
  2222. A similar behavior can be reached by @kbd{M-x auto-revert-tail-mode},
  2223. if available.
  2224. @end ifset
  2225. @subsection Running @code{eshell} on a remote host
  2226. @cindex eshell
  2227. @value{tramp} is integrated into @file{eshell.el}. That is, you can
  2228. open an interactive shell on your remote host, and run commands there.
  2229. After you have started @kbd{M-x eshell}, you could perform commands
  2230. like this:
  2231. @example
  2232. @b{~ $} cd @trampfn{sudo, , , /etc} @key{RET}
  2233. @b{@trampfn{sudo, root, host, /etc} $} hostname @key{RET}
  2234. host
  2235. @b{@trampfn{sudo, root, host, /etc} $} id @key{RET}
  2236. uid=0(root) gid=0(root) groups=0(root)
  2237. @b{@trampfn{sudo, root, host, /etc} $} find-file shadow @key{RET}
  2238. #<buffer shadow>
  2239. @b{@trampfn{sudo, root, host, /etc} $}
  2240. @end example
  2241. @ifset emacs
  2242. Since @value{emacsname} 23.2, @code{eshell} has also an own
  2243. implementation of the @code{su} and @code{sudo} commands. Both
  2244. commands change the default directory of the @file{*eshell*} buffer to
  2245. the value related to the user the command has switched to. This works
  2246. even on remote hosts, adding silently a corresponding entry to the
  2247. variable @code{tramp-default-proxies-alist} (@pxref{Multi-hops}):
  2248. @example
  2249. @b{~ $} cd @trampfn{ssh, user, remotehost, /etc} @key{RET}
  2250. @b{@trampfn{ssh, user, remotehost, /etc} $} find-file shadow @key{RET}
  2251. File is not readable: @trampfn{ssh, user, remotehost, /etc/shadow}
  2252. @b{@trampfn{ssh, user, remotehost, /etc} $} sudo find-file shadow @key{RET}
  2253. #<buffer shadow>
  2254. @b{@trampfn{ssh, user, remotehost, /etc} $} su - @key{RET}
  2255. @b{@trampfn{su, root, remotehost, /root} $} id @key{RET}
  2256. uid=0(root) gid=0(root) groups=0(root)
  2257. @b{@trampfn{su, root, remotehost, /root} $}
  2258. @end example
  2259. @end ifset
  2260. @anchor{Running a debugger on a remote host}
  2261. @subsection Running a debugger on a remote host
  2262. @cindex gud
  2263. @cindex gdb
  2264. @cindex perldb
  2265. @file{gud.el} offers a unified interface to several symbolic
  2266. debuggers
  2267. @ifset emacs
  2268. @ifinfo
  2269. (@ref{Debuggers, , , @value{emacsdir}}).
  2270. @end ifinfo
  2271. @end ifset
  2272. With @value{tramp}, it is possible to debug programs on
  2273. remote hosts. You can call @code{gdb} with a remote file name:
  2274. @example
  2275. @kbd{M-x gdb @key{RET}}
  2276. @b{Run gdb (like this):} gdb --annotate=3 @trampfn{ssh, , host, ~/myprog} @key{RET}
  2277. @end example
  2278. The file name can also be relative to a remote default directory.
  2279. Given you are in a buffer that belongs to the remote directory
  2280. @trampfn{ssh, , host, /home/user}, you could call
  2281. @example
  2282. @kbd{M-x perldb @key{RET}}
  2283. @b{Run perldb (like this):} perl -d myprog.pl @key{RET}
  2284. @end example
  2285. It is not possible to use just the absolute local part of a remote
  2286. file name as program to debug, like @kbd{perl -d
  2287. /home/user/myprog.pl}, though.
  2288. Arguments of the program to be debugged are taken literally. That
  2289. means, file names as arguments must be given as ordinary relative or
  2290. absolute file names, without any remote specification.
  2291. @subsection Running remote processes on Windows hosts
  2292. @cindex winexe
  2293. @cindex powershell
  2294. With the help of the @command{winexe} it is possible tu run processes
  2295. on a remote Windows host. @value{tramp} has implemented this for
  2296. @code{process-file} and @code{start-file-process}.
  2297. The variable @code{tramp-smb-winexe-program} must contain the file
  2298. name of your local @command{winexe} command. On the remote host,
  2299. Powershell V2.0 must be installed; it is used to run the remote
  2300. process.
  2301. In order to open a remote shell on the Windows host via @kbd{M-x
  2302. shell}, you must set the variables @option{explicit-shell-file-name}
  2303. and @option{explicit-*-args}. If you want, for example, run
  2304. @command{cmd}, you must set:
  2305. @lisp
  2306. (setq explicit-shell-file-name "cmd"
  2307. explicit-cmd-args '("/q"))
  2308. @end lisp
  2309. @noindent
  2310. In case of running @command{powershell} as remote shell, the settings are
  2311. @lisp
  2312. (setq explicit-shell-file-name "powershell"
  2313. explicit-powershell-args '("-file" "-"))
  2314. @end lisp
  2315. @node Cleanup remote connections
  2316. @section Cleanup remote connections
  2317. @cindex cleanup
  2318. Sometimes it is useful to cleanup remote connections. The following
  2319. commands support this.
  2320. @deffn Command tramp-cleanup-connection vec
  2321. This command flushes all connection related objects. @option{vec} is
  2322. the internal representation of a remote connection. Called
  2323. interactively, the command offers all active remote connections in the
  2324. minibuffer as remote file name prefix like @file{@trampfn{method,
  2325. user, host, }}. The cleanup includes password cache (@pxref{Password
  2326. handling}), file cache, connection cache (@pxref{Connection caching}),
  2327. connection buffers.
  2328. @end deffn
  2329. @deffn Command tramp-cleanup-this-connection
  2330. This command flushes all objects of the current buffer's remote
  2331. connection. The same objects are removed as in
  2332. @code{tramp-cleanup-connection}.
  2333. @end deffn
  2334. @deffn Command tramp-cleanup-all-connections
  2335. This command flushes objects for all active remote connections. The
  2336. same objects are removed as in @code{tramp-cleanup-connection}.
  2337. @end deffn
  2338. @deffn Command tramp-cleanup-all-buffers
  2339. Like in @code{tramp-cleanup-all-connections}, all remote connections
  2340. are cleaned up. Additionally all buffers, which are related to a
  2341. remote connection, are killed.
  2342. @end deffn
  2343. @node Bug Reports
  2344. @chapter Reporting Bugs and Problems
  2345. @cindex bug reports
  2346. Bugs and problems with @value{tramp} are actively worked on by the
  2347. development team. Feature requests and suggestions are also more than
  2348. welcome.
  2349. The @value{tramp} mailing list is a great place to get information on
  2350. working with @value{tramp}, solving problems and general discussion
  2351. and advice on topics relating to the package. It is moderated so
  2352. non-subscribers can post but messages will be delayed, possibly up to
  2353. 48 hours (or longer in case of holidays), until the moderator approves
  2354. your message.
  2355. The mailing list is at @email{tramp-devel@@gnu.org}. Messages sent to
  2356. this address go to all the subscribers. This is @emph{not} the address
  2357. to send subscription requests to.
  2358. Subscribing to the list is performed via
  2359. @uref{http://lists.gnu.org/mailman/listinfo/tramp-devel/,
  2360. the @value{tramp} Mail Subscription Page}.
  2361. @ifset emacs
  2362. @ifset installchapter
  2363. Before sending a bug report, you could check whether @value{tramp}
  2364. works at all. Run the test suite on your local host, @ref{Testing}.
  2365. @end ifset
  2366. @end ifset
  2367. @findex tramp-bug
  2368. To report a bug in @value{tramp}, you should execute @kbd{M-x
  2369. tramp-bug}. This will automatically generate a buffer with the details
  2370. of your system and @value{tramp} version.
  2371. When submitting a bug report, please try to describe in excruciating
  2372. detail the steps required to reproduce the problem, the setup of the
  2373. remote host and any special conditions that exist. You should also
  2374. check that your problem is not described already in @xref{Frequently
  2375. Asked Questions}.
  2376. If you can identify a minimal test case that reproduces the problem,
  2377. include that with your bug report. This will make it much easier for
  2378. the development team to analyze and correct the problem.
  2379. Sometimes, there might be also problems due to Tramp caches. Flush
  2380. all caches before running the test, @ref{Cleanup remote connections}.
  2381. Before reporting the bug, you should set the verbosity level to 6
  2382. (@pxref{Traces and Profiles, Traces}) in the @file{~/.emacs} file and
  2383. repeat the bug. Then, include the contents of the @file{*tramp/foo*}
  2384. and @file{*debug tramp/foo*} buffers in your bug report. A verbosity
  2385. level greater than 6 will produce a very huge debug buffer, which is
  2386. mostly not necessary for the analysis.
  2387. Please be aware that, with a verbosity level of 6 or greater, the
  2388. contents of files and directories will be included in the debug
  2389. buffer. Passwords you've typed will never be included there.
  2390. @node Frequently Asked Questions
  2391. @chapter Frequently Asked Questions
  2392. @cindex frequently asked questions
  2393. @cindex FAQ
  2394. @itemize @bullet
  2395. @item
  2396. Where can I get the latest @value{tramp}?
  2397. @value{tramp} is available under the URL below.
  2398. @noindent
  2399. @uref{ftp://ftp.gnu.org/gnu/tramp/}
  2400. @noindent
  2401. There is also a Savannah project page.
  2402. @noindent
  2403. @uref{http://savannah.gnu.org/projects/tramp/}
  2404. @item
  2405. Which systems does it work on?
  2406. The package has been used successfully on Emacs 22, Emacs 23, Emacs
  2407. 24, XEmacs 21 (starting with 21.4), and SXEmacs 22.
  2408. The package was intended to work on Unix, and it really expects a
  2409. Unix-like system on the remote end (except the @option{smb} method),
  2410. but some people seemed to have some success getting it to work on MS
  2411. Windows XP/Vista/7 @value{emacsname}.
  2412. @item
  2413. How could I speed up @value{tramp}?
  2414. In the backstage, @value{tramp} needs a lot of operations on the
  2415. remote host. The time for transferring data from and to the remote
  2416. host as well as the time needed to perform the operations there count.
  2417. In order to speed up @value{tramp}, one could either try to avoid some
  2418. of the operations, or one could try to improve their performance.
  2419. Use an external method, like @option{scp}.
  2420. Use caching. This is already enabled by default. Information about
  2421. the remote host as well as the remote files are cached for reuse. The
  2422. information about remote hosts is kept in the file specified in
  2423. @code{tramp-persistency-file-name}. Keep this file. If you are
  2424. confident that files on remote hosts are not changed out of
  2425. @value{emacsname}' control, set @code{remote-file-name-inhibit-cache}
  2426. to @code{nil}. Set also @code{tramp-completion-reread-directory-timeout}
  2427. to @code{nil}, @ref{File name completion}.
  2428. Disable version control. If you access remote files which are not
  2429. under version control, a lot of check operations can be avoided by
  2430. disabling VC@. This can be achieved by
  2431. @lisp
  2432. (setq vc-ignore-dir-regexp
  2433. (format "\\(%s\\)\\|\\(%s\\)"
  2434. vc-ignore-dir-regexp
  2435. tramp-file-name-regexp))
  2436. @end lisp
  2437. Disable excessive traces. The default trace level of @value{tramp},
  2438. defined in the variable @code{tramp-verbose}, is 3. You should
  2439. increase this level only temporarily, hunting bugs.
  2440. @item
  2441. @value{tramp} does not connect to the remote host
  2442. When @value{tramp} does not connect to the remote host, there are three
  2443. reasons heading the bug mailing list:
  2444. @itemize @minus
  2445. @item
  2446. Unknown characters in the prompt
  2447. @value{tramp} needs to recognize the prompt on the remote host
  2448. after execution any command. This is not possible when the prompt
  2449. contains unknown characters like escape sequences for coloring. This
  2450. should be avoided on the remote side. @xref{Remote shell setup}. for
  2451. setting the regular expression detecting the prompt.
  2452. You can check your settings after an unsuccessful connection by
  2453. switching to the @value{tramp} connection buffer @file{*tramp/foo*},
  2454. setting the cursor at the top of the buffer, and applying the expression
  2455. @example
  2456. @kbd{M-: (re-search-forward (concat tramp-shell-prompt-pattern "$"))}
  2457. @end example
  2458. If it fails, or the cursor is not moved at the end of the buffer, your
  2459. prompt is not recognized correctly.
  2460. A special problem is the zsh shell, which uses left-hand side and
  2461. right-hand side prompts in parallel. Therefore, it is necessary to
  2462. disable the zsh line editor on the remote host. You shall add to
  2463. @file{~/.zshrc} the following command:
  2464. @example
  2465. [ $TERM = "dumb" ] && unsetopt zle && PS1='$ '
  2466. @end example
  2467. Similar fancy prompt settings are known from the fish shell. Here you
  2468. must add in @file{~/.config/fish/config.fish}:
  2469. @example
  2470. function fish_prompt
  2471. if test $TERM = "dumb"
  2472. echo "\$ "
  2473. else
  2474. @dots{}
  2475. end
  2476. end
  2477. @end example
  2478. Furthermore it has been reported, that @value{tramp} (like sshfs,
  2479. incidentally) doesn't work with WinSSHD due to strange prompt settings.
  2480. @item
  2481. Echoed characters after login
  2482. When the remote host opens an echoing shell, there might be control
  2483. characters in the welcome message. @value{tramp} tries to suppress
  2484. such echoes via the @command{stty -echo} command, but sometimes this
  2485. command is not reached, because the echoed output has confused
  2486. @value{tramp} already. In such situations it might be helpful to use
  2487. the @option{sshx} or @option{scpx} methods, which allocate a pseudo tty.
  2488. @xref{Inline methods}.
  2489. @item
  2490. @value{tramp} doesn't transfer strings with more than 500 characters
  2491. correctly
  2492. On some few systems, the implementation of @code{process-send-string}
  2493. seems to be broken for longer strings. It is reported for HP-UX,
  2494. FreeBSD and Tru64 Unix, for example. This case, you should customize
  2495. the variable @code{tramp-chunksize} to 500. For a description how to
  2496. determine whether this is necessary see the documentation of
  2497. @code{tramp-chunksize}.
  2498. Additionally, it will be useful to set @code{file-precious-flag} to
  2499. @code{t} for @value{tramp} files. Then the file contents will be
  2500. written into a temporary file first, which is checked for correct
  2501. checksum.
  2502. @ifinfo
  2503. @pxref{Saving Buffers, , , elisp}
  2504. @end ifinfo
  2505. @lisp
  2506. (add-hook
  2507. 'find-file-hook
  2508. (lambda ()
  2509. (when (file-remote-p default-directory)
  2510. (set (make-local-variable 'file-precious-flag) t))))
  2511. @end lisp
  2512. @end itemize
  2513. @item
  2514. @value{tramp} does not recognize hung @command{ssh} sessions
  2515. When your network connection is down, @command{ssh} sessions might
  2516. hang. @value{tramp} cannot detect it safely, because it still sees a
  2517. running @command{ssh} process. Timeouts cannot be used as well,
  2518. because it cannot be predicted how long a remote command will last,
  2519. for example when copying very large files.
  2520. Therefore, you must configure the @command{ssh} process to die
  2521. in such a case. The following entry in @file{~/.ssh/config} would do
  2522. the job:
  2523. @example
  2524. Host *
  2525. ServerAliveInterval 5
  2526. @end example
  2527. @item
  2528. @value{tramp} does not use my @command{ssh} @code{ControlPath}
  2529. Your @code{ControlPath} setting will be overwritten by @command{ssh}
  2530. sessions initiated by @value{tramp}. This is because a master
  2531. session, initiated outside @value{emacsname}, could be closed, which
  2532. would stall all other @command{ssh} sessions for that host inside
  2533. @value{emacsname}.
  2534. Consequently, if you connect to a remote host via @value{tramp}, you
  2535. might be prompted for a password again, even if you have established
  2536. already an @command{ssh} connection to that host. Further
  2537. @value{tramp} connections to that host, for example in order to run a
  2538. process on that host, will reuse that initial @command{ssh}
  2539. connection.
  2540. If your @command{ssh} version supports the @code{ControlPersist}
  2541. option, you could customize the variable
  2542. @code{tramp-ssh-controlmaster-options} to use your @code{ControlPath},
  2543. for example:
  2544. @lisp
  2545. (setq tramp-ssh-controlmaster-options
  2546. (concat
  2547. "-o ControlPath=/tmp/ssh-ControlPath-%%r@@%%h:%%p "
  2548. "-o ControlMaster=auto -o ControlPersist=yes"))
  2549. @end lisp
  2550. Note, that "%r", "%h" and "%p" must be encoded as "%%r", "%%h" and
  2551. "%%p", respectively.
  2552. These settings can be suppressed, if they are configured properly in
  2553. your @file{~/.ssh/config}:
  2554. @lisp
  2555. (setq tramp-use-ssh-controlmaster-options nil)
  2556. @end lisp
  2557. @item
  2558. File name completion does not work with @value{tramp}
  2559. When you log in to the remote host, do you see the output of
  2560. @command{ls} in color? If so, this may be the cause of your problems.
  2561. @command{ls} outputs @acronym{ANSI} escape sequences that your terminal
  2562. emulator interprets to set the colors. These escape sequences will
  2563. confuse @value{tramp} however.
  2564. In your @file{.bashrc}, @file{.profile} or equivalent on the remote
  2565. host you probably have an alias configured that adds the option
  2566. @option{--color=yes} or @option{--color=auto}.
  2567. You should remove that alias and ensure that a new login @emph{does not}
  2568. display the output of @command{ls} in color. If you still cannot use
  2569. file name completion, report a bug to the @value{tramp} developers.
  2570. @item
  2571. File name completion does not work in large directories
  2572. @value{tramp} uses globbing for some operations. (Globbing means to use the
  2573. shell to expand wildcards such as @samp{*.c}.) This might create long
  2574. command lines, especially in directories with many files. Some shells
  2575. choke on long command lines, or don't cope well with the globbing
  2576. itself.
  2577. If you have a large directory on the remote end, you may wish to execute
  2578. a command like @samp{ls -d * ..?* > /dev/null} and see if it hangs.
  2579. Note that you must first start the right shell, which might be
  2580. @command{/bin/sh}, @command{ksh} or @command{bash}, depending on which
  2581. of those supports tilde expansion.
  2582. @item
  2583. How can I get notified when @value{tramp} file transfers are complete?
  2584. The following snippet can be put in your @file{~/.emacs} file. It
  2585. makes @value{emacsname} beep after reading from or writing to the
  2586. remote host.
  2587. @lisp
  2588. (defadvice tramp-handle-write-region
  2589. (after tramp-write-beep-advice activate)
  2590. "Make tramp beep after writing a file."
  2591. (interactive)
  2592. (beep))
  2593. (defadvice tramp-handle-do-copy-or-rename-file
  2594. (after tramp-copy-beep-advice activate)
  2595. "Make tramp beep after copying a file."
  2596. (interactive)
  2597. (beep))
  2598. (defadvice tramp-handle-insert-file-contents
  2599. (after tramp-insert-beep-advice activate)
  2600. "Make tramp beep after inserting a file."
  2601. (interactive)
  2602. (beep))
  2603. @end lisp
  2604. @ifset emacs
  2605. @item
  2606. I'ld like to get a Visual Warning when working in a sudo:ed context
  2607. When you are working with @samp{root} privileges, it might be useful
  2608. to get an indication in the buffer's modeline. The following code,
  2609. tested with @value{emacsname} 22.1, does the job. You should put it
  2610. into your @file{~/.emacs}:
  2611. @lisp
  2612. (defun my-mode-line-function ()
  2613. (when (string-match "^/su\\(do\\)?:" default-directory)
  2614. (setq mode-line-format
  2615. (format-mode-line mode-line-format 'font-lock-warning-face))))
  2616. (add-hook 'find-file-hook 'my-mode-line-function)
  2617. (add-hook 'dired-mode-hook 'my-mode-line-function)
  2618. @end lisp
  2619. @end ifset
  2620. @ifset emacs
  2621. @item
  2622. I'ld like to see a host indication in the mode line when I'm remote
  2623. The following code has been tested with @value{emacsname} 22.1. You
  2624. should put it into your @file{~/.emacs}:
  2625. @lisp
  2626. (defconst my-mode-line-buffer-identification
  2627. (list
  2628. '(:eval
  2629. (let ((host-name
  2630. (if (file-remote-p default-directory)
  2631. (tramp-file-name-host
  2632. (tramp-dissect-file-name default-directory))
  2633. (system-name))))
  2634. (if (string-match "^[^0-9][^.]*\\(\\..*\\)" host-name)
  2635. (substring host-name 0 (match-beginning 1))
  2636. host-name)))
  2637. ": %12b"))
  2638. (setq-default
  2639. mode-line-buffer-identification
  2640. my-mode-line-buffer-identification)
  2641. (add-hook
  2642. 'dired-mode-hook
  2643. (lambda ()
  2644. (setq
  2645. mode-line-buffer-identification
  2646. my-mode-line-buffer-identification)))
  2647. @end lisp
  2648. Since @value{emacsname} 23.1, the mode line contains an indication if
  2649. @code{default-directory} for the current buffer is on a remote host.
  2650. The corresponding tooltip includes the name of that host. If you
  2651. still want the host name as part of the mode line, you can use the
  2652. example above, but the @code{:eval} clause can be simplified:
  2653. @lisp
  2654. '(:eval
  2655. (let ((host-name
  2656. (or (file-remote-p default-directory 'host)
  2657. (system-name))))
  2658. (if (string-match "^[^0-9][^.]*\\(\\..*\\)" host-name)
  2659. (substring host-name 0 (match-beginning 1))
  2660. host-name)))
  2661. @end lisp
  2662. @end ifset
  2663. @ifset emacs
  2664. @item
  2665. My remote host does not understand default directory listing options
  2666. @value{emacsname} computes the @command{dired} options depending on
  2667. the local host you are working. If your @command{ls} command on the
  2668. remote host does not understand those options, you can change them
  2669. like this:
  2670. @lisp
  2671. (add-hook
  2672. 'dired-before-readin-hook
  2673. (lambda ()
  2674. (when (file-remote-p default-directory)
  2675. (setq dired-actual-switches "-al"))))
  2676. @end lisp
  2677. @end ifset
  2678. @item
  2679. There's this @file{~/.sh_history} file on the remote host which keeps
  2680. growing and growing. What's that?
  2681. Sometimes, @value{tramp} starts @command{ksh} on the remote host for
  2682. tilde expansion. Maybe @command{ksh} saves the history by default.
  2683. @value{tramp} tries to turn off saving the history, but maybe you have
  2684. to help. For example, you could put this in your @file{.kshrc}:
  2685. @example
  2686. if [ -f $HOME/.sh_history ] ; then
  2687. /bin/rm $HOME/.sh_history
  2688. fi
  2689. if [ "$@{HISTFILE-unset@}" != "unset" ] ; then
  2690. unset HISTFILE
  2691. fi
  2692. if [ "$@{HISTSIZE-unset@}" != "unset" ] ; then
  2693. unset HISTSIZE
  2694. fi
  2695. @end example
  2696. Furthermore, if you use an @option{ssh}-based method, you could add
  2697. the following line to your @file{~/.ssh/environment} file:
  2698. @example
  2699. HISTFILE=/dev/null
  2700. @end example
  2701. @item There are longish file names to type. How to shorten this?
  2702. Let's say you need regularly access to @file{@trampfn{ssh, news,
  2703. news.my.domain, /opt/news/etc}}, which is boring to type again and
  2704. again. The following approaches can be mixed:
  2705. @enumerate
  2706. @item Use default values for method and user name:
  2707. You can define default methods and user names for hosts,
  2708. (@pxref{Default Method}, @pxref{Default User}):
  2709. @lisp
  2710. (setq tramp-default-method "ssh"
  2711. tramp-default-user "news")
  2712. @end lisp
  2713. The file name left to type would be
  2714. @kbd{C-x C-f @trampfn{, , news.my.domain, /opt/news/etc}}.
  2715. Note that there are some useful settings already. Accessing your
  2716. local host as @samp{root} user, is possible just by @kbd{C-x C-f
  2717. @trampfn{su, , ,}}.
  2718. @item Use configuration possibilities of your method:
  2719. Several connection methods (i.e., the programs used) offer powerful
  2720. configuration possibilities (@pxref{Customizing Completion}). In the
  2721. given case, this could be @file{~/.ssh/config}:
  2722. @example
  2723. Host xy
  2724. HostName news.my.domain
  2725. User news
  2726. @end example
  2727. The file name left to type would be @kbd{C-x C-f @trampfn{ssh, , xy,
  2728. /opt/news/etc}}. Depending on files in your directories, it is even
  2729. possible to complete the host name with @kbd{C-x C-f
  2730. @value{prefix}ssh@value{postfixhop}x @key{TAB}}.
  2731. @item Use environment variables:
  2732. File names typed in the minibuffer can be expanded by environment
  2733. variables. You can set them outside @value{emacsname}, or even with
  2734. Lisp:
  2735. @lisp
  2736. (setenv "xy" "@trampfn{ssh, news, news.my.domain, /opt/news/etc/}")
  2737. @end lisp
  2738. Then you need simply to type @kbd{C-x C-f $xy @key{RET}}, and here you
  2739. are. The disadvantage is that you cannot edit the file name, because
  2740. environment variables are not expanded during editing in the
  2741. minibuffer.
  2742. @item Define own keys:
  2743. You can define your own key sequences in @value{emacsname}, which can
  2744. be used instead of @kbd{C-x C-f}:
  2745. @lisp
  2746. (global-set-key
  2747. [(control x) (control y)]
  2748. (lambda ()
  2749. (interactive)
  2750. (find-file
  2751. (read-file-name
  2752. "Find Tramp file: "
  2753. "@trampfn{ssh, news, news.my.domain, /opt/news/etc/}"))))
  2754. @end lisp
  2755. Simply typing @kbd{C-x C-y} would initialize the minibuffer for
  2756. editing with your beloved file name.
  2757. See also @uref{http://www.emacswiki.org/cgi-bin/wiki/TrampMode, the
  2758. Emacs Wiki} for a more comprehensive example.
  2759. @item Define own abbreviation (1):
  2760. It is possible to define an own abbreviation list for expanding file
  2761. names:
  2762. @lisp
  2763. (add-to-list
  2764. 'directory-abbrev-alist
  2765. '("^/xy" . "@trampfn{ssh, news, news.my.domain, /opt/news/etc/}"))
  2766. @end lisp
  2767. This shortens the file opening command to @kbd{C-x C-f /xy
  2768. @key{RET}}. The disadvantage is, again, that you cannot edit the file
  2769. name, because the expansion happens after entering the file name only.
  2770. @item Define own abbreviation (2):
  2771. The @code{abbrev-mode} gives more flexibility for editing the
  2772. minibuffer:
  2773. @lisp
  2774. (define-abbrev-table 'my-tramp-abbrev-table
  2775. '(("xy" "@trampfn{ssh, news, news.my.domain, /opt/news/etc/}")))
  2776. (add-hook
  2777. 'minibuffer-setup-hook
  2778. (lambda ()
  2779. (abbrev-mode 1)
  2780. (setq local-abbrev-table my-tramp-abbrev-table)))
  2781. (defadvice minibuffer-complete
  2782. (before my-minibuffer-complete activate)
  2783. (expand-abbrev))
  2784. ;; If you use partial-completion-mode
  2785. (defadvice PC-do-completion
  2786. (before my-PC-do-completion activate)
  2787. (expand-abbrev))
  2788. @end lisp
  2789. After entering @kbd{C-x C-f xy @key{TAB}}, the minibuffer is
  2790. expanded, and you can continue editing.
  2791. @item Use bookmarks:
  2792. Bookmarks can be used to visit Tramp files or directories.
  2793. @ifinfo
  2794. @pxref{Bookmarks, , , @value{emacsdir}}
  2795. @end ifinfo
  2796. When you have opened @file{@trampfn{ssh, news, news.my.domain,
  2797. /opt/news/etc/}}, you should save the bookmark via
  2798. @ifset emacs
  2799. @kbd{@key{menu-bar} @key{edit} @key{bookmarks} @key{set}}.
  2800. @end ifset
  2801. @ifset xemacs
  2802. @kbd{@key{menu-bar} @key{view} @key{bookmarks} @key{set}}.
  2803. @end ifset
  2804. Later on, you can always navigate to that bookmark via
  2805. @ifset emacs
  2806. @kbd{@key{menu-bar} @key{edit} @key{bookmarks} @key{jump}}.
  2807. @end ifset
  2808. @ifset xemacs
  2809. @kbd{@key{menu-bar} @key{view} @key{bookmarks} @key{jump}}.
  2810. @end ifset
  2811. @item Use recent files:
  2812. @ifset emacs
  2813. @file{recentf}
  2814. @end ifset
  2815. @ifset xemacs
  2816. @file{recent-files}
  2817. @end ifset
  2818. remembers visited places.
  2819. @ifinfo
  2820. @ifset emacs
  2821. @pxref{File Conveniences, , , @value{emacsdir}}
  2822. @end ifset
  2823. @ifset xemacs
  2824. @pxref{recent-files, , , edit-utils}
  2825. @end ifset
  2826. @end ifinfo
  2827. You could keep remote file names in the recent list without checking
  2828. their readability through a remote access:
  2829. @lisp
  2830. @ifset emacs
  2831. (recentf-mode 1)
  2832. @end ifset
  2833. @ifset xemacs
  2834. (recent-files-initialize)
  2835. (add-hook
  2836. 'find-file-hook
  2837. (lambda ()
  2838. (when (file-remote-p (buffer-file-name))
  2839. (recent-files-make-permanent)))
  2840. 'append)
  2841. @end ifset
  2842. @end lisp
  2843. The list of files opened recently is reachable via
  2844. @ifset emacs
  2845. @kbd{@key{menu-bar} @key{file} @key{Open Recent}}.
  2846. @end ifset
  2847. @ifset xemacs
  2848. @kbd{@key{menu-bar} @key{Recent Files}}.
  2849. @end ifset
  2850. @ifset emacs
  2851. @item Use filecache:
  2852. @file{filecache} remembers visited places. Add the directory into
  2853. the cache:
  2854. @lisp
  2855. (eval-after-load "filecache"
  2856. '(file-cache-add-directory
  2857. "@trampfn{ssh, news, news.my.domain, /opt/news/etc/}"))
  2858. @end lisp
  2859. Whenever you want to load a file, you can enter @kbd{C-x C-f
  2860. C-@key{TAB}} in the minibuffer. The completion is done for the given
  2861. directory.
  2862. @end ifset
  2863. @ifset emacs
  2864. @item Use bbdb:
  2865. @file{bbdb} has a built-in feature for @value{ftppackagename} files,
  2866. which works also for @value{tramp}.
  2867. @ifinfo
  2868. @pxref{bbdb-ftp, Storing FTP sites in the BBDB, , bbdb}
  2869. @end ifinfo
  2870. You need to load @file{bbdb}:
  2871. @lisp
  2872. (require 'bbdb)
  2873. (bbdb-initialize)
  2874. @end lisp
  2875. Then you can create a BBDB entry via @kbd{M-x bbdb-create-ftp-site}.
  2876. Because BBDB is not prepared for @value{tramp} syntax, you must
  2877. specify a method together with the user name when needed. Example:
  2878. @example
  2879. @kbd{M-x bbdb-create-ftp-site @key{RET}}
  2880. @b{Ftp Site:} news.my.domain @key{RET}
  2881. @b{Ftp Directory:} /opt/news/etc/ @key{RET}
  2882. @b{Ftp Username:} ssh@value{postfixhop}news @key{RET}
  2883. @b{Company:} @key{RET}
  2884. @b{Additional Comments:} @key{RET}
  2885. @end example
  2886. When you have opened your BBDB buffer, you can access such an entry by
  2887. pressing the key @key{F}.
  2888. @end ifset
  2889. @end enumerate
  2890. I would like to thank all @value{tramp} users who have contributed to
  2891. the different recipes!
  2892. @ifset emacs
  2893. @item
  2894. How can I use @value{tramp} to connect to a remote @value{emacsname}
  2895. session?
  2896. You can configure Emacs Client doing this.
  2897. @ifinfo
  2898. @xref{Emacs Server, , , @value{emacsdir}}.
  2899. @end ifinfo
  2900. On the remote host, you start the Emacs Server:
  2901. @lisp
  2902. (require 'server)
  2903. (setq server-host (system-name)
  2904. server-use-tcp t)
  2905. (server-start)
  2906. @end lisp
  2907. Make sure that the result of @code{(system-name)} can be resolved on
  2908. your local host; otherwise you might use a hard coded IP address.
  2909. The resulting file @file{~/.emacs.d/server/server} must be copied to
  2910. your local host, at the same location. You can call then the Emacs
  2911. Client from the command line:
  2912. @example
  2913. emacsclient @trampfn{ssh, user, host, /file/to/edit}
  2914. @end example
  2915. @code{user} and @code{host} shall be related to your local host.
  2916. If you want to use Emacs Client also as editor for other programs, you
  2917. could write a script @file{emacsclient.sh}:
  2918. @example
  2919. #!/bin/sh
  2920. emacsclient @trampfn{ssh, $(whoami), $(hostname --fqdn), $1}
  2921. @end example
  2922. Then you must set the environment variable @env{EDITOR} pointing to
  2923. that script:
  2924. @example
  2925. export EDITOR=/path/to/emacsclient.sh
  2926. @end example
  2927. @end ifset
  2928. @item
  2929. There are packages which call @value{tramp} although I haven't entered
  2930. a remote file name ever. I dislike it, how could I disable it?
  2931. In general, @value{tramp} functions are used only when
  2932. you apply remote file name syntax. However, some packages enable
  2933. @value{tramp} on their own.
  2934. @itemize @minus
  2935. @item
  2936. @file{ido.el}
  2937. You could disable @value{tramp} file name completion:
  2938. @lisp
  2939. (custom-set-variables
  2940. '(ido-enable-tramp-completion nil))
  2941. @end lisp
  2942. @item
  2943. @file{rlogin.el}
  2944. You could disable remote directory tracking mode:
  2945. @lisp
  2946. (rlogin-directory-tracking-mode -1)
  2947. @end lisp
  2948. @end itemize
  2949. @item
  2950. How can I disable @value{tramp} at all?
  2951. Shame on you, why did you read until now?
  2952. @itemize @minus
  2953. @ifset emacs
  2954. @item
  2955. If you just want to have @value{ftppackagename} as default remote
  2956. files access package, you should apply the following code:
  2957. @lisp
  2958. (setq tramp-default-method "ftp")
  2959. @end lisp
  2960. @end ifset
  2961. @item
  2962. In order to disable
  2963. @ifset emacs
  2964. @value{tramp} (and @value{ftppackagename}),
  2965. @end ifset
  2966. @ifset xemacs
  2967. @value{tramp},
  2968. @end ifset
  2969. you must set @code{tramp-mode} to @code{nil}:
  2970. @lisp
  2971. (setq tramp-mode nil)
  2972. @end lisp
  2973. @item
  2974. Unloading @value{tramp} can be achieved by applying @kbd{M-x
  2975. tramp-unload-tramp}.
  2976. @ifset emacs
  2977. This resets also the @value{ftppackagename} plugins.
  2978. @end ifset
  2979. @end itemize
  2980. @end itemize
  2981. @c For the developer
  2982. @node Files directories and localnames
  2983. @chapter How file names, directories and localnames are mangled and managed.
  2984. @menu
  2985. * Localname deconstruction:: Breaking a localname into its components.
  2986. @ifset emacs
  2987. * External packages:: Integration with external Lisp packages.
  2988. @end ifset
  2989. @end menu
  2990. @node Localname deconstruction
  2991. @section Breaking a localname into its components
  2992. @value{tramp} file names are somewhat different, obviously, to ordinary file
  2993. names. As such, the lisp functions @code{file-name-directory} and
  2994. @code{file-name-nondirectory} are overridden within the @value{tramp}
  2995. package.
  2996. Their replacements are reasonably simplistic in their approach. They
  2997. dissect the file name, call the original handler on the localname and
  2998. then rebuild the @value{tramp} file name with the result.
  2999. This allows the platform specific hacks in the original handlers to take
  3000. effect while preserving the @value{tramp} file name information.
  3001. @ifset emacs
  3002. @node External packages
  3003. @section Integration with external Lisp packages
  3004. @subsection File name completion.
  3005. While reading file names in the minibuffer, @value{tramp} must decide
  3006. whether it completes possible incomplete file names, or not. Imagine
  3007. there is the following situation: You have typed @kbd{C-x C-f
  3008. @value{prefix}ssh@value{postfixhop} @key{TAB}}. @value{tramp} cannot
  3009. know, whether @option{ssh} is a method or a host name. It checks
  3010. therefore the last input character you have typed. If this is
  3011. @key{TAB}, @key{SPACE} or @kbd{?}, @value{tramp} assumes that you are
  3012. still in file name completion, and it does not connect to the possible
  3013. remote host @option{ssh}.
  3014. External packages, which use other characters for completing file names
  3015. in the minibuffer, must signal this to @value{tramp}. For this case,
  3016. the variable @code{non-essential} can be bound temporarily to
  3017. a non-@code{nil} value.
  3018. @lisp
  3019. (let ((non-essential t))
  3020. @dots{})
  3021. @end lisp
  3022. @subsection File attributes cache.
  3023. When @value{tramp} runs remote processes, files on the remote host
  3024. could change their attributes. Consequently, @value{tramp} must flush
  3025. its complete cache keeping attributes for all files of the remote host
  3026. it has seen so far.
  3027. This is a performance degradation, because the lost file attributes
  3028. must be recomputed when needed again. In cases where the caller of
  3029. @code{process-file} knows that there are no file attribute changes, it
  3030. should let-bind the variable @code{process-file-side-effects} to
  3031. @code{nil}. Then @value{tramp} won't flush the file attributes cache.
  3032. @lisp
  3033. (let (process-file-side-effects)
  3034. @dots{})
  3035. @end lisp
  3036. For asynchronous processes, @value{tramp} flushes the file attributes
  3037. cache via a process sentinel. If the caller of
  3038. @code{start-file-process} knows that there are no file attribute
  3039. changes, it should set the process sentinel to the default. In cases
  3040. where the caller defines its own process sentinel, @value{tramp}'s process
  3041. sentinel is overwritten. The caller can still flush the file
  3042. attributes cache in its process sentinel with this code:
  3043. @lisp
  3044. (unless (memq (process-status proc) '(run open))
  3045. (dired-uncache remote-directory))
  3046. @end lisp
  3047. @code{remote-directory} shall be the root directory, where file
  3048. attribute changes can happen during the process lifetime.
  3049. @value{tramp} traverses all subdirectories, starting at this
  3050. directory. Often, it is sufficient to use @code{default-directory} of
  3051. the process buffer as root directory.
  3052. @end ifset
  3053. @node Traces and Profiles
  3054. @chapter How to Customize Traces
  3055. All @value{tramp} messages are raised with a verbosity level. The
  3056. verbosity level can be any number between 0 and 10. Only messages with
  3057. a verbosity level less than or equal to @code{tramp-verbose} are
  3058. displayed.
  3059. The verbosity levels are
  3060. @w{ 0} silent (no @value{tramp} messages at all)
  3061. @*@indent @w{ 1} errors
  3062. @*@indent @w{ 2} warnings
  3063. @*@indent @w{ 3} connection to remote hosts (default verbosity)
  3064. @*@indent @w{ 4} activities
  3065. @*@indent @w{ 5} internal
  3066. @*@indent @w{ 6} sent and received strings
  3067. @*@indent @w{ 7} file caching
  3068. @*@indent @w{ 8} connection properties
  3069. @*@indent @w{ 9} test commands
  3070. @*@indent @w{10} traces (huge)
  3071. When @code{tramp-verbose} is greater than or equal to 4, the messages
  3072. are also written into a @value{tramp} debug buffer. This debug buffer
  3073. is useful for analyzing problems; sending a @value{tramp} bug report
  3074. should be done with @code{tramp-verbose} set to a verbosity level of at
  3075. least 6 (@pxref{Bug Reports}).
  3076. The debug buffer is in
  3077. @ifinfo
  3078. @ref{Outline Mode, , , @value{emacsdir}}.
  3079. @end ifinfo
  3080. @ifnotinfo
  3081. Outline Mode.
  3082. @end ifnotinfo
  3083. That means, you can change the level of messages to be viewed. If you
  3084. want, for example, see only messages up to verbosity level 5, you must
  3085. enter @kbd{C-u 6 C-c C-q}.
  3086. @ifinfo
  3087. Other keys for navigating are described in
  3088. @ref{Outline Visibility, , , @value{emacsdir}}.
  3089. @end ifinfo
  3090. @value{tramp} errors are handled internally in order to raise the
  3091. verbosity level 1 messages. When you want to get a Lisp backtrace in
  3092. case of an error, you need to set both
  3093. @lisp
  3094. (setq debug-on-error t
  3095. debug-on-signal t)
  3096. @end lisp
  3097. Sometimes, it might be even necessary to step through @value{tramp}
  3098. function call traces. Such traces are enabled by the following code:
  3099. @lisp
  3100. (require 'tramp)
  3101. (require 'trace)
  3102. (dolist (elt (all-completions "tramp-" obarray 'functionp))
  3103. (trace-function-background (intern elt)))
  3104. (untrace-function 'tramp-read-passwd)
  3105. (untrace-function 'tramp-gw-basic-authentication)
  3106. @end lisp
  3107. The function call traces are inserted in the buffer
  3108. @file{*trace-output*}. @code{tramp-read-passwd} and
  3109. @code{tramp-gw-basic-authentication} shall be disabled when the
  3110. function call traces are added to @value{tramp}, because both
  3111. functions return password strings, which should not be distributed.
  3112. @node Issues
  3113. @chapter Debatable Issues and What Was Decided
  3114. @itemize @bullet
  3115. @item The uuencode method does not always work.
  3116. Due to the design of @value{tramp}, the encoding and decoding programs
  3117. need to read from stdin and write to stdout. On some systems,
  3118. @command{uudecode -o -} will read stdin and write the decoded file to
  3119. stdout, on other systems @command{uudecode -p} does the same thing.
  3120. But some systems have uudecode implementations which cannot do this at
  3121. all---it is not possible to call these uudecode implementations with
  3122. suitable parameters so that they write to stdout.
  3123. Of course, this could be circumvented: the @code{begin foo 644} line
  3124. could be rewritten to put in some temporary file name, then
  3125. @command{uudecode} could be called, then the temp file could be
  3126. printed and deleted.
  3127. But I have decided that this is too fragile to reliably work, so on some
  3128. systems you'll have to do without the uuencode methods.
  3129. @item The @value{tramp} file name syntax differs between Emacs and XEmacs.
  3130. The Emacs maintainers wish to use a unified file name syntax for
  3131. Ange-FTP and @value{tramp} so that users don't have to learn a new
  3132. syntax. It is sufficient to learn some extensions to the old syntax.
  3133. For the XEmacs maintainers, the problems caused from using a unified
  3134. file name syntax are greater than the gains. The XEmacs package system
  3135. uses EFS for downloading new packages. So, obviously, EFS has to be
  3136. installed from the start. If the file names were unified, @value{tramp}
  3137. would have to be installed from the start, too.
  3138. @ifset xemacs
  3139. @strong{Note:} If you'd like to use a similar syntax like
  3140. @value{ftppackagename}, you need the following settings in your init
  3141. file:
  3142. @lisp
  3143. (setq tramp-unified-filenames t)
  3144. (require 'tramp)
  3145. @end lisp
  3146. The autoload of the @value{emacsname} @value{tramp} package must be
  3147. disabled. This can be achieved by setting file permissions @code{000}
  3148. to the files @file{@dots{}/xemacs-packages/lisp/tramp/auto-autoloads.el*}.
  3149. In case of unified file names, all @value{emacsname} download sites are
  3150. added to @code{tramp-default-method-alist} with default method
  3151. @option{ftp} @xref{Default Method}. These settings shouldn't be
  3152. touched for proper working of the @value{emacsname} package system.
  3153. The syntax for unified file names is described in the @value{tramp} manual
  3154. for @value{emacsothername}.
  3155. @end ifset
  3156. @end itemize
  3157. @node GNU Free Documentation License
  3158. @appendix GNU Free Documentation License
  3159. @include doclicense.texi
  3160. @node Function Index
  3161. @unnumbered Function Index
  3162. @printindex fn
  3163. @node Variable Index
  3164. @unnumbered Variable Index
  3165. @printindex vr
  3166. @node Concept Index
  3167. @unnumbered Concept Index
  3168. @printindex cp
  3169. @bye
  3170. @c TODO
  3171. @c
  3172. @c * Say something about the .login and .profile files of the remote
  3173. @c shells.
  3174. @c * Explain how tramp.el works in principle: open a shell on a remote
  3175. @c host and then send commands to it.
  3176. @c * Consistent small or capitalized words especially in menus.
  3177. @c * Make a unique declaration of @trampfn.