SSH Kernel - an ipykernel over ssh
A remote jupyterkernel via ssh
- Free software: MIT license
The ideas are heavily based on remote_ikernel, however ssh_ipykerneladds some important features
jupyter_client's functionwrite_connection_fileis used on the remote server to get free ports- Local ports (obtained by jupyter also via
write_connection_file) will be ssh forwarded to the remote ports - The ssh connection and the tunnel command will be retried in case of network or similar errors
- introduced signal handling with python's
signalmodule
Installation
pip install ssh_ipykernel
jupyter labextension install interrupt-ipykernel-extension
Usage
-
Usage of ssh_ipykernel
$ python -m ssh_ipykernel -h usage: __main__.py [--help] [--timeout TIMEOUT] [--env [ENV [ENV ...]]] [-s] --file FILE --host HOST --python PYTHON optional arguments: --help, -h show this help message and exit --timeout TIMEOUT, -t TIMEOUT timeout for remote commands --env [ENV [ENV ...]], -e [ENV [ENV ...]] environment variables for the remote kernel in the form: VAR1=value1 VAR2=value2 -s sudo required to start kernel on the remote machine required arguments: --file FILE, -f FILE jupyter kernel connection file --host HOST, -H HOST remote host --python PYTHON, -p PYTHON remote python_path -
Creation of kernel specification
-
from python
import ssh_ipykernel.manage ssh_ipykernel.manage.add_kernel( host="btest", display_name="SSH btest:demo(abc)", local_python_path="/opt/miniconda/envs/test36/bin/python", remote_python_path="/opt/anaconda/envs/python36", sudo=False, env="VAR1=demo VAR2=abc", timeout=10 )
-
from terminal
python -m ssh_ipykernel.manage --display-name "SSH btest:demo(abc) \ --host btest \ --python /opt/anaconda/envs/python36 \ --env "VAR1=demo VAR2=abc"
$ python -m ssh_ipykernel.manage --help usage: manage.py [--help] [--display-name DISPLAY_NAME] [--sudo] [--timeout TIMEOUT] [--env [ENV [ENV ...]]] --host HOST --python PYTHON optional arguments: --help, -h show this help message and exit --display-name DISPLAY_NAME, -d DISPLAY_NAME kernel display name (default is host name) --sudo, -s sudo required to start kernel on the remote machine --timeout TIMEOUT, -t TIMEOUT timeout for remote commands --env [ENV [ENV ...]], -e [ENV [ENV ...]] environment variables for the remote kernel in the form: VAR1=value1 VAR2=value2 required arguments: --host HOST, -H HOST remote host --python PYTHON, -p PYTHON remote python_path
-
-
Checking of kernel specification
$ jupyter-kernelspec list Available kernels: ssh__ssh_btest_demo_abc_ /Users/bernhard/Library/Jupyter/kernels/ssh__ssh_btest_demo_abc_
$ cat /Users/bernhard/Library/Jupyter/kernels/ssh__ssh_btest_demo_abc_/kernel.json { "argv": [ "/opt/miniconda/envs/test36/bin/python", "-m", "ssh_ipykernel", "--host", "btest", "--python", "/opt/anaconda/envs/python36", "--timeout", "10", "--env", "VAR1=demo VAR2=abc", "-f", "{connection_file}" ], "display_name": "SSH btest:demo(abc)", "language": "python" }
-
Add an ssh config entry to
~/.ssh/configfor the remote host:Host btest HostName btest.example.com User john Port 22 IdentityFile ~/.ssh/id_rsa ServerAliveInterval 30 ConnectTimeout 5 ServerAliveCountMax 5760
Credits
The ideas are heavily based on
History
1.0.0 (2020-05-07)
- Added an extension to send sigint to the reote kernel via ssh (needed for Windows)
- Added Windows support (for OpoenSSH)
- Added a call to a kernel_customize function for sub classes to inject customizations for the kernel
0.1.0 (2019-09-01)
- First release on github
0.9.0 (2019-09-03)
- Restructured pxssh calls
- Rewrote keeping alive routine
- Stabilized error detection (cluster not reachable, VPN cut, ipykernel missing)
0.9.2 (2019-09-20)
- Added code to call ssh_ipykernel as a module to add a kernel
- Added doc strings to all classes and methods
0.9.3 (2019-09-20)
- Fixed argument error for env variables in ssh_ipykernel.manage
Metadata
Release files for ssh-ipykernel 1.2.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ssh_ipykernel-1.2.3.tar.gz | 15.1 kB | Without provenance | Details for ssh_ipykernel-1.2.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ssh_ipykernel-1.2.3-py3-none-any.whl | Python 3 | none | any | Details for ssh_ipykernel-1.2.3-py3-none-any.whl |
Total release size: 31.4 kB
Release files / ssh_ipykernel-1.2.3.tar.gz
| Download URL | ssh_ipykernel-1.2.3.tar.gz |
|---|---|
| Size | 15.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
99314a231846fb47557ebac36fbf4ad0a289933a34b8ef59dfe893a9eb4adbda
|
|
BLAKE2b-256 checksum How to use checksums |
3440338b3799c9ab954364d88b851032e398c54dbed5ca6f8c4a77343571103f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.6.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.8.10
|
Release files / ssh_ipykernel-1.2.3-py3-none-any.whl
| Download URL | ssh_ipykernel-1.2.3-py3-none-any.whl |
|---|---|
| Size | 16.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
eb21cb4bcad43f1f662a497457f213115ced48bbdfbd1229f6537a55e3243b42
|
|
BLAKE2b-256 checksum How to use checksums |
ef3abccd6796bdc381e2ce7f21ec37187a68703660ddda41534a588f078563b5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.6.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.8.10
|
Security for ssh-ipykernel 1.2.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.