I have

(require 'password-cache)
(setq password-cache-expiry nil)

set in my .emacs file.

(2) When I connect to "machine" via tramp with:

dired /ssh:user@machine:

I get logged via ssh and don't need a password, as expected and desired. Then, when I want to sudo I need to give the password for user@machine, as expected and desired. However, emacs doesn't seem to remember that password and periodically I have to reenter it.

(3) A partial workaround is to connect to "machine" via tramp in sudo mode:

dired /ssh:user@machine|sudo:user:/home/user

This allows sudo priveleges without experiation within a single emacs session. The drawback is that it doesn't allow dropping down out of sudo mode into ordinary user mode. Tying "exit" into the shell kills the sudo shell but doesn't go to a user shell.

In a single session using tramp to remote as in (1), is there a way to get emacs to remember the sudo password and apply it automatically whenever the prompt comes up?

Note: I don't want to remove the timeout on the remote sudo password via a setting file on the remote machine.


Following Micheal Albinus' suggestion, I download the git version of tramp. I used this method to download:

Note: ~/emacs dir was replaced with ~/work/emacs-git in practice.

 ] cd ~/emacs
 ] git clone git://git.savannah.gnu.org/tramp.git
 ] cd ~/emacs/tramp
 ] autoconf

Then I tried to setup emacs to that version according to these instructions in the TRAMP users manual:

4.3 How to plug-in TRAMP into your environment.

If you don’t install TRAMP into the intended directories, but prefer to use from the source directory, you need to add the following lines into your .emacs:

(add-to-list 'load-path "~/emacs/tramp/lisp/") (require 'tramp)

If the environment variable INFOPATH is set, add the directory ~/emacs/tramp/info/ to it. Else, add the directory to Info-default-directory-list, as follows:

(add-to-list 'Info-default-directory-list "~/emacs/tramp/info/")

I tried adding those lines at at the end, then after that failed at the beginning of the .emacs file.

However, perhaps because "plugin" method doesn't consider overriding an existing version, I got the error message below and emacs did not initialize correctly.

I now have an auxiliary question: How best to test an development version of an integrated emacs module, in this case TRAMP?

Debugger entered--Lisp error: (void-variable tramp-version)
  (format "INSIDE_EMACS='%s,tramp:%s'" emacs-version tramp-version)
  (cons (format "INSIDE_EMACS='%s,tramp:%s'" emacs-version tramp-version) (quote ("CDPATH=" "HISTORY=" "MAIL=" "MAILCHECK=" "MAILPATH=" "PAGER=cat" "autocorrect=" "correct=")))
  (cons (format "TERM=%s" tramp-terminal-type) (cons (format "INSIDE_EMACS='%s,tramp:%s'" emacs-version tramp-version) (quote ("CDPATH=" "HISTORY=" "MAIL=" "MAILCHECK=" "MAILPATH=" "PAGER=cat" "autocorrect=" "correct="))))
  (cons "LC_CTYPE=''" (cons (format "TERM=%s" tramp-terminal-type) (cons (format "INSIDE_EMACS='%s,tramp:%s'" emacs-version tramp-version) (quote ("CDPATH=" "HISTORY=" "MAIL=" "MAILCHECK=" "MAILPATH=" "PAGER=cat" "autocorrect=" "correct=")))))
  (cons "TMOUT=0" (cons "LC_CTYPE=''" (cons (format "TERM=%s" tramp-terminal-type) (cons (format "INSIDE_EMACS='%s,tramp:%s'" emacs-version tramp-version) (quote ("CDPATH=" "HISTORY=" "MAIL=" "MAILCHECK=" "MAILPATH=" "PAGER=cat" "autocorrect=" "correct="))))))
  (defvar tramp-remote-process-environment (cons "TMOUT=0" (cons "LC_CTYPE=''" (cons (format "TERM=%s" tramp-terminal-type) (cons (format "INSIDE_EMACS='%s,tramp:%s'" emacs-version tramp-version) (quote ("CDPATH=" "HISTORY=" "MAIL=" "MAILCHECK=" "MAILPATH=" "PAGER=cat" "autocorrect=" "correct=")))))) "List of environment variables to be set on the remote host.\n\nEach element should be a string of the form ENVVARNAME=VALUE.  An\nentry ENVVARNAME= disables the corresponding environment variable,\nwhich might have been set in the init files like ~/.profile.\n\nSpecial handling is applied to the PATH environment, which should\nnot be set here. Instead, it should be set via `tramp-remote-path'.")
  eval-buffer(#<buffer  *load*-666330> nil "/usr/local/share/emacs/25.3/lisp/net/tramp-loaddefs.el" nil t)  ; Reading at buffer position 36868
  load-with-code-conversion("/usr/local/share/emacs/25.3/lisp/net/tramp-loaddefs.el" "/usr/local/share/emacs/25.3/lisp/net/tramp-loaddefs.el" nil t)
  eval-buffer(#<buffer  *load*-779028> nil "/home/craig/work/emacs-git/tramp/lisp/tramp-compat.el" nil t)  ; Reading at buffer position 1324
  load-with-code-conversion("/home/craig/work/emacs-git/tramp/lisp/tramp-compat.el" "/home/craig/work/emacs-git/tramp/lisp/tramp-compat.el" nil t)
  eval-buffer(#<buffer  *load*-229435> nil "/home/craig/work/emacs-git/tramp/lisp/tramp.el" nil t)  ; Reading at buffer position 2158
  load-with-code-conversion("/home/craig/work/emacs-git/tramp/lisp/tramp.el" "/home/craig/work/emacs-git/tramp/lisp/tramp.el" nil t)
  eval-buffer(#<buffer  *load*> nil "/home/craig/.emacs" nil t)  ; Reading at buffer position 334
  load-with-code-conversion("/home/craig/.emacs" "/home/craig/.emacs" t t)
  load("~/.emacs" t t)
  #[0 "\205\266 \306=\203\307\310Q\202? \311=\204\307\312Q\202?\313\307\314\315#\203*\316\202?\313\307\314\317#\203>\320\321\322!D\nB\323\202?\316\324\325\324\211#\210\324=\203e\326\327\330\307\331Q!\"\325\324\211#\210\324=\203d\210\203\247\332!\333\232\203\247\334!\211\335P\336!\203\201\211\202\214\336!\203\213\202\214\314\262\203\245\337\"\203\243\340\341#\210\342\343!\210\266\f?\205\264\314\325\344\324\211#)\262\207" [init-file-user system-type delayed-warnings-list user-init-file inhibit-default-init inhibit-startup-screen ms-dos "~" "/_emacs" windows-nt "/.emacs" directory-files nil "^\\.emacs\\(\\.elc?\\)?$" "~/.emacs" "^_emacs\\(\\.elc?\\)?$" initialization format-message "`_emacs' init file is deprecated, please use `.emacs'" "~/_emacs" t load expand-file-name "init" file-name-as-directory "/.emacs.d" file-name-extension "elc" file-name-sans-extension ".el" file-exists-p file-newer-than-file-p message "Warning: %s is newer than %s" sit-for 1 "default"] 7]()

GNU Emacs 25.3.1 (x86_64-pc-linux-gnu, GTK+ Version 3.18.9) of 2018-02-22 on Ubuntu 16.04LTS

  • 1
    Well, this sounds like a problem which was solved in recent Tramp some weeks ago. At least the ChangeLog indicates this. Do you have a chance to test with a recent checkout of Tramp git? (And in case it still doesn't work as intended, we shall be able to fix this then) – Michael Albinus Apr 8 '18 at 11:35
  • @MichaelAlbinus - Thanks very much for your suggestion. I'm having difficulty testing the Git version and before going further I would to ask if you can recommend a best practice for doing such testing. Details of effort so far are added above. – Craig Hicks Apr 8 '18 at 19:34
  • Your Tramp installation seems to be mixed with Emacs proper. What does the command M-x list-load-path-shadowsreturns? – Michael Albinus Apr 10 '18 at 14:02
  • For the emacs version (25.3.1) I am using: "No Emacs Lisp load-path shadowings were found". Downloaded from an official Emacs site, if I remember correctly. // For an older emacs version (24.5.1) which I am not generally using and which came included with Ubuntu 16.04: /usr/share/emacs24/site-lisp/cmake-data/cmake-mode hides /usr/share/emacs/site-lisp/cmake-mode /usr/share/emacs/24.5/site-lisp/debian-startup hides /usr/share/emacs/site-lisp/debian-startup 2 Emacs Lisp load-path shadowings were found – Craig Hicks Apr 11 '18 at 3:19
  • I fear we're going beyond what stackexchange is supporting. Could you pls present your problem at the Tramp mailing list? We could do better debugging then. – Michael Albinus Apr 11 '18 at 7:33

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.