library(improveR)
improveSetupSSH()
# SSH fingerprint: SHA256:xCwizvT982RCRQmM6d+x9QZYcfU/B42MU76ZwaMGCX8
SSH Tunnels to Interactive Steps
Overview
When a step runs an interactive tool like RStudio or Jupyter, improve exposes it on a Docker port behind the runserver firewall. improveOpenTunnel() creates an SSH tunnel so you can access it from your browser via localhost.
One-time setup
Generate an SSH key pair. This only needs to be done once per machine.
The key is stored in your improve internal directory. The fingerprint is registered automatically with the server when you open a tunnel.
Connect to an interactive step
Create a step with an interactive tool (e.g. RStudio), then open the tunnel:
# Create a step with RStudio
stepEnv <- createStepTemplateEnv(treeIdent = myTree)
stepEnv$setStepRunserverLabel("runserver")
stepEnv$setStepToolLabel("R 3_Std")
stepEnv$setStepToolInstance("imRstudio 1.3")
stepEnv$setStepDescription("Interactive Analysis")
step <- stepEnv$realise(run = FALSE)
# Open tunnel — starts the step, opens your browser
tunnel <- improveOpenTunnel(step, localPort = 8787)This:
- Registers your SSH key with the run
- Starts the step on the runserver
- Waits for it to reach RUNNING status
- Reads the dynamically assigned Docker port
- Opens an SSH tunnel from
localhost:8787to the container - Opens your browser to the RStudio session
Working with the tunnel
# Check if tunnel is still alive
tunnel$isAlive()
# Get the URL
tunnel$url
# "http://A1B2C3D4.localhost:8787/"
# Close when done
improveCloseTunnel(tunnel)The tunnel is automatically closed when your R session ends.
Requirements
-
sshandssh-keygenon your system PATH (included with OpenSSH on all platforms) -
processxR package (optional, improves SSH process management) - The runserver must have an SSH port configured