
Open SSH Tunnel to a Running Step
improveOpenTunnel.RdOpens an SSH port-forwarding tunnel to an interactive step (e.g. RStudio, Jupyter) running on an improve runserver. If the step is not yet running, it is started with the SSH public key fingerprint registered for authentication.
Value
An environment (tunnel object) with:
urlThe URL to access the step (e.g.
http://<runId>.localhost:8787/)isAlive()Returns
TRUEif the tunnel is still openclose()Closes the tunnel
pidThe SSH process PID
runIdThe run ID
stepIdentThe step identifier
Details
The function performs the following steps:
Generates an SSH key pair if one does not exist
If the step is not running, starts it with the SSH fingerprint registered
Waits for the step to reach RUNNING status
Reads the dynamically assigned Docker port from run metadata
Opens an SSH tunnel from
localhost:<localPort>to the container portOptionally opens the browser
The tunnel is automatically closed when the R session ends.
Requires the processx package (Suggests) and ssh/ssh-keygen
on the system PATH.
Examples
if (FALSE) { # \dontrun{
stepEnv <- createStepTemplateEnv(treeIdent = myTree)
stepEnv$setStepRunserverLabel("runserver")
stepEnv$setStepToolLabel("R 3_Std")
stepEnv$setStepToolInstance("imRstudio 1.3")
step <- stepEnv$realise(run = FALSE)
tunnel <- improveOpenTunnel(step, localPort = 8787)
# Opens browser to http://<runId>.localhost:8787/
tunnel$isAlive()
tunnel$close()
} # }