Created
November 30, 2020 17:39
-
-
Save BrennanBarker/c0bed3efd2df25c929d65fb05290ecfd to your computer and use it in GitHub Desktop.
connecting local qtconsole to a remote Jupiter kernel over ssh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ Connect via ssh to a remote jupyter kernel | |
| 1. Start a jupyter kernel on the remote machine: | |
| `(remote)$ jupyter kernel` | |
| 2. Note the kernel connection file location and copy to local machine (can use globbing if you escape, e.g. "\*"): | |
| `(local)$ scp remote-user@remote-host:<conn-file.json> .` | |
| 3. Use this script to quickly forward the appropriate ports over SSH: | |
| `(local)$ for port in $(python qt_connect.py <conn-file.json>); do ssh -f -N -L $port\:localhost:$port pi@192.168.1.90; done` | |
| 4. Open a local qtconsole instance specifying a connection to the remote | |
| kernel: | |
| `(local)$ jupyter qtconsole --existing <conn-file.json>` | |
| """ | |
| import sys, json | |
| with open(sys.argv[1], 'r') as f: | |
| connection_info = json.load(f) | |
| for p in ['shell_port', 'iopub_port', 'stdin_port', 'control_port', 'hb_port']: | |
| print(connection_info[port]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment