Jupyter Notebook: Force cookie expiration and reset token - python

How can I remove access to a Jupyter Notebook server to previous users? I did a quick setup of a Jupyter Notebook server and provided access to a few users. Now that it's no longer needed, how can I force the authentication cookies to expire and reset the authentication token?
I think I should have used JupyterHub, but I didn't know about it then.

I had to delete the runtime files as well as the change the password.
You can get the path to the runtime files with jupyter --paths
Also see https://docs.jupyter.org/en/latest/use/jupyter-directories.html#runtime-files

Stop the server, run jupyter notebook password and set/change your password.

Related

In PyCharm the Jupyter Server tool window to preview server's configuration details gives nothing

I use PyCharm Professional and I am trying to launch Jupyter Notebook inside PyCharm IDE.
I followed the official instructions Manage Jupyter notebook servers.
I installed Jupyter and configured python 3.8 interpreter using virtual environment. I do not use conda.
When I run the first cell "Starting Jupyter Server" message is shown on the Jupyter top bar. I now that I have to insert Jupyter password or activation token for the server.
When I run command inside PyCharm terminal it gives me only the address:
jupyter notebook list
Currently running servers:
http://localhost:8888/
As officials say here must be shown authentication token for the server, but it is missing.
So, where I can find this token to enter the Jupyter Server and see other server's configuration details?
I have just found the answer by myself.
I have Jupyter configuration already in the folder ~/.jupyter/jupyter_notebook_config.py where the password and other parameters are set. So, to enter the server all I had to do is to enter the password which I set on my own in the above configuration file in the past.

How to maintain .ipynb running in the background with VSCode?

I have installed jupyter-related plugins in VS Code. While I close the VS Code, the GPU memory is cleared. I can't use jupyter like the traditional method in the browser.
I changed the jupyter to remote with localhost: port in VS Code, the Jupyter: Server Remote displayed in the button of VS Code GUI.
Steps:
The remote jupyter notebook is running in the tmux with & bash option.
Add port forward in VSCode.(maybe unnecessary)
Ctrl + Shift + P and search "Jupyter: Specify Jupyter Server for connections".
Add URL with the token.
Run a ipynb file and nvidia-smi to see the usage of GPU.
Close the VSCode, the GPU memory is clear.
When you use remote mode, the code runs in the server instead of the local computer.
Please operate again according to the documentation.
Select the Jupyter Server: local button in the global Status bar or run the Jupyter: Specify local or remote Jupyter server for connections command from the Command Palette (Ctrl+Shift+P).
When prompted to Pick how to connect to Jupyter, select Existing: Specify the URI of an existing server.
When prompted to Enter the URI of a Jupyter server, provide the server's URI (hostname) with the authentication token included with a URL parameter. (If you start the server in the VS Code terminal with an authentication token enabled, the URL with the token typically appears in the terminal output from where you can copy it.) Alternatively, you can specify a username and password after providing the URI

How to use JupyterLab in Visual Studio Code

is there a way to use JupyterLab in VS Code? I know that VS Code provides the Jupyter Notebook extension. However, I need to connect to another server remotely......
Any guidance will be appreciated!
You can offload intensive computation in a Jupyter Notebook to other computers by connecting to a remote Jupyter server. Once connected, code cells run on the remote server rather than the local computer.
To connect to a remote Jupyter server:
Select the Jupyter Server: local button in the global Status bar or
run the Jupyter: Specify local or remote Jupyter server for
connections command from the Command Palette (Ctrl+Shift+P).
When prompted to Pick how to connect to Jupyter, select Existing:
Specify the URI of an existing server.
When prompted to Enter the URI of a Jupyter server, provide the
server's URI (hostname) with the authentication token included with
a URL parameter. (If you start the server in the VS Code terminal
with an authentication token enabled, the URL with the token
typically appears in the terminal output from where you can copy
it.) Alternatively, you can specify a username and password after
providing the URI.
For guidance about securing a notebook server, refer to the Jupyter documentation.

How do I set up Jupyter notebook on a linux server (RHEL7) for my team to use via Chrome browser?

I am leading a team of analysts and want to introduce them to Jupyter Notebook as a window into Python programming.
We have Anaconda downloaded and installed on our Linux server. I've asked our IT to help set it up to run on Google Chrome and they have been able to only provide the following steps:
source /R_Data/anaconda3/etc/profile.d/conda.sh
this kicks off Anaconda on the server, must run in PUTTY. We stored the installation in the same location as RStudio hence the R_Data in the filepath.
/R_Data/anaconda3/bin/jupyter-notebook --ip 0.0.0.0 --port 8889
This sets up the port 8889 with a token generated each time from scratch. We then need to grab the token id and paste into Chrome with the full URL per step 3
http://localhost:8889/?token=ea97e502a7f45d....
When I paste this in Chrome it loads Jupyter.
While this gets the job done it seems less than ideal for an entire team of analysts to have to do this each time. We also have RStudio installed on the same server but that simply opens from Chrome using a URL since I assume it is always running in the background. Jupyter and Anaconda seem to only run once they are kicked off first in PUTTY and I would like a way to bypass those steps.
I am familiar with the Jupyter config file however my limited understanding as a non-developer tells me it applies only to each user and cannot be applied to all users simultaneously (i.e. as a root user on the server or something to that effect).
I am hoping someone here might point me in the right direction. I should also point out that as a Redhat user I can't follow instructions based in Ubuntu since that syntax seems different.
Many thanks for the help.
Yoni
A convenient way is to run jupyter notebook --no-browser --port=12345 on your server while connecting through the ssh tunel as ssh -N -f -L 12345:localhost:12345 myserveralias. Now jupyter is on your 12345 localhost. Things like AutoSSH or Keep Alive will help with an erratic network, however, take security into account.

How to link to Jupyter notebook from a local HTML page

I am learning Jupyter Notebooks at the moment. Is it possible to link a Jupyter Notebook to an HTML page.
For example, say I have an HTML page which is on my computer. Can I use this to link to a Jupyter Notebook, so when the link is clicked it loads the notebook in a viewer to be run?
Thanks,
BJR
I am not using Jupyter notebook this way (actually I use Jupyter Lab). However, if I understood correctly you want to click on link on HTML page in your local machine and run notebook.
If trying access Jupyter notebook via HTML link in your machine while notebook (server) is not running or you are using non-default browser while notebook is running you will reach page with following information which should be sufficient to plan you next steps:
Token authentication is enabled
If no password has been configured,
you need to open the notebook server with its login token in the URL,
or paste it above. This requirement will be lifted if you enable a
password.
The command:
jupyter notebook list
will show you the URLs of running servers with
their tokens, which you can copy and paste into your browser. For
example:
Currently running servers:
http://localhost:8888/?token=*****... :: /Users/you/notebooks
or you can paste just the token value into the password field on this
page.
See the documentation on how to enable a password in place of token
authentication, if you would like to avoid dealing with random tokens.
Cookies are required for authenticated access to notebooks.
Setup a Password You can also setup a password by entering your token
and a new password on the fields below:
Token
New password
Basically it means that: link to Jupyter notebook will work if you have started server with token autorhization and use default browser. You can set password which means that you can use whatever browser in your machine but must log in (you can save login credentials in your browser of course). In any case notebook (server) must have been started and running before using link.
Link will not run your notebook, it just opens notebook page.

Categories

Resources