Skip to content

Instantly share code, notes, and snippets.

@tomykaira
Created February 11, 2019 17:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomykaira/aaafc7ec3b3bda47aecc1df87af5b034 to your computer and use it in GitHub Desktop.
Save tomykaira/aaafc7ec3b3bda47aecc1df87af5b034 to your computer and use it in GitHub Desktop.
Run remote jupyter server (server = windows + WSL + SSH)
#!/bin/sh
set -e
local_json=/tmp/jupyter-kernel.json
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