如何使用R中的ssh连接到远程服务器

use*_*980 15 ssh r

是否可以使用用户名和密码连接到远程ssh服务器并读取文件?我做了一些研究,并没有得到任何关于此的信息.我很欣赏任何见解.

Ale*_*iev 12

在RCurl中直接支持ssh/scp:

x = scp("remote.ssh.host.com", "/home/dir/file.txt", "My.SCP.Passphrase", user="username")
Run Code Online (Sandbox Code Playgroud)


sgi*_*ibb 5

@JamesThompson 在Can R read from a file through an ssh connection 中的回答有什么问题? (第二个代码示例使用用户名和密码)

请尝试以下操作:

> d <- read.table(pipe('ssh -l user remotehost "cat /path/to/your/file"'))
user@remotehost's password: # type password here
Run Code Online (Sandbox Code Playgroud)

ssh必须安装并在$PATH.