[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Reopening ssh file with sudo
From: |
Michael Albinus |
Subject: |
Re: Reopening ssh file with sudo |
Date: |
Thu, 07 Sep 2023 20:45:46 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) |
Joseph Garvin <k04jg02@gmail.com> writes:
Hi Joseph,
> I originally posted this on the emacs stack exchange
> (https://emacs.stackexchange.com/questions/78768/reopen-with-sudo-command-that-works-through-tramp)
> but they suggested I try here.
"They" is me :-)
> I have tried to define this command:
>
> ```
> (defun etc-reopen-with-sudo ()
> (interactive)
> (let* ((vec (tramp-dissect-file-name (buffer-file-name
> (current-buffer))))
> (method (tramp-file-name-method vec))
> (user (tramp-file-name-user vec))
> (host (tramp-file-name-host vec))
> (localname (tramp-file-name-localname vec)))
> (message "localname=%s" localname)
> (find-alternate-file
> (if (tramp-tramp-file-p (buffer-file-name (current-buffer)))
> (concat (format "/%s:%s@%s|sudo::%s" method user host
> localname))
> (concat "/sudo:root@localhost:" buffer-file-name)))))
> ```
>
> It worked once... and now ever since mysteriously hangs whenever I try
> to use it to open a file with sudo on a remote host with ssh. The idea
> for what file string to use for this comes from
> https://stackoverflow.com/questions/2177687/open-file-via-ssh-and-sudo-with-emacs
> which suggests `/ssh:you@remotehost|sudo:remotehost:/path/to/file`
> should work. I'm able to visit files on the host just fine without
> sudo. Any ideas what I'm doing wrong here?
I'm a little bit overloaded, but I hope to come back to you within a
couple of days.
Best regards, Michael.