ssh_setup: Setup SSH

View source: R/outsider.R

ssh_setupR Documentation

Setup SSH

Description

Send all outsider commands to an external host. Provide an ssh session to this function and all subsequent commands will be run on the host rather than the local machine. When finished it is always good practice to disconnect from the remote host by running ssh_teardown. It is required that the remote host has Docker running.

Usage

ssh_setup(session)

Arguments

session

ssh session, see ssh_connect

Value

logical

Examples

library(outsider)

# To forward all Docker commands to a remote host:
# 1. Gain ssh access to a remote host
# 2. Ensure Docker is running on the remote machine
# 3. Supply the IP address and authentication args to ssh::ssh_connect
ip_address <- NULL

if (!is.null(ip_address)) {
  # Create an ssh session
  session <- ssh::ssh_connect(host = ip_address)
  
  # Setup the session for running outsider
  ssh_setup(session)
}

# After setup, run outsider as normal

# simplest repo
repo <- 'dombennett/om..hello.world'

if (is_module_installed(repo = repo)) {
  # import
  hello_world <- module_import(fname = 'hello_world', repo = repo)
  
  # run function
  hello_world()
}

# Always ensure to disconnect after a session
if (!is.null(ip_address)) {
  ssh_teardown()
}

AntonelliLab/outsider documentation built on June 17, 2022, 3:27 p.m.