I would like to upgrade my current workflow so I can use Emacs to edit a file on a remote machine. Here is what I have to do now:

ssh remote # password1 required
sudo su -l otheruser # password2 required

I should note that remote is defined in my ~/.ssh/config file and I am using a password to protect my ~/.ssh/id_rsa key.

But (a) I don't know the exact syntax for this command and (b) what I have tried seems to not work.

Here is my first attempt, based on this and this:

C-x C-f /sshx:remote|su:otheruser@remote:

This prompts me first for the password for remote, and then prompts for the password for otheruser@remote. And then nothing - no error message, but also no remote file access.

Is this syntax correct to recreate the basic "first ssh, then su" workflow from above?

  • The TRAMP path looks correct - I just tested the same on Linux with Emacs 27.0.91. Worked correctly. Have you tried setting tramp-verbose to 3 or higher, then looking in the *Messages* buffer after? – gregoryg Jun 10 at 3:22
  • n.b. Tramp debug messages go to a buffer named *debug tramp/FOO* for the connection FOO. – phils Jun 11 at 5:59
  • I think the root cause was not being on the right VPN for the initial host, although on second thought that doesn't make sense because using plain ssh from a terminal worked. In trying to fix this, I got my emacs into a bad state with recently opened files asking for passwords and not allowing my config file to load properly. At this point I think there's too much other noise going on in my setup for this question to be properly answered. – Alex Shroyer Jun 11 at 13:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.