reddit / emacs

[HELP] sudo over ssh

pasholnahuy228 · 2022-06-09 09:42
Having troubles with it. Tried this: $ emacs -nw /ssh:user@172.16.42.1|sudo::/etc/hosts $ emacs -nw /ssh:user@172.16.42.1|sudo:172.16.42.1:/etc/hosts but no matter what I try I just keep getting an empty editor window and stuff like `bash: sudo::/etc/hosts: No such file or directory` in the terminal. The file I'm looking for definitely does exist. Anything wrong with the command syntax maybe? Emacs 28.1 on linux. Thanks.
carnivorousdrew · 2022-06-09 09:51
You can just pass root as a user if you need root privileges without having to insert that sudo part.
pasholnahuy228 · 2022-06-09 09:54
I know, but let's imagine I don't have a root password - only a sudo-capable account.
gojirabsd · 2022-06-09 10:01
Put the complete /ssh... part in " or '. Or try: emacs -nw /ssh:user@172.16.42.1\\|sudo:172.16.42.1:/etc/hosts
deaddyfreddy · 2022-06-09 10:08
I believe `sudo-edit` supports remote hosts.
anaumann · 2022-06-09 11:50
Given the error message, this sounds about right.. It's an unescaped pipe that is executed by the shell, not passed on to emacs.
pasholnahuy228 · 2022-06-09 11:54
Shit, that was obvious. Thanks a lot.