When I do what you're describing, I get prompted for my password:

   >  system('ssh -l  usernm rmthost')
   use...@rmthost's password:

After I enter my password, nothing seems to happen. But if I hit ctrl-c then I get a command line prompt, and it turns out that it's a shell prompt on the remote host. I can issue standard unix commands, and they execute on the remote host. To get back into R on my local host I type 'exit'.

Or:

Here's a couple of lines from one of my scripts that might help ...

    cmd <- 'ssh -l username remotehost /bin/lpstat -a'
    lprs <- read.table(pipe(cmd),fill=TRUE,as.is=TRUE)[,1]

I get prompted for my password when I source these lines on my local host.

With the result that the lprs object has the names of printers available on the remote host.

-Don

At 10:01 PM -0800 4/8/10, afoo wrote:
Hi,

I am trying to SSH to a remote server through R script. In other words, I
would like to know how I can get a SSH connection to the remote server and
then execute commands on that server with the R script.

So in bash, I would normally type ssh -lusername remoteserver.com; press
enter and then wait for the password prompt to key in my password.

I have tried system("ssh remoteserver.com") but that doesn't work because,
from what I know, SSH requires user interactivity - I am required to key in
my password.

I tried looking up about putting password as a command line parameter, but
SSH doesn't allow that, my only option then is to set up a private/public
key pair. But the admin of the remoteserver doesn't allow me to do that.

Is there a way in which I can SSH in? Or is there a command in R that allows
me to interact with the command prompts interactively?

thanks,
afoo
--
View this message in context: http://*n4.nabble.com/SSH-Through-R-Script-tp1809635p1809635.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help@r-project.org mailing list
https://*stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://*www.*R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


--
--------------------------------------
Don MacQueen
Environmental Protection Department
Lawrence Livermore National Laboratory
Livermore, CA, USA
925-423-1062

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to