> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cudocompute.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 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.

<Note>
  If you already have an SSH key you'd like to use, you can skip straight to [Add your SSH key to CUDO Compute](#add-your-ssh-key-to-cudo-compute)
</Note>

### Linux and macOS

1. Open <a href="https://support.apple.com/en-gb/guide/terminal/welcome/mac" target="_blank">Terminal</a>.

2. Paste the text below, substituting your email address.

   ```shell theme={null}
   ssh-keygen -t ed25519 -C "your_email@example.com"
   ```

   This creates a new SSH key, using the provided email as a label.

   ```shell theme={null}
   > 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.

3. At the prompt, type a secure passphrase.

   ```shell theme={null}
   > 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.

1. Start the ssh-agent in the background.

   ```shell theme={null}
   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.

2. 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.

   ```shell theme={null}
   open ~/.ssh/config
   > The file /Users/YOU/.ssh/config does not exist.
   ```

   * If the file doesn't exist, create the file.

   ```shell theme={null}
   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.

   ```shell theme={null}
   Host *.cudo.org
   AddKeysToAgent yes
   UseKeychain yes
   IdentityFile ~/.ssh/id_ed25519
   ```

3. 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.

   ```shell theme={null}
   ssh-add --apple-use-keychain ~/.ssh/id_ed25519
   ```

### Windows

See [Windows with PuTTY](https://www.ssh.com/academy/ssh/putty/windows/puttygen) to generate an SSH key in Windows.

### Add your SSH key to CUDO Compute

Click the profile menu on the far right of the top navigation. Select SSH keys to navigate to the SSH keys page. When on the SSH keys page click "Add an SSH key". You will then be able to copy your public key into the form.
