# Create an SSH key and add it to your server

You generate an SSH key pair in the terminal, place the public key on the server, and store the private key in the platform.

> Source: https://www.application-platform.com/en/docs/create-ssh-key/

An SSH key pair consists of a private key, which stays secret and goes into the platform, and a public key, which goes onto the server. You need one when you want to connect a [server of your own]({{< relref "own-server" >}}) to the platform.

## 1. Generate the key pair

Run this command in the terminal:

```bash
ssh-keygen -t ed25519 -C "application-platform" -f ~/.ssh/application-platform
```

Confirm the prompts with Enter. Afterwards, `~/.ssh` contains the private key `application-platform` and the public key `application-platform.pub`.

## 2. Add the public key to the server

The quickest way is `ssh-copy-id`; replace the user and host with the values of your server:

```bash
ssh-copy-id -i ~/.ssh/application-platform.pub deploy@your-server.example.com
```

Without `ssh-copy-id`, append the contents of the `.pub` file by hand to the `~/.ssh/authorized_keys` file of the user on the server.

Then check the login with the new key:

```bash
ssh -i ~/.ssh/application-platform deploy@your-server.example.com
```

If you land on the server without being asked for a password, the public key is in place. If the server still asks for a password, check whether you added the key to the right user.

## 3. Store the private key in the platform

1. In the platform, open **Servers**, click **Add server**, and choose **SSH**.
2. Print the contents of the private key file in the terminal:

   ```bash
   cat ~/.ssh/application-platform
   ```

3. Copy the complete output, including the `BEGIN` and `END` lines, into the **SSH private key** field.
4. Fill in the remaining fields as described under [Your own server (SSH)]({{< relref "own-server" >}}) and save.

{{< docnote type="warning" >}}
The private key belongs only in your `~/.ssh` folder and in the server entry of the platform. Never share it via chat or email, and never commit it to a repository.
{{< /docnote >}}

