reddit / emacs

How do I TRAMP into dired on my server as another user with `sudo -u other_user -s`?

shackra · 2022-02-23 05:12
title. Use case: There are some files I want to edit as another user in a remote server (is old laptop used as server and is in my living room), I wish to execute dired instead of visiting a file so I can see all of the contents of the folder holding the files, but I would like to do this as another user and wish to switch to this user using sudo as these files are owned by him. I log in as my user on the remote server using SSH keys. How do I do that with TRAMP?
wargxs · 2022-02-23 10:25
Google finds this : https://oremacs.com/2015/02/15/sudo-stuffs/
organic-bookworm · 2022-02-23 13:10
Going `ssh` at `host`, then `sudo` as `other_user` at that `host` would be M-x find-file RET /ssh:host#port|su:other_user@:/path/to/file RET See *almost* [direct answer](https://stackoverflow.com/questions/2177687/open-file-via-ssh-and-sudo-with-emacs/16408592#16408592) at SO, especially for Emacs <27. See [TRAMP file name conventions](https://www.gnu.org/software/emacs/manual/html_node/tramp/File-name-syntax.html) in TRAMP manual. Single hop TRAMP URL: /method:user@host:path/to/file See [Declaring multiple hops in the file name](https://www.gnu.org/software/emacs/manual/html_node/tramp/Ad_002dhoc-multi_002dhops.html) in TRAMP manual. Multi-hop TRAMP URL: /method1:user1@host1|method2:user2@host2:path/to/file