> 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-2/how-to/how-to-configure-an-ssh-key-new-server.md).

# How to Configure an SSH Key on a New Server

SSH lets you manage 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 provisioning and connect with it afterward.

> 👍 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 you keep, and it is what proves your identity when connecting.

That is why a key is more secure than a password: it does not travel, it cannot be guessed, and it is not reused across services.

| Item        | Where it lives   | What it's for                              |
| ----------- | ---------------- | ------------------------------------------ |
| Public key  | On the server    | Verifies who connects                      |
| Private key | On your computer | Identifies you when connecting; 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 **+**.
3. In the window that opens, enter a **name for the key**, check **Generate a new key** and click **Add**.

{/\* 📸 SCREENSHOT 1 · field "Choose an SSH key" with the + button and the key generation dialog \*/}

![Generation of a new SSH key during server creation](https://REEMPLAZA-URL/servidores-howto-ssh-01.png)

> #### ❗️ The private key is shown only once
>
> When you add it, the platform shows you the private key. Copy it and save it in a safe place 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 filled with the newly created key. Click **Create server**.

{/\* 📸 SCREENSHOT 2 · wizard with the selected key and the Create server button \*/}

![Server with the selected SSH key, ready to create](https://REEMPLAZA-URL/servidores-howto-ssh-02.png)

### 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 (username and IP of your server)
ssh -i ~/.ssh/plenit-srv01 <username>@<SERVER-IP>
```

On Windows, with the OpenSSH client from PowerShell:

```powershell
# Restrict the key 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" <username>@<SERVER-IP>
```

> #### 📘 The user depends on the image
>
> The username to connect with is determined by the server operating system. If you're not sure, confirm it based on 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 don't have the private key         | It was shown only 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](/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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
