I have setup Jupyterhub in my AWS server, I am able to access server and visit login page. But after adding allowed users and admin_user to config file when i try to login it says Incorrect Username or password.
Is there any solution to fix this?
Note: Server is setup without Docker / kubernetes.
I was able to login but after login i get 500 server error, the server is not starting automatically.
please refer below spawner class
Note: this is public accessible not restricted for system users
class CustomSpawner(LocalProcessSpawner):
def get_env(self):
# Get the environment from the parent class
env = super().get_env()
# Define base notebook directory and user notebook directory
base_notebook_dir = #my notebook directory path
username = self.user.name
user_notebook_dir = os.path.join(base_notebook_dir, username)
# Ensure user's directory exists or create it
if not os.path.exists(user_notebook_dir):
os.makedirs(user_notebook_dir)
# Copy files from the admin's directory to the user's directory
admin_notebook_dir = os.path.join(base_notebook_dir, 'testuser') # Update with admin user name
if os.path.exists(admin_notebook_dir):
for item in os.listdir(admin_notebook_dir):
s = os.path.join(admin_notebook_dir, item)
d = os.path.join(user_notebook_dir, item)
if os.path.isfile(s):
shutil.copy2(s, d)
elif os.path.isdir(s):
shutil.copytree(s, d)
# Set environment variables for each user manually (without relying on system users)
env['HOME'] = user_notebook_dir
env['USER'] = username
env['LOGNAME'] = username
env['PWD'] = user_notebook_dir
return env
def start(self):
# Ensure that the user's directory is set up correctly before starting
self.notebook_dir = os.path.join('/Notebooks', self.user.name)
if not os.path.exists(self.notebook_dir):
os.makedirs(self.notebook_dir)
# Automatically start the server without waiting for explicit action
self.ready = True # Mark the server as ready immediately
self._spawned = True # Indicate that the server is spawned
# Call the parent class start method
return super().start()
Spawner configuration
c.JupyterHub.spawner_class = CustomSpawner
c.Spawner.notebook_dir = ‘/Notebooks’ # Path for user notebooks
c.Spawner.default_url = ‘/lab’ # Launch JupyterLab interface by default
I was able to login but after login i get 500 server error, the server is not starting automatically.
please refer below spawner class
Note: this is public accessible not restricted for system users
class CustomSpawner(LocalProcessSpawner):
def get_env(self):
# Get the environment from the parent class
env = super().get_env()
# Define base notebook directory and user notebook directory
base_notebook_dir = #my notebook directory path
username = self.user.name
user_notebook_dir = os.path.join(base_notebook_dir, username)
# Ensure user's directory exists or create it
if not os.path.exists(user_notebook_dir):
os.makedirs(user_notebook_dir)
# Copy files from the admin's directory to the user's directory
admin_notebook_dir = os.path.join(base_notebook_dir, 'testuser') # Update with admin user name
if os.path.exists(admin_notebook_dir):
for item in os.listdir(admin_notebook_dir):
s = os.path.join(admin_notebook_dir, item)
d = os.path.join(user_notebook_dir, item)
if os.path.isfile(s):
shutil.copy2(s, d)
elif os.path.isdir(s):
shutil.copytree(s, d)
# Set environment variables for each user manually (without relying on system users)
env['HOME'] = user_notebook_dir
env['USER'] = username
env['LOGNAME'] = username
env['PWD'] = user_notebook_dir
return env
def start(self):
# Ensure that the user's directory is set up correctly before starting
self.notebook_dir = os.path.join('/Notebooks', self.user.name)
if not os.path.exists(self.notebook_dir):
os.makedirs(self.notebook_dir)
# Automatically start the server without waiting for explicit action
self.ready = True # Mark the server as ready immediately
self._spawned = True # Indicate that the server is spawned
# Call the parent class start method
return super().start()
Spawner configuration
c.JupyterHub.spawner_class = CustomSpawner
c.Spawner.notebook_dir = ‘/Notebooks’ # Path for user notebooks
c.Spawner.default_url = ‘/lab’ # Launch JupyterLab interface by default