28

I've used the setup instructions found here: http://jupyter-notebook.readthedocs.io/en/latest/public_server.html

After starting the server, every time I attempt to login it refuses to take my password. I've verified the hash, used the passwd() function from notebook.auth as the sha1 generator.

Lastly, the password value is set in the jupyter_notebook_config.py file.

Is there something I'm missing here. I can see the POST request and everything, but it will not take the password that I've set.

A few google searches have turned up nothing thus far. I'm using the Anaconda v1.5.1 distro on Linux Mint 17. Thanks

1
  • I met this error, Now I found the reason. I set the pwd using jupyter notebook password, and set the pwd then I execute jupyter-lab both are different. after I set the pwd using jupyter-lab password, its working now well.
    – user225549
    Commented Jun 14, 2021 at 0:07

12 Answers 12

27

I was able to set a password and use that to login. I did not have luck running jupyter notebook password, but jupyter server password did work.

5
  • 1
    Finally! You are awesome! Commented Jan 27, 2021 at 21:36
  • 1
    The clue that led me to this was the following at startup: ` 'password' has moved from NotebookApp to ServerApp. This config will be passed to ServerApp. Be sure to update your config before our next release.` Commented Jan 29, 2021 at 17:30
  • I've been looking for this answer since last week. Thanks a lot! Commented Feb 2, 2021 at 18:37
  • This saved me a couple of hours. Thanks
    – James Wong
    Commented Feb 16, 2021 at 15:11
  • perfect, thank you
    – Sophie
    Commented Jan 4, 2022 at 19:01
9
  1. Generate config file: jupyter notebook --generate-config

  2. Generate password: jupyter notebook password and (input password 2 times). This should generate a jupyter_notebook_config.json file or change it in the current configuration path.

  3. Search path to jupyter_notebook_config.py file. (Usually in path/.jupyter):

    • jupyter --path
  4. Uncomment and add json configuration file to the config file: jupyter_notebook_config.py

    • c.JupyterApp.config_file_name = 'jupyter_notebook_config.json'
2
  • I think this would help, but the second step of generating password gets me a "No such file or directory" <pwd>/password.
    – ashley
    Commented Mar 5, 2019 at 13:19
  • Hi there! Interesting . What version of notebook are you using? password should be a reserved keyword. Your command is trying to serve a single file named password. Commented Apr 1, 2019 at 14:03
9

You can make a configuration to all options in a file, generated by command jupyter notebook --generate-config.

This will produce a file with all configurations explained and commented out in the file ~/.jupyter/jupyter_notebook_config.py.

  • vi jupyter_notebook_config.py to access and edit

In this file you can un-comment:

## Allow password to be changed at login for the notebook server.
#
#  While loggin in with a token, the notebook server UI will give the opportunity
#  to the user to enter a new password at the same time that will replace the
#  token login mechanism.
#
#  This can be set to false to prevent changing password from the UI/API.
c.NotebookApp.allow_password_change = True

and set some starting or no token with

## Token used for authenticating first-time connections to the server.
#
#  When no password is enabled, the default is to generate a new, random token.
#
#  Setting to an empty string disables authentication altogether, which is NOT
#  RECOMMENDED.
c.NotebookApp.token = ''

For a simple single password: In the jupyter_notebook_config.py:

# my notebooks settings
c = get_config()
c.NotebookApp.ip = '*'
c.NotebookApp.open_browser = False
c.NotebookApp.port = 5000

# setting up the password
from IPython.lib import passwd
password = passwd("your_secret_password")
c.NotebookApp.password = password

See also here in the docs:https:

3

Not the answer you are looking for, but useful for excluding other issues.

$ jupyter notebook --port 5000 --no-browser --ip='*' --NotebookApp.token='' --NotebookApp.password=''

this will give the following warnings. understand the risk.

[W 09:04:50.273 NotebookApp] WARNING: The notebook server is listening on all IP addresses and not using encryption. This is not recommended.

[W 09:04:50.274 NotebookApp] WARNING: The notebook server is listening on all IP addresses and not using authentication. This is highly insecure and not recommended.

2

Try Clear the Cookies and Caches of your browser!
Close the Jupyter page, find the corresponding cookie for "localhost:****" and clean them.

I have had the same problem with Jupyter password login:
If I enter the correct password, the login page just refreshes and stays the same (blank); but if I enter a wrong password, it will prompt that the password is wrong.

Later I found clearing the old cookies solved the problem.

1

I was having the same issue. Try to run notebook server in the same directory with jupyter_notebook_config.py. This fixed my problem.

1

If you are using single user version Jupyter, you don't need to enable login;

If you are using multiple user version which is JupyterHub (one of the simplest), I would suggest you should use LDAP kind of authentication module, you can refer to this post on how to use LDAP authentication: ldapauthenticator

Lastly, you might also need to enable Kerberos authorization, you can refer to this post: Kerberos

1

I know this is an older thread, but posting what worked for me recently while setting up a notebook server on DigitalOcean.

  1. Run the jupyter notebook --generate-config which will generate the jupyter_notebook_config.py file in ~/.jupyter
  2. In the iPython shell - ipython, run the below piece of code which will generate the password hash and salt
from notebook.auth import passwd
passwd('your password goes here')

Next, in jupyter_notebook_config.py, add the hash value to c.NotebookApp.password = ''. Also, change c.NotebookApp.password_required to True.

When accessing the notebook remotely - <server_ip>:8888, you will now be able to login with your password.

1

I launch jupyterlab by this way, It's works for me.

from jupyterlab.labapp import main
from sys import argv
from jupyter_server.auth import passwd
passwd('your password goes here')

main(argv=['--notebook-dir=D:/', '--PasswordIdentityProvider.hashed_password=' + passwd('123456'),
           '--PasswordIdentityProvider.password_required=True'])
0

I have commented the password line from the jupyter_notebook_config.py

{
  "NotebookApp": {
    "nbserver_extensions": {
      "jupyter_nbextensions_configurator": true
    },
    /* "password": "sha1:11a35c353b76:23365664049ac6918bc149b6044b990d7d23b080" */
  }
}
0

Although this question is very old, I'll still share my solution to this problem for the next person facing the same issue. It seems that jupyter notebook switch port from 8888 to 8889 while using password. Once I navigated to http://localhost:8889 my password was accepted.

0

Try adding following lines to jupyter_notebook_config.py.

from notebook.auth import passwd   # OR, from IPython.lib import passwd
passwd(algorithm='sha1')

(ref: https://github.com/jupyter/docker-stacks/issues/1056)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.