10

/multi used to work for me, now it's gone and I'm frustrated.

What I want to do is, in my dream world:

/myuser@remotehost:sudo:anotheruser:/some/path/to/file

...and have ido-mode work.

The key thing here is that 'myuser', 'remotehost' and 'anotheruser' are all very ad-hoc, I use a huge array of remote hosts, often with different users and sudo-ing to a wide range of different users.

What do I need to add and how can I test it without reloading emacs over and over?

Chris Withers
  • 10,837
  • 4
  • 33
  • 51
  • Could you be more precise: did you use `tramp-completion-function-alist`? What's your configuration? Maybe the following post may help you: http://stackoverflow.com/questions/95631/open-a-file-with-su-sudo-inside-emacs – Renaud Oct 22 '11 at 00:01
  • 1
    This thread gives the full background: http://lists.gnu.org/archive/html/tramp-devel/2011-10/msg00014.html – Chris Withers Oct 29 '11 at 07:42

2 Answers2

9

As of this commit, TRAMP supports ad-hoc multiple hops again.

Roughly speaking, you use it like this:

/ssh:transituser@remotehost|sudo:user@remotehost:/some/file

I haven't got it to work reliably with ido-mode yet, which is a shame, but it's a lot better than nothing! :-)

itsjeyd
  • 5,070
  • 2
  • 30
  • 49
Chris Withers
  • 10,837
  • 4
  • 33
  • 51
  • 2
    Included in Emacs 24, for anyone wondering. See also http://stackoverflow.com/a/16408592/324105 – phils May 07 '13 at 03:06
  • Confirmed this worked for me on Emacs 24.3, no special configurations needed. A point of clarification: If your is an alias defined in ~/.ssh/config (with Host), then use your local alias for in both places -- you don't need to translate to the true hostname for the sudo. You can also use this for dired/dired+ to open remote directories and eshell. – mike Jul 10 '14 at 11:14
0

The following code may help:

  (defun find-file-as-root ()
    "Find a file as root."
    (interactive)
    (let* ((parsed (when (tramp-tramp-file-p default-directory)
                     (coerce (tramp-dissect-file-name default-directory)
                             'list)))
           (default-directory
             (if parsed
                 (apply 'tramp-make-tramp-file-name
                        (append '("sudo" "root") (cddr parsed)))
               (tramp-make-tramp-file-name "sudo" "root" "localhost"
                                           default-directory))))
      (call-interactively 'find-file)))

I had it in my .emacs file, and it seems to come from here: http://atomized.org/2011/01/toggle-between-root-non-root-in-emacs-with-tramp/

I haven't used it extensively but it seems like that is a step in the right direction.

stevejb
  • 2,414
  • 5
  • 26
  • 41