Our servers are behind a proxy that requires two factor authenticatio. I managed to get through the authentication process yet was wondering, is there a way of authenticating only once and not for each different connection?

1 Answer 1


Tramp could cache passwords. See variable password-cache-expiry. Its default value expires cached passwords after 16 seconds.

And/or configure auth-source.el properly. For example, add respective entries to .authinfo.

Read the Tramp manual, section "Password handling", for more details.

  • Thanks for your answer though I'm not sure either of those solutions can solve the issue. The two factor authentication password keep changes on a constant interval period of time therefore saving the password doesn't really helps in this case. I tried it.
    – Adam
    May 12, 2018 at 20:18
  • Then I need your use case. Do you mean that there is the same password for different targets, you would like to reuse? May 13, 2018 at 8:43
  • all hosts are behind a single proxy server. In order to login to that server and then multi-hop to the other hosts I must to enter a password that keeps on changing each minute. Thats why saving this password wouldn't help. Is there a way of reusing the connection with the proxy server when connecting to different hosts?
    – Adam
    May 14, 2018 at 21:37
  • I cannot say it for sure. But if tramp-use-ssh-controlmaster-options is set to t, and tramp-ssh-controlmaster-options is set to something like "-o ControlMaster=auto -o ControlPath='tramp.%%C' -o ControlPersist=no", it could work. Both variables exist since Emacs 24.1, I believe. May 15, 2018 at 7:11
  • Thanks again, I tried to use the config you suggested and noticed that this issue only happen when I use the 'sudo' method. If I connect without it it works great and doesn't prompt me for a password login on each connection.
    – Adam
    May 19, 2018 at 22:22

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.