How do you hide login information (esp passwords) in .emacs init file?

6

If you're using an extension or emacs mode (e.g. rcirc) that has auto-login or similar config to store username and password, how do you hide password and/or username info?

I'd like to do something similar to how you put a link to something like a .smbpasswd file in /etc/fstab.

labyrinth

Posted 2012-05-29T05:05:35.927

Reputation: 2 116

Answers

7

The standard Emacs way is to put in .authinfo.gpg

machine www.example.com login itsme password secret

and to encode it using gpg. I didn't test it with rcirc, but both gnus and tramp use it.

You can also put the same information into .authinfo, using only chmod to protect-it, but it won't be as secure.

Reading the source of Emacs auth-source.el show that it can do quite complex thing, in particular, you could use M-x customize-variable auth-sources to choose different way to specify login/mdp to Emacs (including gnome and kde stuff).

Rémi

Posted 2012-05-29T05:05:35.927

Reputation: 1 300

Out of curiosity: do these Emacs extensions require this file to be named .authinfo, or do they accept .netrc as well? Several other Unix tools use ~/.netrc, which has the exact same syntax. – user1686 – 2012-05-29T07:41:57.930

@grawity: I do not know, but you can create a symbolic link nevertheless. – choroba – 2012-05-29T08:49:21.110

You can change the auth-sources Emacs variable to point to the file you use. Its default value is ("~/.authinfo" "~/.authinfo.gpg" "~/.netrc") meaning that .netrc will be looked at. – Rémi – 2012-05-29T15:47:35.337