> For the complete documentation index, see [llms.txt](https://docs.plenit.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.plenit.com/docs-en/productos/servers/how-to/how-to-configure-an-ssh-key-new-server.md).

# How to Configure an SSH Key on a New Server

SSH lets you administer a server remotely from the command line, with the connection encrypted through port 22.

Instead of a password, it uses a pair of keys: you create the key during server setup and then connect with it later.

> 👍 What you get
>
> A server created with its associated SSH key, and the private key in your possession to connect securely.

### How the key pair works

SSH works with two pieces that go together: a public key and a private key. The public one stays on the server; the private one is kept by you and is what proves your identity when connecting.

That is why a key is more secure than a password: it doesn't travel, it can't be guessed, and it isn't reused across services.

| Item        | Where it lives   | What is it for                                   |
| ----------- | ---------------- | ------------------------------------------------ |
| Public key  | On the server    | Verifies who connects                            |
| Private key | On your computer | Identifies you when connecting; it is not shared |

### Before you begin

* Be registered on the Plenit platform.
* Have permission to create servers.
* Be creating a server in a subscription of **Servers** (the key is configured in the last step of the wizard).

### Step 1. Generate the key when creating the server

In the last window of the wizard (the one for **Name**):

1. Enter the **name** of the server.
2. In **Choose an SSH key**, click the button **+**.
3. In the window that opens, enter a **name for the key**, check **Generate a new key** and click **Add**.

<figure><img src="https://3894148717-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxksPMyYRDCe4qKkhbpcY%2Fuploads%2Fgit-blob-6ebe3478ca3e9017eb36727d1f1c96c7cbe57120%2FCAPTURA%201%20y%202%20%C2%B7%20asistente%20con%20la%20clave%20seleccionada%20y%20el%20bot%C3%B3n%20Crear%20servidor%20(1).jpg?alt=media" alt="Generación de una nueva clave SSH durante la creación del servidor"><figcaption><p>Generation of a new SSH key during server creation</p></figcaption></figure>

> #### ❗️ The private key is shown only once
>
> When you add it, the platform shows you the private key. Copy it and save it somewhere safe at that moment: it cannot be viewed again. If you lose it, generate a new one.

4. Copy the private key and click **Confirm**.
5. Back in the wizard, the field **Choose an SSH key** is left with the newly created key. Click **Create server**.

<figure><img src="https://3894148717-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxksPMyYRDCe4qKkhbpcY%2Fuploads%2Fgit-blob-87f1685ac61cd4da2d6d1f08a32e204a6916dd71%2FCAPTURA%201%20y%202%20%C2%B7%20asistente%20con%20la%20clave%20seleccionada%20y%20el%20bot%C3%B3n%20Crear%20servidor%20(3).jpg?alt=media" alt="Servidor con la clave SSH seleccionada, listo para crear"><figcaption><p>Server with the selected SSH key, ready to create</p></figcaption></figure>

### Step 2. Connect with the key

Save the private key in a file and protect it: SSH rejects a private key with permissions that are too open.

On Linux or macOS:

```bash
# Save the key in ~/.ssh and restrict its permissions
chmod 600 ~/.ssh/plenit-srv01

# Connect (user and IP of your server)
ssh -i ~/.ssh/plenit-srv01 <user>@<SERVER-IP>
```

On Windows, with the OpenSSH client from PowerShell:

```powershell
# Restrict the key's permissions to the current user
icacls "C:\Users\<your-user>\.ssh\plenit-srv01" /inheritance:r /grant:r "%USERNAME%:R"

# Connect
ssh -i "C:\Users\<your-user>\.ssh\plenit-srv01" <user>@<SERVER-IP>
```

> #### 📘 The user depends on the image
>
> The username used to connect is determined by the server operating system. If you're not sure, confirm it according to the image you deployed.

### If something doesn't fit

| Symptom                                | Likely cause                                            | What to do                                            |
| -------------------------------------- | ------------------------------------------------------- | ----------------------------------------------------- |
| SSH rejects the key due to permissions | The private key is accessible to other users            | Apply `chmod 600` (Linux) or `icacls` (Windows)       |
| You do not have the private key        | It was only shown when it was created and was not saved | Generate a new key and associate it with the server   |
| The connection is rejected             | Incorrect user for that image                           | Use the user that corresponds to the operating system |

### Next steps

* [How to configure an SSH key on an existing server](https://docs.plenit.com/docs-en/productos/servers/how-to/how-to-configure-an-ssh-key-existing-server.md)

<br>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.plenit.com/docs-en/productos/servers/how-to/how-to-configure-an-ssh-key-new-server.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
