CoCalc support for SSH is significantly improved with the CoCalc upgrade to Kubernetes. This article reviews new features and gives examples using SSH with CoCalc.
New SSH Features
TL;DR: SSH to CoCalc projects has been completely rewritten. For example, you can now paste a single ssh key in account settings, and it will automatically be available in all of your projects!
User Interface for Managing Public Keys
User interfaces are now available for managing your SSH keys. Using these forms, you can add and remove keys, as well as viewing which keys are configured and when they have been used last. There are separate UI dialogues for keys configured at account and project scope, as described below.
To connect from a remote computer to the SSH server on a project, you must have owner or collaborator status on that project. It is NOT required that the project have network access enabled; network access is only required if you want to ssh from a project to somewhere else.
NOTE: Manual editing of the authorized_keys file is no longer supported. Use the procedures below to add public keys.
Configure a single key for all projects for a given account
It is now possible to set a public key for your CoCalc account that works
with all projects where your account is owner or collaborator.
Click on your account name or the gear icon next to it, and choose the
SSH Keys tab.
There is a form at right for entering keys, as shown here:
To add a key, enter a descriptive title and paste the .pub
file for the public key file into the form and click
Add SSH Key.
Extraneous spaces and newlines in the key
that is pasted in will be automatically removed.
The title, MD5 fingerprint, and last-used timestamp will be displayed for each key that is added, as shown here:
Multiple keys can be added in this way.
If you want to remove an account key, return to the SSH Keys tab and click the Delete button to the right of the key you want to delete.
To use an account key, you will need the ssh user and hostname
for a project you want to access.
Open project settings (wrench icon) and look in the
SSH Keys section at lower left for the information
under ‘Use the following username@host:’.
You will see that the username is the same as
the destination project id without hyphens,
and the host is always ssh.cocalc.com.
(This is a major improvement over before when the host
depended on the project.)
See below for detailed examples of using SSH keys.
Configure a public key for a single project
There is also a form to add and remove keys for
a single project.
To add a key for use with a single project, open project
Settings (wrench icon) and scroll down to the
SSH Keys section at lower left.
Click ‘Add an SSH Key’ to open the dialogue shown
SSH agent forwarding
If you’re familiar with ssh-agent forwarding, this feature is now supported by CoCalc. You will need to have ssh-agent configured on your local system and have public keys distributed to all target hosts for agent forwarding to work.
See Steve Friedl’s Tech Tips guide for more info about SSH agent forwarding.
SSH access between CoCalc projects
When the client and server for an SSH connection are both
CoCalc projects, you can use a hostname of
ssh rather than
Using the shorter hostname gives a much faster connection,
because it is optimized within the CoCalc cloud.