I edited this question to clarify why I asked this question again (I had weak Google-Fu and found these rather old 1 2 3 pretty-much-duplicates only after posting).
Approaches to accessing a password-protected resources that I've seen in the wild.
- Plaintext storage in script (might often end up being shared, or in a Dropbox)
- Plaintext storage in a config script
- You can do
password = readline("Password: ")
but of course the password ends up in plaintext in the console (and thus in console logs etc.), so might as well store it in a plaintext config file. - I found this little trick to avoid displaying the password in the Terminal, but running
system("stty -echo")
on OS X Mavericks leads to the errorstty: stdin isn't a terminal
, so I guess it wouldn't be particularly portable. - Using
tcltk
. Has the unfortunate effect of making Rstudio crash and being difficult to install. - keychain. It's not on CRAN, so I don't think I can use this as a first-line approach, I'd also like a bit more detail about where and how passwords are stored on various systems (i.e. will it end up in plaintext on Windows?).
- Access tokens, OAuth etc. seem to have similar problems.
I don't know any R packages which use PGP for connections? Probably also a bit difficult for newbie users.
I'm not asking for myself mainly, but I want to provide somewhat sensible defaults for nontechnical users who might store plaintext passwords enabling access to sensitive data in their Dropbox.
Unlike others who asked similar questions, I could also change the server-side of things if I had a better approach.
Are there best-practice approaches that I'm currently missing? My focus on interactive sessions is because I assume that's how most nontechnical types use R, but of course it would be nice if it worked during e.g. knitr report generation too.