2

When I try to connect computer A to computer B using ssh and R's system() command, I get an error:

system('ssh root@Bs-ip-address')

ssh_askpass: exec(rpostback-askpass): No such file or directory
Host key verification failed.
lost connection

But if I enter the command in quotes into my Linux terminal (ssh root@Bs-ip-address) it works fine (ssh keys are set up for the correct user). How can I connect properly using R's system() command? Or can you suggest a better way to connect?

It might have something to do with needing to enter 'yes' to the following prompt that arises within Linux:

The authenticity of host Bs-ip-address (Bs-ip-address) cant be established.
ECDSA key fingerprint is unique-fingerprint.
Are you sure you want to continue connecting (yes/no)?

After I enter 'yes' once in a putty session, the R system() command above will work. But I don't want to have to enter into putty each time. (As a side note, I'm creating a number of identical Digital Ocean instances with pre-set ssh keys, and trying to connect to them from R, so entering a putty session each time for each new instance is not a workable option.) Can you send a 'yes' command using system()?

Devon
  • 650
  • 8
  • 19
  • See Jeroen Ooms' R package for SSH: https://github.com/jeroenooms/ssh – daroczig Aug 24 '15 at 03:54
  • Thanks, did not investigate this package, but it looks promising! The accepted solution below was everything I needed. – Devon Aug 24 '15 at 18:11

1 Answers1

3

You could automate that acceptance (caveat: you have to be sure that the machines you're about to access are trusted!).

If the hosts have rsa keys, for instance, you can do:

system( 'ssh-keyscan  -t rsa Bs-ip-address  >> ~/.ssh/known_hosts' )

HIH.

tink
  • 14,342
  • 4
  • 46
  • 50