# SSH 密钥对

SSH（安全外壳）密钥对用于身份验证和加密通信，由一个公网密钥和一个私网密钥组成。公网密钥可以用来加密只有私网密钥才能解密的消息。这一特性作为使用密钥对进行身份验证的方式。您的 SSH 密钥对包含多个公网密钥，可以放置在服务器上以安全访问。

## 支持的格式 <a href="#supported-formats" id="supported-formats"></a>

SSH 密钥通常存储在 \~/.ssh/ 目录中。

<table><thead><tr><th width="196">格式</th><th width="265">以...开头</th><th>最小长度</th></tr></thead><tbody><tr><td><strong>RSA</strong></td><td>ssh-rsa</td><td>2048 位</td></tr><tr><td><strong>ED25519</strong></td><td>ssh-ed25519</td><td>256 位</td></tr><tr><td><strong>ECDSA</strong></td><td>ecdsa-sha2-nistp</td><td>256 位</td></tr></tbody></table>

{% hint style="info" %} <mark style="color:blue;">**注意**</mark>

* <mark style="color:blue;">提供您的公网密钥。请小心不要使用您的私网密钥。</mark>
* <mark style="color:blue;">建议您使用</mark> <mark style="color:blue;">**RSA**</mark> <mark style="color:blue;">或</mark> <mark style="color:blue;">**ED25519**</mark> <mark style="color:blue;">密钥，因为它们具有良好的兼容性和安全性。</mark>
  {% endhint %}

## 示例 <a href="#example" id="example"></a>

这里我们以 RSA 格式为例。

### 公网密钥 <a href="#public-key" id="public-key"></a>

```
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDx6VN...
```

### 私网密钥 <a href="#private-key" id="private-key"></a>

```
-----BEGIN RSA PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: AES-256-CBC,5764636E65726F726974686D616E6F6E
...
-----END RSA PRIVATE KEY-----
```

## 限制 <a href="#limit" id="limit"></a>

您可以添加最多 5 个公网密钥以创建 SSH 密钥对。


---

# Agent Instructions: 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:

```
GET https://docs.console.zenlayer.com/welcome/cn/elastic-compute/security/ssh-key-pair.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
