Skip to content

Instantly share code, notes, and snippets.

Created February 11, 2019 17:37
What would you like to do?
Run remote jupyter server (server = windows + WSL + SSH)
set -e
rm nohup.out
pkill -f "jupyter-kernel.exe"
nohup ssh win "/mnt/c/Users/tomyk_000.GALLERIAXTWIN81/Anaconda3/Scripts/jupyter-kernel.exe" &
sleep 1
json_filename=$(grep -o 'kernel-.*.json' nohup.out | tail -1)
scp "win:/mnt/c/Users/tomyk_000.GALLERIAXTWIN81/AppData/Roaming/jupyter/runtime/$json_filename" $local_json
ssh win -f -N $(for pt in $(cat $local_json | jq -r '[.shell_port, .iopub_port, .stdin_port, .control_port]|map(tostring)|join("\n")'); do /bin/echo -n "-L ${pt}:localhost:${pt} "; done)
jupyter run --existing /tmp/jupyter-kernel.json <<< "print('hello')"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment