Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

scp

Retrieve contents of a file from a remote host via SCP (Secure Copy)


Description

This function allows us to retrieve the contents of a file from a remote host via SCP. This is done entirely within R, rather than a command line application and the contents of the file are never written to disc. The function allows the

Usage

scp(host, path, keypasswd = NA, user = getUserName(), rsa = TRUE,
     key = sprintf(c("~/.ssh/id_%s.pub", "~/.ssh/id_%s"),
                   if (rsa) "rsa" else "dsa"),
     binary = NA, size = 5000, curl = getCurlHandle(), ...)

Arguments

host

the name of the remote host or its IP address

path

the path of the file of interest on the remote host's file systems

keypasswd

a password for accessing the local SSH key. This is the passphrase for the key.

user

the name of the user on the remote machine

rsa

a logical value indicating whether to use the RSA or DSA key

key

the path giving the location of the SSH key.

binary

a logical value giving

size

an estimate of the size of the buffer needed to store the contents of the file. This is used to initialize the buffer and potentially avoid resizing it as needed.

curl

a curl handle (getCurlHandle) that is to be reused for this request and which potentially contains numerous options settings or an existing connection to the host.

...

additional parameters handed to curlPerform.

Details

This uses libcurl's facilities for scp. Use "scp" %in% curlVersion()$protocols to see if SCP is supported.

Value

Either a raw or character vector giving the contents of the file.

Author(s)

Duncan Temple Lang

References

See Also

Examples

## Not run: 
   x = scp("eeyore.ucdavis.edu", "/home/duncan/OmegaWeb/index.html",
           "My.SCP.Passphrase", binary = FALSE)
   x = scp("eeyore.ucdavis.edu", "/home/duncan/OmegaWeb/RCurl/xmlParse.bz2",
           "My.SCP.Passphrase")
   o = memDecompress(x, asChar = TRUE)

## End(Not run)

RCurl

General Network (HTTP/FTP/...) Client Interface for R

v1.98-1.3
BSD_3_clause + file LICENSE
Authors
CRAN Team [ctb, cre] (de facto maintainer since 2013), Duncan Temple Lang [aut] (<https://orcid.org/0000-0003-0159-1546>)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.