How to automatically mount a CIFS share upon user login in RStudio Server (Open Source)?

Hi everyone,

(To be clear, sorry but AI is used to solve the issue and to write this post)

I am looking for a reliable way to automatically mount a unique Windows CIFS share (//<IP>/directory) into each user's home directory (/home/username@domain.org/directory) when they log into the RStudio Server Open Source web interface.

The mount must use the user's native Active Directory (AD) Windows permissions.

Our Environment:

  • OS: Ubuntu (integrated into an Active Directory domain using SSSD).
  • Application: RStudio Server (Open Source version).
  • Users: AD users (e.g., username@domain.org / short name: username).

What already works perfectly:

  1. SSH Login: Standard AD authentication works seamlessly. The home directory is automatically created upon first login.
  2. Manual CIFS Mount: Running this command as root/sudo works perfectly:
    sudo mount -t cifs //<ip>/directory /home/username@domain.org/directory -o username=username,domain=domain.org,uid=username@domain.org,gid=12345,file_mode=0700,dir_mode=0700

What we tried (and why it failed on the Open Source version):

  1. PAM (pam_mount.so): Works flawlessly for SSH, but fails for RStudio Server. During the session phase, RStudio Server Open Source drops root privileges and switches to the unprivileged user before executing system mounts. Also, RStudio does not seem to pass the clear-text password down the PAM stack in a way pam_mount can reuse.
  2. session-prologue-script (rserver.conf): Fails with an unrecognised option error because this directive is exclusive to RStudio Workbench / Pro.
  3. Global R Profile (Rprofile.site) + Sudoers script: We triggered a Bash mounting script via Rprofile.site using a NOPASSWD sudoers rule. System logs show the script executes successfully as root. However, the mounted folder remains invisible or inaccessible inside the RStudio user session UI. We suspect this is due to how RStudio Open Source isolates the user session namespace before R initializes.

My Question:

Since session-prologue-script is not available in the Open Source edition, what is the best practice to trigger a per-user CIFS mount at the exact moment the web session initializes, so that the mount is correctly propagated into the user's R session namespace?

Should we look into dynamic autofs triggers, an rsession binary wrapper script, or is there an alternative hook within RStudio Server Open Source that we missed?

Thank you for your help!

1 Like