Learn R Programming

mirai (version 2.6.0)

ssh_config: SSH Remote Launch Configuration

Description

Generates a remote configuration for launching daemons over SSH, with the option of SSH tunnelling.

Usage

ssh_config(
  remotes,
  tunnel = FALSE,
  timeout = 10,
  command = "ssh",
  rscript = "Rscript"
)

Value

A list in the required format to be supplied to the remote argument of daemons() or launch_remote().

Arguments

remotes

(character) URL(s) to SSH into using scheme 'ssh://', e.g. 'ssh://10.75.32.90:22' or 'ssh://nodename'. Port defaults to 22.

tunnel

(logical) whether to use SSH tunnelling. Requires url hostname '127.0.0.1' (use local_url() with tcp = TRUE). See SSH Tunnelling section.

timeout

(integer) maximum seconds for connection setup.

command

(character) shell command for launching daemons (e.g. "ssh"). NULL returns shell commands for manual deployment without launching.

rscript

(character) Rscript executable. Use full path if needed, or "Rscript.exe" on Windows.

SSH Direct Connections

The simplest use of SSH is to execute the daemon launch command on a remote machine, for it to dial back to the host / dispatcher URL.

SSH key-based authentication must already be in place. The relevant port on the host must be open to inbound connections from the remote machine. This approach is suited to trusted networks.

SSH Tunnelling

SSH tunnelling launches remote daemons without requiring the remote machine to access the host directly. Often firewall configurations or security policies may prevent opening a port to accept outside connections.

A tunnel is created once the initial SSH connection is made. For simplicity, this SSH tunnelling implementation uses the same port on both host and daemon. SSH key-based authentication must already be in place, but no other configuration is required.

To use tunnelling, set the hostname of the daemons() url argument to be '127.0.0.1'. Using local_url() with tcp = TRUE also does this for you. Specifying a specific port to use is optional, with a random ephemeral port assigned otherwise. For example, specifying 'tcp://127.0.0.1:5555' uses the local port '5555' to create the tunnel on each machine. The host listens to '127.0.0.1:5555' on its machine and the remotes each dial into '127.0.0.1:5555' on their own respective machines.

Daemons can be launched on any machine accessible via SSH, whether on the local network or in the cloud.

See Also

cluster_config(), http_config() and remote_config() for other types of remote configuration.

Examples

Run this code
# direct SSH example
ssh_config(c("ssh://10.75.32.90:222", "ssh://nodename"), timeout = 5)

# SSH tunnelling example
ssh_config(c("ssh://10.75.32.90:222", "ssh://nodename"), tunnel = TRUE)

if (FALSE) {

# launch daemons on the remote machines 10.75.32.90 and 10.75.32.91 using
# SSH, connecting back directly to the host URL over a TLS connection:
daemons(
  n = 1,
  url = host_url(tls = TRUE),
  remote = ssh_config(c("ssh://10.75.32.90:222", "ssh://10.75.32.91:222"))
)

# launch 2 daemons on the remote machine 10.75.32.90 using SSH tunnelling:
daemons(
  n = 2,
  url = local_url(tcp = TRUE),
  remote = ssh_config("ssh://10.75.32.90", tunnel = TRUE)
)
}

Run the code above in your browser using DataLab