IJulia.jl icon indicating copy to clipboard operation
IJulia.jl copied to clipboard

Show the token when starting a notebook from the REPL

Open vchuravy opened this issue 6 years ago • 8 comments

Would it be possible to show the token of a new Jupyter instance when doing notebook()? When starting through a ssh tunnel a browser can't be automatically started and my current workaround is:

ssh -L 8888:localhost:8888 HOST
> julia
julia> using IJulia
julia> notebook(detached=true)
julia> run(`$(IJulia.notebook_cmd[1]) notebook list`)
# Get the token used by the instance bound to localhost:8888
# and visit localhost:8888 in your browser and past the token their

vchuravy avatar Sep 13 '17 17:09 vchuravy

notebook could also start the notebook with token authentication disabled... I don't really understand what threat token authentication is protecting against, since the server is not accessible outside the local machine.

(If you have malicious code running on your local machine, it seems like you have much bigger concerns than having the code try to manipulate your Jupyter notebooks. And the code can do that anyway if it has access to the filesystem.)

What am I missing?

stevengj avatar Sep 13 '17 17:09 stevengj

Yes that would be lovely, but not easy see https://github.com/jupyter/notebook/issues/2254 You apparently need to either set a password or set a configuration option to set the token to be empty.

vchuravy avatar Sep 13 '17 18:09 vchuravy

Considering the way Jupyter is used in IJulia/Julia, this seems like a reasonable suggestion: "Would it be possible to show the token of a new Jupyter instance when doing notebook()?"

You can also consider setting up a password, along the lines of: https://discourse.julialang.org/t/ijulia-password-token-requirement/4974 (Careful, that "howto" is not completely accurate!)

@stevengj : You might be sharing the same machine with multiple users in a cluster environment. You would not want other users to be able to execute code with your user's privileges. Tokens prevent that.

joachimneu avatar Sep 28 '18 00:09 joachimneu

notebook_cmd is no longer working

Moelf avatar Jan 19 '21 20:01 Moelf

This would be useful! As a workaround, I'm now using the following shameful hack with IJulia 1.23.2:

using IJulia
jupyter = IJulia.find_jupyter_subcommand("")[1]
run(`$(jupyter) notebook list`)

tpgillam avatar Jul 21 '21 16:07 tpgillam

This would be useful! As a workaround, I'm now using the following shameful hack with IJulia 1.23.2:

using IJulia
jupyter = IJulia.find_jupyter_subcommand("")[1]
run(`$(jupyter) notebook list`)

I wanted to note that this helped me troubleshoot a problem during a clean install of conda and jupyter via IJulia. Previous to the clean install I had been tinkering around with hosting jupyter on a remote server and one of the server links was still open and connected to the default url and ports. As a result this caused a connection failure when trying to run the newly installed jupyter via IJulia. Long story short, I was able to use this (without installing jupyter by some other means) to see all the notebooks lingering in the background that had failed to close down properly and were conflicting with this

glemieux avatar Dec 15 '22 19:12 glemieux

This would be useful! As a workaround, I'm now using the following shameful hack with IJulia 1.23.2:

using IJulia
jupyter = IJulia.find_jupyter_subcommand("")[1]
run(`$(jupyter) notebook list`)

Thanks for this. I am brand new to WSL and this is this only way I could get the notebook running in the Windows browser. It's been a few years, but has there been anything implemented more permanent? Or a better way to pass the token?

uajdgiz avatar Jan 26 '24 09:01 uajdgiz

@uajdgiz I am also facing this issue.

Launching the notebook from the Julia REPL feels a little hacky--or just like a small convenience for most users accessing the notebook from their local machine. Not to say I wouldn't appreciate this feature being updated to eliminate the need for a token or print it out on launch, but yeah--it feels like there should be a better way.

The best thing I could think of was just running a Jupyterlab docker container with Julia built in. I found a helpful guide here to introduce the concept, and there's more documentation on Jupyter's documentation on doing this. This feels like the right way to handle this.

Unfortunately for me, I need Julia 1.6.7, but their docker images only go back to 1.9.1 or something--so I wasn't able to personally take this route without making my own image. For now (and for the sake of time) I'll be sticking to the "shameful hack" lol.

nlitz88 avatar Jan 28 '24 21:01 nlitz88