— 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 Pro. Once you have completed these steps, configure LabKey as described in Connect to RStudio Pro
- 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)
Non-Linux Host OS
- VM: (Optional, for non linux host OS) Use Virtual Box to set up a local Linux environment.
- Linux: (Optional, for non linux host OS)
- Install Linux OS:
- 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
- Ex: VM > Settings > Network > Attached To > Bridged Adapter
Set Up R (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 Pro
1. Download and install RStudio Pro 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 Pro 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 Pro login page, login using your ubuntu login
4. Verify accessing RStudio pro from the host machine
In the host machine’s browser, go to 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 Pro 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 Pro by adding the following lines to /etc/rstudio/rserver.conf:
auth-proxy-sign-in-url=https://nihs-stage.app.labkey.host/rstudio-startPro.view?method=LAUNCH (change the server name to whatever server you want to point at)
3. 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 Pro url to verify the page redirects to LabKey. Note: Once SSL is enabled, 8787 no longer works.
Custom security token
$sudo sh -c "echo 'X-LabKey-RStudio-Header' > /etc/rstudio/secure-proxy-user-header"
$sudo chmod 0600 /etc/rstudio/secure-proxy-user-header
(Optional) Add RStudio Pro 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 Pro Users
RStudio Pro uses Linux’s PAM authentication so any users accounts configured for Linux will be able to access RStudio Pro. Users can be added for RStudio by the adduser
The following commands add a user “rstudio1” to Linux (and hence RStudio pro).
$ 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 Pro 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 Pro 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 Pro config, always run the following for the change to take effect:
$sudo rstudio-server restart