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

Description Usage Arguments Details See Also Examples

View source: R/ssh.R

Description

Assumes that you have ssh & scp installed. If on Windows see website and examples for workarounds.

Usage

1
2
3
4
5
6
cloud_ssh(instance, ..., key.pub = NULL, key.private = NULL, wait = TRUE,
  capture_text = "", username = "")

cloud_ssh_upload(instance, local, remote, wait = TRUE)

cloud_ssh_download(instance, remote, local, overwrite = FALSE, wait = TRUE)

Arguments

instance

The Instance object

...

List of parameters

key.pub

The public SSH key

key.private

The private SSH key

wait

Whether then SSH output should be waited for or run it asynchronously.

capture_text

Possible values are "", to the R console (the default), NULL or FALSE (discard output), TRUE (capture the output in a character vector) or a character string naming a file.

username

The useranme

local, remote

Local and remote paths.

overwrite

If TRUE, will overwrite the local file if exists.

Details

Taken via https://github.com/cloudyr/googleComputeEngineR/blob/master/R/ssh.R

Only works connecting to linux based instances.

On Windows you will need to install an ssh command line client - see examples for an example using RStudio's built in client.

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

To customise SSH connection see sparkler.create

capture_text is passed to stdout and stderr of system2

Otherwise, instructions for generating SSH keys can be found here: https://www.ovh.com/us/publiccloud/guides/g1769.creating_ssh_keys.

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

See Also

Other ssh functions: cloud_ssh_addkeys

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
## Not run: 

  # you need to instance a client for creating VM

  ## if running on Windows, use the RStudio default SSH client
  ## add C:\Program Files\RStudio\bin\msys-ssh-1000-18 to your PATH
  ## AND
  ## add C:\Program Files\RStudio\bin\msys-ssh-1000-18 to your RSTUDIO_SSH_PATH
  ## then run:

  regionVM <- "UK1"
  typeVM <- "s1-4"
  sshPubKeyPath  <- './.ssh/id_rsa.pub'
  sshPrivKeyPath <- './.ssh/id_rsa'
  vm <- createSparkler(client,regionVM,typeVM,sshPubKeyPath,sshPrivKeyPath)

  ## if you have already logged in via gcloud, the default keys will be used
  ## no need to run cloud_ssh_addkeys
  ## run command on instance
  cloud_ssh(vm, "pwd")
  #> /user/debian



## End(Not run)

voltek62/RsparkleR documentation built on May 19, 2019, 1:48 a.m.