The cache expiry

(setq password-cache-expiry nil)

works only for the livetime of the emacs client. But I found in the Tramp user manual the possibility to store passwords permanently

5.12.1 Using an authentication file


machine melancholia port scp login daniel password geheim

How do I setup this permanent password storage?

  • 2
    If you are connecting via SSH, I'd rather use ~/.ssh/config file to store connection settings. Note that using passwords for SSH connection is generally not advisable since asymmetric cryptography provides much better protection. The only valid uses could be if you connect to a machine with no internet access or similar cases when security doesn't matter. – wvxvw Feb 2 '15 at 8:59

Do as recommended in the Tramp manual. Write your settings into ~/.authinfo.gpg. This requires a more recent Emacs which supports auth-source.el, I guess any Emacs 24.* should do.


In addition to the Tramp manual, there's a full manual for auth-source.el: (info "auth") that I wrote, which may help you. In the case of SSH logins, you may find it better to avoid passwords altogether--look at SSH keys instead.

Your Answer

