Are there any technical reasons or use cases for why sudo:: in TRAMP cannot use the rightmost host to the left of it, instead of localhost?

When I do /ssh:[email protected]|sudo::/tmp/file, I would expect the sudo:: to implicitly use [email protected].

More generally, when multiple SSH hops are chained together, such as in/ssh:jumpbox.example.com|ssh:remote.example.com|sudo::/tmp/file, I would expect the sudo:: to always use the rightmost host to the left of the sudo::.

I expect this because from a user interface and experience perspective, to me this seems like the obviously more intuitive and most convenient behavior for it to do.

But this does not happen. Instead, sudo:: seems to always implicitly use root @ the local host.

I understand that this is how it is. What I don't understand is why? Are there technical reasons for why implementing this would be difficult, or common use cases I am not imagining that would be broken if this was implemented?

1 Answer 1


You'll be happy to learn that in more recent tramp releases (first included in Emacs 27.1) the :: case will work the way you want it to, such that /ssh:you@remotehost|sudo:: will re-use remotehost rather than your own local hostname, so you won't end up with a bad proxy entry.

In addition, the likes of /ssh:you@remotehost|sudo:localhost: are detected and flagged as user errors.

Of course, if you are liable to use a mixture of Emacs versions, you should continue to treat :: as unsafe when multi-hopping in general, to avoid potential mishap.

-- https://stackoverflow.com/questions/2177687/open-file-via-ssh-and-sudo-with-emacs/16408592#comment94821206_16408592

  • So I think this answers my question implicitly: no, there are no technical issues or use cases preventing it, as evidence by the fact that it was recently done. Thanks!
    – mtraceur
    Commented Aug 15, 2020 at 4:15
  • 1
    And in case you cannot upgrade to the just released Emacs 27.1, you might use Tramp from GNU ELPA. That version has also solved the problem. Commented Aug 15, 2020 at 14:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.