ssh使用R system()命令

当我尝试使用ssh和R的system()命令将计算机A连接到计算机B时,出现错误:

 system('ssh root@Bs-ip-address') ssh_askpass: exec(rpostback-askpass): No such file or directory Host key verification failed. lost connection 

但是,如果我input命令引号到我的Linuxterminal( ssh root@Bs-ip-address )它工作正常(SSH密钥设置为正确的用户)。 如何使用R的system()命令正确连接? 或者你能build议一个更好的方法来连接?

这可能与需要在Linux中出现的以下提示中input“yes”有关:

 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)? 

在putty会话中input'yes'后,上面的R system()命令将工作。 但我不想每次都进入腻子。 (作为一个方面说明,我使用预先设置的ssh键创build了大量相同的Digital Ocean实例,并尝试从R连接到它们,因此每次为每个新实例input一个putty会话都不是一个可行的选项。 )你可以发送一个“是”命令使用system()

你可以自动接受(注意:你必须确保你要访问的机器是可信的!)。

例如,如果主机有rsa密钥,则可以执行以下操作:

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

HIH。