I\'m trying to use the bash kernel in iPython/Jupyter notebook, but I need sudo access within the notebook itself.
I\'ve tried $ sudo jupyter notebook
to ru
Just login as root, then do the following command to start the notebook :
jupyter notebook --allow-root
root@user# jupyter notebook --generate-config
root/.jupyter/jupyter_notebook_config.py root@user# cd .jupyter/ root@user:/.jupyter/# gedit jupyter_notebook_config.py Add line in jupyter_notebook_config.py
c.NotebookApp.allow_root=True
Add c.NotebookApp.allow_root=True
from the root configuration files. That you don't need ask to allow-root
every time then you start the notebook.
Edit:
Before edit the configuration file you need to run jupyter notebook --generate-config
as root to make the file.
When I need to execute command as root in my notebook, I use the -A
flag, that allows to access an helper program used to read the user's password when no terminal is available.
You need to modify the sudo.conf
file before to declare the helper program. On a Debian Buster, I personnaly added:
Path askpass: /usr/libexec/seahorse/ssh-askpass
See the main page of sudo.conf
for more information.
You should try running the command sudo jupyter notebook --allow-root , I'm not sure why but this works. On the server it'll ask you for a password, if you have set up a password for it just type it in the box that will be shown, otherwise, type jupyter notebook password to set up a new password
In case anyone is still looking for an answer, this is what worked for me:
sudo ~/.local/bin/jupyter-notebook --allow-root
Switching user using su didn't work because I didn't have jupyter installed on root. Using just --allow-root by itself also didn't work for me. This allows you to run sudo with jupyter notebook without running into the issue of "notebook" not being a valid command. Because I am using a linux terminal, jupyter-notebook is installed at ~/.local/bin/jupyter-notebook. See After installing with pip, "jupyter: command not found" for more information about where jupyter may be installed.