ssh使用R system()命令 [英] ssh using R system() command
问题描述
当我尝试使用ssh和R的 system()
命令将计算机A连接到计算机B时,出现错误:
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
但是,如果我在Linux终端( ssh root @ Bs-ip-address
)中使用引号将命令输入,它将正常工作(为正确的用户设置了ssh密钥).如何使用R的 system()
命令正确连接?还是可以建议一种更好的连接方式?
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?
这可能与需要在Linux中出现的以下提示中输入是"有关:
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)?
在腻子会话中一次输入是"后,上面的R system()
命令将起作用.但是我不想每次都要腻子.(作为一个旁注,我正在使用预设的ssh键创建许多相同的Digital Ocean实例,并尝试从R连接到它们,因此每次为每个新实例进入一次腻子会话都不可行.)您可以使用 system()
发送'yes'命令吗?
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()
?
推荐答案
您可以自动执行该接受操作(注意:必须确保您将要访问的计算机受信任!)
You could automate that acceptance (caveat: you have to be sure that the machines you're about to access are trusted!).
例如,如果主机具有rsa密钥,则可以执行以下操作:
If the hosts have rsa keys, for instance, you can do:
system( 'ssh-keyscan -t rsa Bs-ip-address >> ~/.ssh/known_hosts' )
HIH.
这篇关于ssh使用R system()命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!