SSH Keys#
Introduction#
SSH (Secure Shell) keys are a secure and convenient way to authenticate to remote systems without typing your password for every connection. They are commonly used for:
logging in to research computing systems such as Eureka2 and AISurrey
connecting through the SSH gateway when you are not using the VPN
using Git over SSH with Surrey GitLab, GitHub, GitLab.com, Bitbucket and similar services
automating safe, repeatable workflows where password prompts would be impractical
For most research computing users, SSH keys become part of their normal working environment. The initial setup takes a few minutes, but after that the same key can be used repeatedly from your laptop or desktop to access the systems where the matching public key has been installed.
Why use SSH keys?#
Using SSH keys instead of passwords offers several advantages:
Improved security: a correctly generated SSH key is computationally infeasible to guess. A passphrase-protected private key is also harder to misuse if your laptop is lost or stolen.
Convenience: once set up, an SSH agent can remember your passphrase until your laptop or desktop is rebooted.
Automation: SSH keys are suitable for scripts and tools that need to connect to remote systems without repeated password prompts.
Git access: Surrey GitLab and many external Git services support Git over SSH, which is often more convenient than HTTPS tokens.
How does it work?#
An SSH key pair consists of two files:
- Public key:
This file usually ends in
.pub. It is safe to upload to services such as GitLab or GitHub, or to add to~/.ssh/authorized_keyson a remote server.- Private key:
This file has the same name but no
.pubsuffix. Keep it secret. Never email it, upload it, paste it into web forms, or share it with anyone. If a private key is exposed, treat it as compromised and replace it.
When you connect to a remote system, your computer proves that it has the private key corresponding to the public key installed on that system. The private key itself is not sent over the network. Learn more about the underlying technology on Wikipedia.
Warning
Only share or upload the public key file ending in .pub. Never share the matching private key.
Which page should I read next?#
If you are new to SSH keys.
If you already have a key and need to add it to a cluster, gateway, GitLab or GitHub.
If you use several Git services such as Surrey’s GitLab, GitHub, GitLab.com.