Jump to navigation Jump to search
2,569 bytes added ,  06:01, 1 June 2016
== Multiple hops ==
=== No config in Emacs24 ===
As of Emacs 24, an analog of the old multi-hop syntax has been layered on top of the modern '''tramp-default-proxies-alist''' approach, meaning that you can once again perform multi-hops without any prior configuration. For details, see:
{{Keys | C-hig}} (tramp) Ad-hoc multi-hops RET
With the new syntax, each 'hop' is separated by '''|''' (pipe). In this instance, it would look like:
{{Keys | C-xC-f}} /ssh:user@server|sudo:server:/home/user/file RET
As this still uses the proxy mechanism underneath,
{{Keys | C-hv}} tramp-default-proxies-alist RET
should now include the value:
<code>("server" "root" "/ssh:user@server:")</code>
Meaning that the proxy <code>/ssh:user@server:</code> is going to be used whenever you request a file as <code>root@server</code>.
Something important to note here is that you usually don't need to specify ''server'' in the ''sudo:server'' part -- and indeed ''sudo::'' will still work in a sense -- however if you do that then the dynamic proxy created will contain the hostname you originated from rather than the host you connected to, so I would recommend being explicit; otherwise it will not only look confusing (as the wrong host will be displayed in filenames), but it will also mean that subsequent attempts to use ''sudo::'' on the localhost will be proxied to this remote server!
=== Configuration for all emacs versions ===
To set up multiple hop connections you will need to do a little bit of configuration.
The <tt>plink</tt> method built into TRAMP can be used as a mostly drop-in replacement for SSH connections. It uses <tt>plink.exe</tt> from the [ PuTTY suite of tools], which must be installed separately.
== Tips and tricks ==
=== Edit current file as root ===
Use the function below to open the current file as root:
<source lang="lisp">
(defun edit-current-file-as-root ()
"Edit the file that is associated with the current buffer as root"
(let ((filep (buffer-file-name)))
(if filep (find-file (concat "/sudo::" filep))
(message "Current buffer does not have an associated file."))))
== Debugging ==
=== "Waiting for prompts from remote shell" message error ===
This problem (as many others) is due to a fancy shell prompt of the remote host that Tramp doesn't understand.
Try setting a normal one
set PS1="> "
and try again.
You could also change the prompt regexp that Tramp understands ('''M-x customize-variable RET tramp-terminal-prompt-regexp''') but that is discouraged, or change the host prompt depending on the connection type (Tramp terminal shall be 'dumb', check the variable tramp-terminal-type):
<source lang="shell">
case "$TERM" in
PS1="> "
See the original [ Stack Overflow answer].
[[Category:Remote Edit]]

Navigation menu