Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to initialize UNIX system users - is there a LocalNativeAuthenticator? #75

Open
odovad opened this issue May 6, 2019 · 4 comments
Labels
question Further information is requested

Comments

@odovad
Copy link

odovad commented May 6, 2019

Hi,

Maybe there are some elements I don't understand...

  1. I had to signup with my already existing admin user to be able to login.

  2. When I create a user with the admin panel, I have an error 500 because the nativeauthenticator.NativeAuthenticator does not allow to pass an option like : c.LocalAuthenticator.create_system_users = True
    /home/{new_user} is not created.

Am I missing someting ?
Thanks in advance :)

@leportella
Copy link
Collaborator

Hi @odovad sorry for the delay. I don't think we have create_system_users as an option on NativeAuth. Users must necessarily signup otherwise the system will not know them

@leportella leportella added the question Further information is requested label Aug 8, 2019
@chicocvenancio
Copy link

Initializing users is not behind any authentication, to create them I used a small script, maybe it is useful to someone else.

import requests
creds = [('user', 'good_password123')]

for cred in creds:
    requests.post('https://jupyterhub.mydomain.com/hub/signup', data={'username':cred[0], 'pw': cred[1]})

@user919lx
Copy link

user919lx commented Sep 9, 2019

I have same issue.Since nativeauthenticator doesn't inherit LocalAuthenticator,we can't set c.LocalAuthenticator.create_system_users = True

I solve it by setting config c.Spawner.pre_spawn_hook,so that everytime before jupyterhub spawns server,it will execute some python code.

for example

from subprocess import check_call

def create_system_user(spawner):
    username = spawner.user.name
    check_call(['bash', '/srv/jupyterhub/adduser.sh', username])

c.Spawner.pre_spawn_hook = create_system_user

adduser.sh code

adduser -q --gecos '""' --home /home/$1 --disabled-password  $1 || "True"

It will create system user if user not exists, otherwise return do nothing

@consideRatio consideRatio changed the title How to initialize ? How to initialize UNIX system users - is there a LocalNativeAuthenticator? Oct 29, 2021
@Caiofcas
Copy link

Running jupyterhub inside docker with c.JupyterHub.spawner_class = 'jupyterhub.spawner.LocalProcessSpawner', what worked for me was (based on the answer above by @user919lx ):

def create_system_user(spawner):
    """Hook to create system user before spawning notebook. Required since NativeAuthenticator does not create users."""
    username = spawner.user.name
    check_call(['useradd', username, "-m"])


c.Spawner.pre_spawn_hook = create_system_user

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

5 participants