How to generate SSH keys
Learn how to generate SSH keys on Linux, macOS and Windows.
Generate an SSH key
The following guide will show you how to generate a new SSH key on your local machine.
If you already have an SSH key you'd like to use, you can skip straight to Add your SSH key to CUDO Compute
Linux and macOS
- Open Terminal.
- Paste the text below, substituting your email address.
$ ssh-keygen -t ed25519 -C "[email protected]"
This creates a new SSH key, using the provided email as a label.> Generating public/private ALGORITHM key pair.
When you're prompted to "Enter a file in which to save the key", you can press Enter to accept the default file location. Please note that if you created SSH keys previously, ssh-keygen may ask you to rewrite another key, in which case we recommend creating a custom-named SSH key. To do so, type the default file location and replace id_ssh_keyname with your custom key name. - At the prompt, type a secure passphrase.
> Enter passphrase (empty for no passphrase): [Type a passphrase] > Enter same passphrase again: [Type passphrase again]
Adding your SSH key to the ssh-agent
Before adding a new SSH key to the ssh-agent to manage your keys, you should have checked for existing SSH keys and generated a new SSH key. When adding your SSH key to the agent, use the default macOS ssh-add command, and not an application installed by Macports, homebrew, or some other external source.
- Start the ssh-agent in the background.
$ eval "$(ssh-agent -s)" > Agent pid 59566
Depending on your environment, you may need to use a different command. For example, you may need to use root access by running sudo -s -H before starting the ssh-agent, or you may need to use exec ssh-agent bash or exec ssh-agent zsh to run the ssh-agent. - If you're using macOS Sierra 10.12.2 or later, you will need to modify your ~/.ssh/config file to automatically load keys into the ssh-agent and store passphrases in your keychain.
- First, check to see if your ~/.ssh/config file exists in the default location.
$ open ~/.ssh/config > The file /Users/YOU/.ssh/config does not exist.
- If the file doesn't exist, create the file.
$ touch ~/.ssh/config
- Open your ~/.ssh/config file, then modify the file to contain the following lines. If your SSH key file has a different name or path than the example code, modify the filename or path to match your current setup.
Host *.cudo.org AddKeysToAgent yes UseKeychain yes IdentityFile ~/.ssh/id_ed25519
- Add your SSH private key to the ssh-agent and store your passphrase in the keychain. If you created your key with a different name, or if you are adding an existing key that has a different name, replace id_ed25519 in the command with the name of your private key file.
$ ssh-add --apple-use-keychain ~/.ssh/id_ed25519
Windows
See Windows with PuTTY to generate an SSH key in Windows.
Add your SSH key to CUDO Compute
Click "SSH keys" in the sidebar then click "Add an SSH key" and you will be able to copy your public key into the form.