analogsea (version 0.6.0)

droplet_ssh: Remotely execute ssh code, upload & download files.

Description

Assumes that you have ssh & scp installed, and password-less login set up on the droplet.

Usage

droplet_ssh(droplet, ..., user = "root", verbose = FALSE)

droplet_upload(droplet, local, remote, user = "root", verbose = FALSE)

droplet_download(droplet, remote, local, user = "root", verbose = FALSE, overwrite = FALSE)

Arguments

droplet

A droplet, or something that can be coerced to a droplet by as.droplet.

...

Shell commands to run. Multiple commands are combined with && so that execution will halt after the first failure.

user

User name. Defaults to "root".

verbose

If TRUE, will print command before executing it.

local, remote

Local and remote paths.

overwrite

If TRUE, then overwrite destination files if they already exist.

Value

On success, the droplet (invisibly). On failure, throws an error.

Details

Uploads and downloads are recursive, so if you specify a directory, everything inside the directory will also be downloaded.

Examples

Run this code
# NOT RUN {
d <- droplet_create() %>% droplet_wait()

# Upgrade system packages
d %>%
  droplet_ssh("apt-get update") %>%
  droplet_ssh("sudo apt-get upgrade -y --force-yes") %>%
  droplet_ssh("apt-get autoremove -y")

# Install R
d %>%
  droplet_ssh("apt-get install r-base-core r-base-dev --yes --force-yes")

# Upload and download files -------------------------------------------------

tmp <- tempfile()
saveRDS(mtcars, tmp)
d %>% droplet_upload(tmp, "mtcars.rds")

tmp2 <- tempfile()
d %>% droplet_download("mtcars.rds", tmp2)
mtcars2 <- readRDS(tmp2)

stopifnot(all.equal(mtcars, mtcars2))
# }

Run the code above in your browser using DataCamp Workspace