Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Way to securely give a password to R application from the terminal?

Does R have a function that allows a user to provide a password securely, such as Python's getpass module?

(see http://docs.python.org/library/getpass.html for an example of what I mean)

like image 918
HamiltonUlmer Avatar asked May 26 '10 22:05

HamiltonUlmer


People also ask

How do passwords pass securely from server to client?

This is usually overcome by encrypting the communication between the user and the server. The most common form of encryption is the Transport Layer Security (TLS) standard or the older SSL standard (Secure Socket Layer).

Is it safe to send password over HTTP?

So while it's possible to communicate passwords securely using HTTP, it's not possible to securely-store passwords on the server while using it.


2 Answers

The problem is that R does not have functions to control the terminal it is running in (something like Rncurses); probably this is due to portability issues.
Some time ago I was struggling with the same problem and I ended up with a function using TclTk:

getPass<-function(){     require(tcltk);     wnd<-tktoplevel();tclVar("")->passVar;     #Label     tkgrid(tklabel(wnd,text="Enter password:"));     #Password box     tkgrid(tkentry(wnd,textvariable=passVar,show="*")->passBox);     #Hitting return will also submit password     tkbind(passBox,"<Return>",function() tkdestroy(wnd));     #OK button     tkgrid(tkbutton(wnd,text="OK",command=function() tkdestroy(wnd)));     #Wait for user to click OK     tkwait.window(wnd);     password<-tclvalue(passVar);     return(password);   }   

Of course it won't work in non-GUI environments.

like image 95
mbq Avatar answered Sep 28 '22 22:09

mbq


Very simple linux concept for terminal secure password question:

   password <- function(prompt = "Password:"){       cat(prompt)       pass <- system('stty -echo && read ff && stty echo && echo $ff && ff=""',                         intern=TRUE)       cat('\n')       invisible(pass)    }         
like image 28
seventm Avatar answered Sep 28 '22 22:09

seventm