Run sshd under jupyter
Project description
jupyter-sshd-proxy
Enable sshing into a remote Jupyter Server.
Primarily for use with remote JupyterHubs, so users can access them via ssh. Enables everything
one would normally do with ssh - copy files, run interactive commands, use the proprietary
VSCode Remote Development functionality, etc!
Usage
For this document, we will assume you are running inside a containerized JupyterHub enviornment
(such as kubernetes or docker). jupyter-sshd-proxy itself does not require
containerization - this is simply to make instructions easier.
Server pre-requisities
The following packages must be present in the container environment:
- openssh. You can install this from
conda-forgeor fromaptas you desire. jupyter-sshd-proxyitself must be pre-installed in the container - you can not dynamically install it with!pipafter you start the container.
The docker image quay.io/yuvipanda/pangeo-jupyter-sshd-proxy:latest can be used
for testing purposes. It it is based on the pangeo-notebook docker image, and has
the pre-requisites required pre-installed. You can find the source Dockerfile for
it in this repository.
Client pre-requisites
websocat must be installed on the client machine.
brew install websocat works on Mac OS, and pre-built binaries are available
for all other operating systems.
Start your server
jupyter-sshd-proxy only works after you start your JupyterHub server. So, start your server!
Create a JupyterHub Token
We will need to create a JupyterHub token for authentication.
-
Go to the JupyterHub control panel. You can access it via
File -> Hub control panelin JupyterLab, or directly going tohttps://<your-hub-url>/hub/home. -
In the top bar, select Token.
-
Create a new Token, and keep it safe. Treat this like you would treat a password to your JupyterHub instance! It is recommended you set an expiry date for this.
Setup your local ~/.ssh/config
We will set up our ssh config file to tell ssh how to connect to our JupyterHub. Add
an entry that looks like this to the end of your ~/.ssh/config file (create it if it
does not exist).
Host <YOUR-JUPYTERHUB-DOMAIN>
User <YOUR-JUPYTERHUB-CONTAINER-USER-NAME>
ProxyCommand websocat --binary -H='Authorization: token <YOUR-JUPYTERHUB-TOKEN>' asyncstdio: wss://%h/user/<YOUR-JUPYTERHUB-USERNAME>/sshd/
replace:
<YOUR-JUPYTERHUB-DOMAIN>with your hub domain (for example,hub.openveda.cloud)<YOUR-JUPYTERHUB-TOKEN>with the token you generated earlier<YOUR-JUPYTERHUB-USERNAME>with your jupyterhub username<YOUR-JUPYTERHUB-CONTAINER-USERNAME>is the name of the unix user created inside your JupyterHub container. This is most commonlyjovyan. You can verify this by runningwhoamioridin the terminal in your JupyterHub.
Here's an example:
Host hub.openveda.cloud
User jovyan
ProxyCommand websocat --binary -H='Authorization: token a56ff59c93f64fb587f46b06af9422ee' asyncstdio: wss://%h/user/yuvipanda/sshd/
We're almost there!
Setup ssh keys on your JupyterHub server
There are still two levels of authentication - your JupyterHub token, as well as some ssh keys. You need to put some ssh public keys
in ~/.ssh/authorized_keys after you start your JupyterHub server, and have the private keys available in your ssh client machine.
The simplest way to do this is to rely on your GitHub public keys!
-
After you start your JupyterHub server, open a terminal in JupyterLab
-
Run the following commands:
mkdir -p ~/.ssh wget https://github.com/<YOUR-GITHUB-USERNAME>.keys -O ~/.ssh/authorized_keys chmod 0600 ~/.ssh/authorized_keys
replacing
<YOUR-GITHUB-USERNAME>with your github username.
With that, we are ready to go!
ssh into your JupyterHub!
After all this is setup, you're now able to ssh in! Try:
ssh <YOUR-JUPYTERHUB-DOMAIN>
and it should just work! You can also use this with the proprietary Visual Studio code Remote SSH feature,
use sftp to copy files over (although it will be slow), create tunnels, etc!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file jupyter_sshd_proxy-0.3.0.tar.gz.
File metadata
- Download URL: jupyter_sshd_proxy-0.3.0.tar.gz
- Upload date:
- Size: 6.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2d4ea167f39864fd436173860798ebd1625385e248e070bf29c96354db34543b
|
|
| MD5 |
4ecf04111eec9900a823fa7a0920b0b7
|
|
| BLAKE2b-256 |
662e098b0c33ddfc51af5e4082c617b4595ef7f35b283999066dc47d87940c13
|
File details
Details for the file jupyter_sshd_proxy-0.3.0-py3-none-any.whl.
File metadata
- Download URL: jupyter_sshd_proxy-0.3.0-py3-none-any.whl
- Upload date:
- Size: 5.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cb33e012a3b5eee1e7ce1c1986534e4797473c6a05973a4ffbbd410094becf08
|
|
| MD5 |
dd4d61f0ebdd9a9d78e8179df5948a52
|
|
| BLAKE2b-256 |
94c4148eec071c341ba935a05f9bd61ddd08a7de8e9219f745b4dfd9868f1fef
|