0

Ubuntu 16.04 Emacs 26.1 Emacs needs to open the file with root privileges. Here is my code:

    (secrets-delete-item "session" "Login")
(secrets-create-item "session" "Login" "myParol" :method "sudo" :host "iemuser" :user "iemuser")
;(secrets-show-secrets)
; session
; `-[-] Login
;    |-  password:   myParol
;    |-  host:       iemuser
;    |-  user:       iemuser
;    |-  method:     sudo
;    `-  xdg:schema: org.freedesktop.Secret.Generic
(setq auth-sources '("secrets:session"))
(find-file "/sudo::/usr/share/emacs/24.5/lisp/gnus/auth-source.el.gz")

and again Emacs persistently requires a password: Password for /sudo:root@iemuser: How to get Emacs to take the password from my Ubuntu login.


Addition details from the comments:

  • iemuser@iemuser is not a mistake:
    • The localhost is named iemuser
    • I am logged in to that host (and running Emacs on that host) as a user with that same name, iemuser
  • In emacs I wish to programmatically open a root-owned file on this localhost for editing. i.e.: /sudo::/path/to/file
    • My goal is to not be prompted for a sudo password when this happens -- rather, I want emacs to handle the authentication
    • I am trying to use auth-sources and secrets to achieve this
  • I don't know about the "secrets" stuff, but "Password for /sudo:root@iemuser" indicates that you're not actually accessing the correct path. I strongly suspect you've tried to access /sudo:iemuser:... which means "log me in as username root on the host iemuser" (hence root@iemuser in the prompt). The correct syntax (which is common to tramp paths in general) is /sudo:USER@HOST: with the sudo method using root@ as the default user when no username is given. The incorrect attempt may also have created a C-h v tramp-default-proxies-alist entry for the bad hostname. – phils Mar 19 '19 at 22:30
  • Yes, I made a mistake in the code, I did not want to write the real names of the host, user and password. I need to substitute the password from the code, and not enter it manually in the minibuffer. I am trying to pass a parol with the Parol element to the desired password for the host user, but the tramp asks persistently. If I enter the password in the minibuffer, everything opens, and more in this emacs session, the tramp does not ask for the password for this host and user. – uanr81 Mar 20 '19 at 6:16
  • So based on your edits the hostname and the username are both iemuser? Is the iemuser host also the localhost, or is it remote? – phils Mar 20 '19 at 9:57
  • (find-file "/sudo::/usr/share/emacs/24.5/lisp/gnus/auth-source.el.gz") ought to be accessing that path on localhost, not on the iemuser host (although if there's an unfortunate tramp-default-proxies-alist entry from a use of incorrect syntax it's possible for localhost paths to end up being proxied to a remote host, but that's very much dependent on the specific proxies which are defined). – phils Mar 20 '19 at 10:03
  • 1
    I would like to help, but a discussion in the comments section doesn't look appropriate. Pls send your problem to the Tramp mailing list tramp-devel@gnu.org. Michael, Tramp maintainer. – Michael Albinus Mar 20 '19 at 14:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.