Learn R Programming

googleComputeEngineR (version 0.1.0)

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

Description

Assumes that you have ssh & scp installed.

Usage

gce_ssh(instance, ..., key.pub = NULL, key.private = NULL, wait = TRUE, capture_text = FALSE, username = Sys.info()[["user"]])
gce_ssh_upload(instance, local, remote, username = Sys.info()[["user"]], key.pub = NULL, key.private = NULL, verbose = FALSE, wait = TRUE)
gce_ssh_download(instance, remote, local, username = Sys.info()[["user"]], key.pub = NULL, key.private = NULL, verbose = FALSE, overwrite = FALSE, wait = TRUE)

Arguments

instance
Name of the instance of run ssh command upon
...
Shell commands to run. Multiple commands are combined with && so that execution will halt after the first failure.
key.pub
The filepath location of the public key, only needed first call per session
key.private
The filepath location of the private key, only needed first call per session
wait
Whether then SSH output should be waited for or run it asynchronously.
capture_text
whether to return the output of the SSH command into an R text
username
The username you used to generate the key-pair
local, remote
Local and remote paths.
verbose
If TRUE, will print command before executing it.
overwrite
If TRUE, will overwrite the local file if exists.

Value

If capture_text is TRUE, the text of the SSH command result.

Details

Only works connecting to linux based instances.

On Windows you will need to install an ssh command line client.

You will need to generate a new SSH key-pair if you have not connected to the instance before.

Otherwise, instructions for this can be found here: https://cloud.google.com/compute/docs/instances/connecting-to-instance.

When you have generated it run gce_ssh_setup once to initiate setup.

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

See Also

https://cloud.google.com/compute/docs/instances/connecting-to-instance

Other ssh functions: gce_ssh_browser, gce_ssh_setup

Examples

Run this code

## Not run: 
# 
#   gce_ssh("rbase", "sudo journalctl -u rstudio")
# 
# ## End(Not run)

Run the code above in your browser using DataLab