I have installed jupyterhub and run it as a daemon in a VM (ubuntu) with a systemuser account. Login with the same systemuser account have no issue. But it fail when I try to log in with other user account (user1, user2 or user3).
I have set the jupyterhub_config.py as follow:
c.Authenticator.whitelist = {'systemuser', 'user1', 'user2', 'user3'}
c.Authenticator.allowed_users = {'systemuser', 'user1', 'user2', 'user3'}
c.PAMAuthenticator.allowed_users = {'systemuser', 'user1', 'user2', 'user3'}
c.LocalAuthenticator.create_system_users = True
c.JupyterHub.authenticator_class = 'jupyterhub.auth.PAMAuthenticator'
c.JupyterHub.spawner_class = 'jupyterhub.spawner.LocalProcessSpawner'
and config the jupyterhub_service as folllow:
/etc/systemd/system/jupyterhub.service
[Unit]
Description=JupyterHub
After=network.target
[Service]
User=systemuser
ExecStart=/usr/local/bin/jupyterhub --config /home/systemuser/jupyterhub_config.py
WorkingDirectory=/home/systemuser
Restart=always
Environment=PATH=/usr/local/bin:/usr/bin:/bin
Environment=PYTHONPATH=/usr/local/lib/python3.x/site-packages
[Install]
WantedBy=multi-user.target
Feb 24 10:04:56 labsandbox jupyterhub[965]: [E 2025-02-24 10:04:56.459 JupyterHub log:192] 500 POST /hub/api/users/user2/servers/?_xsrf=[secret] (ctc@::ffff:10.12.133.52) 105.18ms
Feb 24 10:06:28 labsandbox jupyterhub[965]: [I 2025-02-24 10:06:28.998 JupyterHub provider:661] Creating oauth client jupyterhub-user-user2
Feb 24 10:06:29 labsandbox jupyterhub[965]: [I 2025-02-24 10:06:29.016 JupyterHub spawner:1837] Spawning jupyterhub-singleuser
Feb 24 10:06:29 labsandbox jupyterhub[965]: [E 2025-02-24 10:06:29.025 JupyterHub user:1007] Unhandled error starting user2’s server: Exception occurred in preexec_fn.
Feb 24 10:06:29 labsandbox jupyterhub[965]: Traceback (most recent call last):
Feb 24 10:06:29 labsandbox jupyterhub[965]: File “/usr/local/lib/python3.8/dist-packages/jupyterhub/user.py”, line 920, in spawn
Feb 24 10:06:29 labsandbox jupyterhub[965]: await asyncio.wait_for(f, timeout=spawner.start_timeout)
Feb 24 10:06:29 labsandbox jupyterhub[965]: File “/usr/lib/python3.8/asyncio/tasks.py”, line 494, in wait_for
Feb 24 10:06:29 labsandbox jupyterhub[965]: return fut.result()
Feb 24 10:06:29 labsandbox jupyterhub[965]: File “/usr/local/lib/python3.8/dist-packages/jupyterhub/spawner.py”, line 1847, in start
Feb 24 10:06:29 labsandbox jupyterhub[965]: self.proc = Popen(cmd, **popen_kwargs)
Feb 24 10:06:29 labsandbox jupyterhub[965]: File “/usr/lib/python3.8/subprocess.py”, line 858, in init
Feb 24 10:06:29 labsandbox jupyterhub[965]: self._execute_child(args, executable, preexec_fn, close_fds,
Feb 24 10:06:29 labsandbox jupyterhub[965]: File “/usr/lib/python3.8/subprocess.py”, line 1705, in _execute_child
Feb 24 10:06:29 labsandbox jupyterhub[965]: raise child_exception_type(err_msg)
Feb 24 10:06:29 labsandbox jupyterhub[965]: subprocess.SubprocessError: Exception occurred in preexec_fn.
Feb 24 10:06:29 labsandbox jupyterhub[965]:
Feb 24 10:06:29 labsandbox jupyterhub[965]: [E 2025-02-24 10:06:29.051 JupyterHub web:1875] Uncaught exception POST /hub/api/users/ai_user2/servers/?_xsrf=MnwxOjB8MTA6MTc0MDM4OTA5Nnw1Ol94c3JmfDg4Oll6ZzVNREZtTVdRMFpqUmlORE5rTURreU1EUm1PVFZoTXpBeVlqa3dOVGc2TURoaU5qWmhORGM0WTJJeE5EQTNaamcyWVRWbU1XSXlObUV6T0RrNE1ERT18MGFlYTA1YjA2M2JlZWVkZDhhOTI2MmYzYmRkYTI3MjU5MTNjYWRkYWY0MzcyZTViMzQ4YWYzNWU4YzA5MDgwNw (::ffff:10.12.133.52)
Feb 24 10:06:29 labsandbox jupyterhub[965]: HTTPServerRequest(protocol=‘http’, host=‘10.12.196.103:8000’, method=‘POST’, uri=‘/hub/api/users/ai_user2/servers/?_xsrf=MnwxOjB8MTA6MTc0MDM4OTA5Nnw1Ol94c3JmfDg4Oll6ZzVNREZtTVdRMFpqUmlORE5rTURreU1EUm1PVFZoTXpBeVlqa3dOVGc2TURoaU5qWmhORGM0WTJJeE5EQTNaamcyWVRWbU1XSXlObUV6T0RrNE1ERT18MGFlYTA1YjA2M2JlZWVkZDhhOTI2MmYzYmRkYTI3MjU5MTNjYWRkYWY0MzcyZTViMzQ4YWYzNWU4YzA5MDgwNw’, version=‘HTTP/1.1’, remote_ip=‘::ffff:10.12.133.52’)
Feb 24 10:06:29 labsandbox jupyterhub[965]: Traceback (most recent call last):
Feb 24 10:06:29 labsandbox jupyterhub[965]: File “/usr/local/lib/python3.8/dist-packages/tornado/web.py”, line 1790, in _execute
Feb 24 10:06:29 labsandbox jupyterhub[965]: result = await result
Feb 24 10:06:29 labsandbox jupyterhub[965]: File “/usr/local/lib/python3.8/dist-packages/jupyterhub/apihandlers/users.py”, line 666, in post
Feb 24 10:06:29 labsandbox jupyterhub[965]: await self.spawn_single_user(user, server_name, options=options)
Feb 24 10:06:29 labsandbox jupyterhub[965]: File “/usr/local/lib/python3.8/dist-packages/jupyterhub/handlers/base.py”, line 1215, in spawn_single_user
Feb 24 10:06:29 labsandbox jupyterhub[965]: await gen.with_timeout(
Feb 24 10:06:29 labsandbox jupyterhub[965]: File “/usr/local/lib/python3.8/dist-packages/jupyterhub/handlers/base.py”, line 1122, in finish_user_spawn
Feb 24 10:06:29 labsandbox jupyterhub[965]: await spawn_future
Feb 24 10:06:29 labsandbox jupyterhub[965]: File “/usr/local/lib/python3.8/dist-packages/jupyterhub/user.py”, line 1021, in spawn
Feb 24 10:06:29 labsandbox jupyterhub[965]: raise e
Feb 24 10:06:29 labsandbox jupyterhub[965]: File “/usr/local/lib/python3.8/dist-packages/jupyterhub/user.py”, line 920, in spawn
Feb 24 10:06:29 labsandbox jupyterhub[965]: await asyncio.wait_for(f, timeout=spawner.start_timeout)
Feb 24 10:06:29 labsandbox jupyterhub[965]: File “/usr/lib/python3.8/asyncio/tasks.py”, line 494, in wait_for
Feb 24 10:06:29 labsandbox jupyterhub[965]: return fut.result()
Feb 24 10:06:29 labsandbox jupyterhub[965]: File “/usr/local/lib/python3.8/dist-packages/jupyterhub/spawner.py”, line 1847, in start
Feb 24 10:06:29 labsandbox jupyterhub[965]: self.proc = Popen(cmd, **popen_kwargs)
Feb 24 10:06:29 labsandbox jupyterhub[965]: File “/usr/lib/python3.8/subprocess.py”, line 858, in init
Feb 24 10:06:29 labsandbox jupyterhub[965]: self._execute_child(args, executable, preexec_fn, close_fds,
Feb 24 10:06:29 labsandbox jupyterhub[965]: File “/usr/lib/python3.8/subprocess.py”, line 1705, in _execute_child
Feb 24 10:06:29 labsandbox jupyterhub[965]: raise child_exception_type(err_msg)
Feb 24 10:06:29 labsandbox jupyterhub[965]: subprocess.SubprocessError: Exception occurred in preexec_fn.
Feb 24 10:06:29 labsandbox jupyterhub[965]:
Feb 24 10:06:29 labsandbox jupyterhub[965]: [E 2025-02-24 10:06:29.052 JupyterHub log:184] {
Feb 24 10:06:29 labsandbox jupyterhub[965]: “X-Forwarded-Host”: “10.12.196.103:8000”,
Feb 24 10:06:29 labsandbox jupyterhub[965]: “X-Forwarded-Proto”: “http”,
Feb 24 10:06:29 labsandbox jupyterhub[965]: “X-Forwarded-Port”: “8000”,
Feb 24 10:06:29 labsandbox jupyterhub[965]: “X-Forwarded-For”: “::ffff:10.12.133.52”,
Feb 24 10:06:29 labsandbox jupyterhub[965]: “Cookie”: “jupyterhub-hub-login=[secret]; _xsrf=[secret]; jupyterhub-session-id=[secret]”,
Feb 24 10:06:29 labsandbox jupyterhub[965]: “Accept-Language”: “en-US,en;q=0.9”,
Feb 24 10:06:29 labsandbox jupyterhub[965]: “Accept-Encoding”: “gzip, deflate”,
Feb 24 10:06:29 labsandbox jupyterhub[965]: “Referer”: “http://10.12.196.103:8000/hub/admin”,
Feb 24 10:06:29 labsandbox jupyterhub[965]: “Origin”: “http://10.12.196.103:8000”,
Feb 24 10:06:29 labsandbox jupyterhub[965]: “Content-Type”: “application/json”,
Feb 24 10:06:29 labsandbox jupyterhub[965]: “Accept”: “application/jupyterhub-pagination+json”,
Feb 24 10:06:29 labsandbox jupyterhub[965]: “User-Agent”: “Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36”,
Feb 24 10:06:29 labsandbox jupyterhub[965]: “Content-Length”: “0”,
Feb 24 10:06:29 labsandbox jupyterhub[965]: “Connection”: “keep-alive”,
Feb 24 10:06:29 labsandbox jupyterhub[965]: “Host”: “10.12.196.103:8000”
Feb 24 10:06:29 labsandbox jupyterhub[965]: }