TLJH user management configuration - How to avoid creation of new system users and use existing home directories?

I fail to configure jupyter lab (TLJH) to behave in the following way: Allow only EXISTING system users to log in. Do NOT create any additional users on system level or additional home directories. Use home/<existing_system_user>/notebooks as the notebook directory for a hub user.

After reading multiple pages of documentation I thought this should be possible by using PAM authenticator / LocalAuthentificator and set c.LocalAuthenticator.create_system_users = False.

This is my /opt/tljh/config/jupyterhub_config.d/jupyterhub_config.py (which should be read in after the config.yaml if I understand the TLJH docs right.)

c.JupyterHub.authenticator_class = 'jupyterhub.auth.PAMAuthenticator'
c.LocalAuthenticator.create_system_users = False

This is the /opt/tljh/config/config.yaml (I use custom ports, which works in itself):

users:
  admin:
  - admin
http:
  port: 5432
https:
  port: 5433

This config works in the sense that I can indeed log in with an existing system user / pw, but then a new home directory is created named /home/"username"-jupyter, which I do not want. I suspect that I missed some necessary lines in the configuration file.

Would be glad if someone could provide a full working config.yaml or jupyterhub_config.py for my requirements.

Seems like this behaviour is hard coded in TLJH. Before spawning, an user is created with jupyter-<username> as username and single user server is spawned as that user.

Maybe you can set c.c.SystemdSpawner.dynamic_users = True and symlink your user home directories to /var/lib/<username>. When using dynamic_users, home directory is set to /var/lib/<username>.

1 Like

Thank you @mahendrapaipuri, your suggestion indeed worked.

For me the better solution in the end was to switch from TLJH to jupyterhub pip installation (which defaultly behaves the way I want) and setting the notebook directory with c.Spawner.notebook_dir plus using a custom c.Spawner.pre_spawn_hook to create the directory automatically.

2 Likes