SSH, PyCharm, and VS Code
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.
Additional Infrastructure CostsEnabling SSH access for a Jupyter Server results in additional infrastructure costs. We use an ELB (Elastic Load Balancer) per SSH service. These charges are per Jupyter instance. If you run a Jupyter instance for an entire month with SSH enabled, expect approximately $20 in additional AWS charges.
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
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>
Notethis functionality is only available in the Professional edition of Pycharm - it is not available in the Community (free) edition.
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@ .
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)
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.