Edit file as other user on other host in Emacs

242 Views Asked by At

I've seen this but my situation is slightly different. Currently I edit the file like this:

  1. ssh HOST_1
  2. ssh HOST_2
  3. su OTHER_USER
  4. vim ~/FILENAME

How do I tell Emacs (using tramp) to edit this file, while including the hop from HOST_1 to HOST_2 as well as the su OTHER_USER?

"multi-hop" with "me" as the user works fine:

/sshx:HOST_1|sshx:HOST_2:/user/me/FILENAME

However, adding sudo su OTHER_USER fails:

/sshx:HOST_1|sshx:HOST_2|sudo:OTHER_USER@HOST_2:

After typing the final colon, I am prompted for a password. After entering the password, I can type the remote file path, but it appears to be an empty filesystem somewhere, with no folders or files at all.

The *Messages* buffer contains this:

Tramp: Encoding local file ‘/tmp/tramp.61Eexc.ulUhgA’ using ‘base64-encode-region’...done
Tramp: Decoding remote file ‘/ssh:HOST_2:/tmp/tramp.ulUhgA’ using ‘base64 -d -i >%s’...done

I've replicated this on my preferred Emacs setup (using sshx with spacemacs 0.200.13, Emacs 26.3) as well as a completely vanilla Emacs 25.2.2 (using ssh).

0

There are 0 best solutions below