Good afternoon. To visit the local sudo privilege file, I use the tramp command:

Ctr+f //sudo::/путьКфайлу

Is it possible to open a remote file with sudo privileges if emacs already uses tramp, and the invitation to enter visiting the file looks like:

Ctr+f /ssh:remoteHost:/home/uzvr

It seems to me there should be a team to change the privileges of opening files when emacs is already working with deleted files. Thanks.

Thank you, Michael Albinus, you get a new jump, and you can’t use the fact that you already reached the host. I use an ssh certificate to access the host (it is written in the configuration file, thank you again for this personally), a third-party application forms the command (in this case, my command looks like this:

/usr/local/bin/emacs -eval '
  (require (quote tramp-sh))
  (let ((args (assoc (quote tramp-login-args)
                     (assoc "ssh" tramp-methods))))
    (setcar (cdr args)
            (append (quote (("-F" "/home/alamd/ПакетыДоступа/al_kuhnia/config")))
                    (cadr args)))))' \
"/ssh:remoteHost: ~"

Next, emacs opens the user folder. It turns out then how can I transfer the configuration file for ssh again to tramp


1 Answer 1


Use Tramp's multi-hop:

C-x C-f /ssh:remoteHost|sudo:remotehost:/home/uzvr

The Tramp manual gives you more detail.

This will only work if you immediately attach my ssh configuration file for the trump, but I would like not to edit all files from root.only such a solution comes to mind

M-: (progn
      (require (quote tramp-sh))
      (let ((args (assoc (quote tramp-login-args)
                         (assoc "ssh" tramp-methods))))
        (setcar (cdr args)
                (append (quote (("-F" "/home/alamd/ПакетыДоступа/al_kuhnia/config")))
                        (cadr args))))
      (find-file "/ssh:remoteHost|sudo:remotehost:/etc/ssh/sshd_config"))
  • did not fit into the comment, posted above
    – uanr81
    Feb 14, 2020 at 19:59
  • There's no need to edit all files as root. If you add the change-to-my-config-file form to your ~/.emacs. it shall work for both /ssh:remoteHost:/home/uzvr and /ssh:remoteHost|sudo:remotehost:/home/uzvr. Feb 15, 2020 at 8:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.