Jupyter notebook remote connection - Quantitative-Physiological-Imaging-Lab/documentation GitHub Wiki
ssh user@hostname
i.e ssh username@perf-imglab08
. Then enter password
You will likely need to add the .concordia.ca
identifier to the end of the hostname
ssh [email protected]
cd directory_to_work
Load the anaconda environment (and any others that you need!)
module load anaconda3 example_module2
Start the jupyter notebook AND/OR (but mostly OR) jupyter lab kernel (this can be done within a tmux session to allow you to log out while keeping the kernel running).
jupyter notebook --port=8889 --no-browser
or
jupyter lab --port=8889 --no-browser
Local address:port is listed first, then remote address:port (i.e., to <-- from)
ssh -N -L localhost:8888:localhost:8889 user@hostname
HERE's THE TRICK. On your prior tab/window/terminal (especially for Macs) replace the localhost:8889
with the local host that your computer TELLS YOU. Then enter your username@neuralabccs01 and password and go straight to opening a browser and writing, as seen below for localhost:8888
To end forwarding, simply cancel the running process with ctrl-c
Add -X
at the end to enable X11 forwarding, which should allow some access to visualizations from the command line terminal available in jupyter lab. As far as I can tell, this only works if you keep your first ssh session (where you started the jupyter lab) connected and open and is as slow as native X11 forwarding :-/.
ssh -N -L localhost:8888:localhost:8889 user@hostname -X
Add -f
if you do not want the ssh process to be launched in the background
ssh -N -f -L localhost:8888:localhost:8889 user@hostname
You can now open a browser and navigate to localhost:8888
, which will connect you to Jupiter notebook
When you are finished, find the running process id in your local computer (linux) ps ax |grep ssh
and kill <PID>
Then kill your remote jupyter kernel by (if you logged out) logging back in, re-opening the tmux session, and typing ctrl-c ctrl-c
https://thedatafrog.com/en/remote-jupyter-notebooks/ https://www.blopig.com/blog/2018/03/running-jupyter-notebook-on-a-remote-server-via-ssh/
This allows you to only type in "ssh your-alias"
On Linux:
Open a new terminal.
Create and edit a new config file in /.ssh
by typing the command nano ~/.ssh/config
In that file, type the following:
Host "alias"
(Here type any alias name that is easy to remember, will be using this to ssh)
HostName neuralabccs01
User "yourusename"
(type your username)
Port 22
Save the file and exit. Now you can use ssh "alias"
to connect.
Here is how the file should look:
https://www.youtube.com/watch?v=bO9eX5JIHdE
the appropriate directory of this file will depend on your operating system, so use google.