— This feature supports RStudio
, which is part of the Professional and Enterprise Editions of LabKey Server. Learn more
or contact LabKey
This topic covers setting up and configuring RStudio Workbench (previously RStudio Server Pro) for use with LabKey Server. RStudio Workbench runs as a separate server, and unlike RStudio, can shared by many simultaneous users. On the machine where RStudio Workbench is running, the R language must also be installed and the Rlabkey package loaded.
Typically the steps on this page would be completed by a system administrator, though not necessarily the LabKey site administrator. Once the steps described here have been completed on the RStudio Workbench machine, the LabKey Server can be configured to connect to RStudio Workbench as described in Connect to RStudio Pro/Workbench
. Key pieces of information from this setup must be communicated to the LabKey admin.
- If you're setting this server up in AWS, you will want to set it up in a public subnet in the same VPC as the destination server. It will need a public-facing IP/EIP.
- For AWS, the following ports need to be open, inbound and outbound, for this install to work in AWS. Set your security group/NACLs accordingly:
- 1080 (license server)
- 8787 (initial connection)
- 1024-65535 (license server)
Linux and Ubuntu Setup
If your RStudio Workbench host machine is running an OS other than Linux/Ubuntu, you can configure a VM to provide a local Linux environment in which you can run Ubuntu. If your host is Linux running Ubuntu, you can skip this section
.Steps to set up Ubuntu on a non Linux host OS:
- VM: Use Virtual Box to set up a local Linux environment.
- Linux: Install Linux OS in that VM
- Ubuntu: Download and install latest Ubuntu; version 12.04 or higher is required) in the VM.
- Configure VM network so that VM has an IP and can be accessed by the host. For example: VM > Settings > Network > Attached To > Bridged Adapter
R Language Setup (for Ubuntu)
Use the following steps to set up R for Ubuntu. For other versions of linux, follow the instructions here instead: http://docs.rstudio.com/ide/server-pro/index.html#installation
1. Configure CRAN Repository
. Add the following entry to your /etc/apt/sources.list file, substituting the correct name for your Ubuntu version where this example uses 'xenial' (the name for 16.x):
If you are not sure what name your Ubuntu version is using, you can find it in other lines of the sources.list file.
Linux Tip: to open a system file in linux for editing, use:
$ gksudo gedit /etc/apt/sources.list
To add edit permission to a file:
$ chmod 777 /etc/apt/sources.list
2. Install latest version of R
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys E084DAB9
sudo apt-get install r-base
3. Install Rlabkey and other R packages
- If a library is to be used by RStudio as a system library (instead of a user library), run with 'lib' set as shown here:
$ sudo R
> install.packages("Rlabkey", lib="/usr/local/lib/R/site-library")
- If a library has dependencies:
> install.packages("package", lib="/usr/local/lib/R/site-library", dependencies=TRUE)
Trouble installing Rlabkey on Linux? Try installing dependencies explicitly:
> sudo apt-get install libssl-dev
> sudo apt-get install libcurl4-openssl-dev
Install RStudio Workbench
1. Download and install RStudio Workbench as instructed when you purchased it. For demo purposes, you can use the free 45 day trial license and download from the RStudio download page
2. Activation: (Optional)
$ sudo rstudio-server license-manager activate ACTIVATION_KEY
This function requires high ports to be world-accessible. If this command fails, check your security groups or NACLs; if this fails with a timeout, check them first.
3. Verify RStudio Workbench Installation
- Create a ubuntu user:
useradd -m -s /bin/bash username
- Get Ubuntu’s ip address by:
- In VM browser, go to localhost:8787, or ip:8787
- You should be on the RStudio Workbench login page, login using your ubuntu login
4. Verify accessing RStudio Workbench from the host machine
In the host machine’s browser, go to your VMs IP address. Depending on how you configured your license, it might look something like "http://ubuntuVmIPAddress:8787". You should see the RStudio login page and being able to log in.
Troubleshoot: did you configure VM to use Bridged Adapter?
5. Create a Route 53 DNS name for the server. You will need this for the next steps.
Configure RStudio Workbench Proxy
The RStudio Workbench administrator must enable proxy authentication on RStudio Workbench to use LabKey Server as the authenticator. The following steps will configure the proxy. See below
for the details that must then be used when configuring LabKey Server to use this proxy.
1. You will need to create an SSL cert:
- openssl req -newkey rsa:2048 -nodes -keyout key.pem -x509 -days 3650 -out certificate.pem
- Copy the key.pem file to /etc/ssl/private/
- Copy the certificate.pem file to /etc/ssl/certs
- Edit /etc/rstudio/rstudio-server.conf and add the following lines:
- rstudio-server stop
- rstudio-server start
2. Use LabKey Server as proxy authenticator for RStudio Workbench by adding the following lines to /etc/rstudio/rserver.conf, supplying your own server name:
3. Restart RStudio Workbench so that these configuration changes are effective by running
$sudo rstudio-server restart
4. Follow the instructions here for downloading the cert: https://stackoverflow.com/questions/21076179/pkix-path-building-failed-and-unable-to-find-valid-certification-path-to-requ
5. Upload the saved cert to the destination server
6. On the destination Labkey Server (nb: this will require restarting the LabKey instance):
- Log in.
- sudo su -
- keytool -import -keystore /usr/lib/jvm/jdk1.8.0_151/jre/lib/security/cacerts -alias <RStudio hostname, but not the FQDN> -file <whatever you named the saved cert>.crt (nb: you will be prompted for a password; ask Ops for it)
- service tomcat_lk restart
7. Verify Proxy redirect
Go to the RStudio Workbench url to verify the page redirects to LabKey. Note: Once SSL is enabled, 8787 no longer works.
8. Customize Security Token
Define a custom security token for the proxy. This will be used to indicate the authenticated user when LabKey Server connects to RStudio Workbench. For example, to define the default 'X-RStudio-Username' token:
$sudo sh -c "echo 'X-RStudio-Username' > /etc/rstudio/secure-proxy-user-header"
$sudo chmod 0600 /etc/rstudio/secure-proxy-user-header
Information to Pass to LabKey Administrator
To configure LabKey Server to connect to RStudio Workbench, the admin will need:
(Optional) Add RStudio Workbench Users
LabKey users are mapped to RStudio users by removing the configured "email suffix"
. For example: LabKey user XYZ@email.com is mapped to RStudio user name XYZ
Adding RStudio Workbench Users
RStudio Workbench uses Linux’s PAM authentication so any users accounts configured for Linux will be able to access RStudio Workbench. Users can be added for RStudio by the adduser
The following commands add a user “rstudio1” to Linux (and hence RStudio Workbench).
$ sudo useradd -m -d /home/rstudio1 rstudio1
$ sudo passwd rstudio1
IMPORTANT: Each user must have a home directory associated with them otherwise they won’t be able to access RStudio since RStudio works on this home directory.
Verify Access Verify access to RStudio Workbench for the newly added user:
Go to ip:8787, enter user and pw for the newly created user, verify the user can be logged in to RStudio successfully.Troubleshoot for permission denied error on login:
- Run pamtester to rule out PAM issue
$ sudo pamtester --verbose rstudio <username> authenticate acct_mgmt
- Try adding the following line to /etc/sssd/sssd.conf (you may need to install sssd):
ad_gpo_map_service = +rstudio
- Did you create the user with a specified home directory?
- Make sure you didn’t configure the RStudio Workbench server to limit user access by user group (the default is to allow all; check /etc/rstudio/rserver.conf), or if so make sure your user is added to an allowed group.
After making any change to the RStudio Workbench config, always run the following for the change to take effect:
$sudo rstudio-server restart