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

gce_ssh(instance, ..., = NULL, key.private = NULL,
  wait = TRUE, capture_text = "", username =[["user"]])

gce_ssh_upload(instance, local, remote, username =[["user"]], = NULL, key.private = NULL, verbose = FALSE, wait = TRUE)

gce_ssh_download(instance, remote, local,
  username =[["user"]], = NULL,
  key.private = NULL, verbose = FALSE, overwrite = FALSE,
  wait = TRUE)



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.

The filepath location of the public key


The filepath location of the private key


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


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.


The username you used to generate the key-pair

local, remote

Local and remote paths.


If TRUE, will print command before executing it.


If TRUE, will overwrite the local file if exists.


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 gce_ssh_setup

capture_text is passed to stdout and stderr of system2

Otherwise, instructions for generating SSH keys can be found here:

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

See also


if (FALSE) { vm <- gce_vm("my-instance") ## if you have already logged in via gcloud, the default keys will be used ## no need to run gce_ssh_addkeys ## run command on instance gce_ssh(vm, "echo foo") #> foo ## if running on Windows, use the RStudio default SSH client ## e.g. add C:\Program Files\RStudio\bin\msys-ssh-1000-18 to your PATH ## then run: vm2 <- gce_vm("my-instance2") ## add SSH info to the VM object ## custom info vm2 <- gce_ssh_setup(vm2, username = "mark", = "C://.ssh/", key.private = "C://.ssh/id_rsa") ## run command on instance gce_ssh(vm2, "echo foo") #> foo }