Connecting to Tools

SSH into Jupyter, connecting with private Git repositories, and managing credentials.

SSH

SSH access provides alternatives to Jupyterlab for working with your projects. In order to access a server via SSH, a public key must first be added for your user.

Adding SSH Public Keys

From the dashboard sidebar, select “Credentials”, then click the + in the upper right to add a new credential. Select “SSH Public Key” from the type list, choose a name, and paste in an openssh-formatted public key. If you do not yet have a public key, follow the instructions here to create a keypair, and copy the public key into the text box, as shown below.

Note that some key generation tools (such as PuTTY) may generate public keys in various formats - the public key here must be in openssh format.

Enable SSH for the Jupyter Server

If the server already exists, click its name from the server list to edit its details (if it is running, it must first be stopped). Under Advanced Settings, check the checkbox labeled “Enable SSH Access”. Click Save, then start the server.

Create or Update the Jupyter Server

If the server was already running before your key was added, it will need to be stopped and restarted to pick up the newly-created key.

Connecting to the Server

Many tools should be compatible with this functionality. Below are instructions for some popular options. For all options, the SSH URL is found in the server’s details:

Note that this URL may change if the server is stopped, including auto-shutoff

Terminal

Using the terminal application of your choice, the server can be accessed via:

ssh <server URL>

If your key is not added to your ssh agent (or no ssh agent is running), the key can be manually specified:

ssh -i path/to/key <server URL>

PyCharm

To set up PyCharm to connect to a running Jupyter server, follow Jetbrains’ instructions here: https://www.jetbrains.com/help/pycharm/creating-a-remote-server-configuration.html. Choose SFTP for the credentials type and create a new SSH configuration. Use the following values:

Host: The hostname from the Jupyter Server details (see screenshot above) - remove joyvan@ .

Port: 22

User name: jovyan

Authentication type: Key pair

Private key file: Path to your private key

Passphrase: The passphrase to your key, if you set one

Once the new server configuration has been added, navigate to Tools > Deployment > Remote Host. Fprom the new panel this opens, select the new server configuration you just created. This will let you browse the contents of the server, and edit the files in place. Your project is located at /home/jovyan/project . From Tools > Start SSH Session… a terminal can be opened to run commands.

Visual Studio Code (VS Code)

Using the Remote - SSH plugin, VS Code can connect to the Jupyter Server instance directly. To set this up, following their instructions: https://code.visualstudio.com/docs/remote/ssh

To make configuration easy, it is suggested to add an entry to your ~/.ssh/config file (create it if it doesn’t exist):

Host myjupyter
    HostName <your server hostname>
    User jovyan
    IdentityFile path/to/your/key

Update the name above to match your server as you see fit. Then, from the command pallette (Ctrl+Shift+P or Cmd+Shift+P, depending on OS), select Remote-SSH: Connect to host…, then select your config entry (created above) from the list. Once opened, select “Open Folder”, then choose /home/jovyan/project . The project’s files can be opened directly, and bash is available if you would like to open a terminal through VS Code.

Using a private git repo in Saturn Cloud

This section will cover:

  • How to use Credentials in Saturn to access private git repositories on GitHub
  • How to install and use a Python package from a git repository in Jupyter and on a Dask cluster
  • How to use a Start Script in Saturn to create custom, reproducible environments

This tutorial focuses only on GitHub, but the same principles apply to private git repositories on other hosted version control systems like GitLab, BitBucket, or AWS CodeCommit.

Set up Access Token in GitHub

This tutorial uses Access Tokens to clone git repositories. This is a form of authentication where you generate a single purpose private token with specific permissions so GitHub can verify that you are allowed to clone a repo.

To create a new access token, follow the steps in this tutorial:

Stop right after you’ve created the token. You should see your token and be able to copy it.

Add Credentials in Saturn

Copy the access token that you just set up. In the Saturn UI, navigate to the Credentials page. Click +.

  • Shared With: choose your username
  • Name: GITHUB_TOKEN
  • Value: Paste in the contents of your GitHub access token

Click Save to create this credential.

Clone with a start script

The GITHUB_TOKEN will now automatically be present whenever you start up a Jupyter, Dask cluster, or Deployment. Next, let’s use a Start Script that takes advantage of that fact.

The Start Script is a shell script that runs whenever Saturn creates resources like Jupyter servers, Dask workers, or Deployments.

Navigate to the Jupyter page. In the Create Server form, scroll down to the Advanced Settings and enter the following in the Start Script box.

GITHUB_REPO=github.com/your_org/your_repo
mkdir -p /tmp/repos

pushd /tmp/repos
    yes | git clone https://${GITHUB_TOKEN}@${GITHUB_REPO}
popd

After filling out the Start Script, click Create. Now you will have the git repo cloned into your Jupyter files.

You can push and pull from that repo without any further authentication.


SSH, PyCharm, and VS Code

Saturn provides SSH access into Jupyter instances, which means you can also connect PyCharm and VS Code

Git repositories

Connecting to Git repositories (GitHub, BitBucket, GitLab, etc..)

Prefect Cloud

Saturn Cloud offers a built-in integration with Prefect Cloud, a hosted version of prefect. Prefect is an open-source workflow management framework written in Python.