How to remove password for Jupyter Notebooks and set token again

25,283

Solution 1

Hmm my config looks different.

Just remove this file and it will default to making a token

$ cat ~/.jupyter/jupyter_notebook_config.json
{
  "NotebookApp": {
    "password": "sha1:d0a89f391169:9ca771c3518f845438693b938b39703ce1104eaf"
  }

Solution 2

Run in shell:

ipython

from IPython.lib import passwd
passwd()

Enter the password twice and copy the 'sha1:12345' code.

After that, edit jupyter config file:

vi ./jupyter/jupyter_notebook_config.py

... and alter the password.

c.NotebookApp.password='sha1:12345'

Paste your 'sha' code and run jupyter notebook.

Solution 3

I had a situation where I wanted token-based authentication (the default if you don't specify a password) but I kept getting a password form in the browser. And jupyter notebook list was showing an empty token.

I made sure I had no password entry in ~/.jupyter/jupyter_notebook_config.py and I deleted the ~/.jupyter/jupyter_notebook_config.json file (created when jupyter notebook password is run) but I was still getting the password form after restarting the service.

What seemed to finally resolve things was putting a blank password entry into jupyter_notebook_config.py and restarting the service. After that, jupyter notebook list starting showing the autogenerated token, and the token was shown in the startup log when the Jupyter URL was output.

Once the autogenerated token starts showing, if you want to specify the token, do as @gschizas describes.

It seems odd that it takes adding a blank password entry to the config to get the token authentication to come back--as if having a password set in the past prevents jupyter from reverting to its "token authentication by default" behavior.

Share:
25,283
Jugal Anchalia
Author by

Jugal Anchalia

Breakout

Updated on July 05, 2022

Comments

  • Jugal Anchalia
    Jugal Anchalia almost 2 years

    I need to do this for Pycharm.

    Here are the steps that I did which I'm not able to undo.

    1. I added a password for authentication using:

      $ jupyter notebook password

    2. I then used the below command to comment all the code in jupyter_notebook_config.py

      $ jupyter notebook --generate-config

    3. Then I removed the hashed password generated in the jupyter_notebook_config.json which now looks like this

      { "NotebookApp": { "password": "" } }

    4. I then did the following changes in jupyter_notebook_config.py file

      c.NotebookApp.password = ''
      c.NotebookApp.token = '< generated>'

    5. Now, There is no token getting generated and there is no password as well when I start the Jupyter notebook.

      Pycharm git:(master) ✗ jupyter notebook
      [I 21:53:35.158 NotebookApp] Serving notebooks from local directory: /Users/...
      [I 21:53:35.158 NotebookApp] 0 active kernels
      [I 21:53:35.158 NotebookApp] The Jupyter Notebook is running at:
      [I 21:53:35.158 NotebookApp] http://localhost:8888/?token=%3Cgenerated%3E

      Copy/paste this URL into your browser when you connect for the first time,
      to login with a token:
      http://localhost:8888/?token=%3Cgenerated%3E

    Now, how do I make it like the way it was or how do I get the token back??

    PS - I even tried jupyter notebook list, but still the same URL is coming. Also, I'm doing this on a mac, so please advise accordingly.