Rstudio_container

Using SSH tunnel for R Studio

Author

Prof. Peter Kille

Published

June 17, 2025

Rstudio Quick and easy

  • Step 1 - Copy Rstudio_container folder from classdata into you mydata directory
  • Step 2 - Make sure you have bash local environment installed on mobxterm (PC only)
  • Step 3 - Change directory to enter Rstudio_container folder and run sbatch rstudio-server-442.job
  • Step 4 - Print [jobid].err file to screen - note the ssh command and copy and paste that into a ‘local’ blank terminal session.
  • Step 5 - Paste http://localhost:8787 into a browser and copy and paste in username and password listed in the [jobid].err file.
  • Step 6 - Local interface to a server based Rstudio should now appear. You can close browser and relogon as many times as you like. The session will close in 24 hours unless you edit the job file (see advanced instructions). You also do not need to keep your command line session running.
  • Step 7 - When finished please scancel -f [jobid]

Detailed Instructions

Step 1 - Copy Rstudio_container folder from classdata into you mydata directory

Before you run this make sure you have symlinks created to your classdata and mydata from your home folder. to check if you have type cd then ls and you should see classdata and mydata appear in light blue.

cp -R ~/classdata/Rstudio_container ~/mydata/Rstudio_container

Step 2 - Make sure you have bash local environment installed on mobxterm (PC only)

You will need to run a linux command on your PC (macs can do this from any terminal) The easiest way to do this is from MobaXterm by opening a bash session in a blank tab. Often MoaXterm does not install the bash plugin so you need to check and install if needed. In mobaXterm go to settings > configuration > Terminal. Now look at the last configuration panel - Local environment - you want to selecet Bash (32 bit) from the pull down menu. It may ask permission to install a plugin and restart MobaXterm. Once selecetd you can select OK. Now if you click the + tab next to your session window a local bash terminal will appear.

Step 3 - Change directory to enter Rstudio_container folder and run sbatch rstudio-server-442.job

cd ~/mydata/Rstudio_container
sbatch rstudio-server-442.job

*** if you are running a long job or one that needs more processor or RAM you can edit the job script parameters***

Step 4 - Print [jobid].err file to screen - note the ssh command and copy and paste that into a ‘local’ blank terminal session.

This is as easier as it sounds …… use cat to print to screen and you should see somethign like this:

#########################################
# An rstudio-server session is launching.
# To connect to this session you will need
# to create an SSH tunnel from your local
# workstation/desktop/laptop:

   ssh -NL 8787:admiral1:32985 [username]@admiral.bios.cf.ac.uk

   and point your web browser to http://localhost:8787

# log in to RStudio Server using the following credentials:

   user: [username]
   password: [ver complex password]

# When done using RStudio Server, terminate the job by:
#  *  Issue the following command on the iago login node:

      scancel -f [jobid]
#########################################

Step 5 - Paste http://localhost:8787 into a browser and copy and paste in username and password listed in the [jobid].err file.

This is very very straightforward :)

Step 6 - Local interface to a server based Rstudio should now appear.

You can close browser and relogon as many times as you like. The session will close in 24 hours unless you edit the job file (see advanced instructions). You also do not need to keep your command line session running.

Step 7 - When finished please scancel -f [jobid]