Skip to content
This repository was archived by the owner on Apr 7, 2026. It is now read-only.

Commit 50a76e9

Browse files
committed
modified: docs/appendix/ssh-server.md
1 parent d5e8ebc commit 50a76e9

1 file changed

Lines changed: 30 additions & 10 deletions

File tree

docs/appendix/ssh-server.md

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ SSH(Secure Shell)是一种加密的网络传输协议,可以在不安全
1818

1919
## 2. 生成 SSH 密钥对
2020

21-
下面介绍常用的 RSA 算法加密和 Ed25519 算法加密两种SSH密钥对,分别命名为 `id_rsa`, `id_rsa.pub``id_ed25519`, `id_ed25519.pub` 文件。当今SSH协议规范通常推荐使用Ed25519算法加密,不过现阶段我们不需要区分这两种加密具体区别。如果你很好奇这两种加密方式的优劣性,可以参阅[这篇文章](https://nikk.is-a.dev/blog/ed25119_n_rsa/)
21+
下面介绍常用的 RSA 算法加密和 Ed25519 算法加密两种 SSH 密钥对,分别命名为 `id_rsa`, `id_rsa.pub``id_ed25519`, `id_ed25519.pub` 文件。当今 SSH 协议规范通常推荐使用 Ed25519 算法加密,不过现阶段我们不需要区分这两种加密具体区别。如果你很好奇这两种加密方式的优劣性,可以参阅[这篇文章](https://nikk.is-a.dev/blog/ed25119_n_rsa/)
2222

2323
### 检查现有密钥
2424

@@ -34,7 +34,7 @@ ls ~/.ssh
3434
>
3535
>如果你有 `id_rsa``id_rsa.pub` 文件(由 RSA 算法加密),或 `id_ed25519``id_ed25519.pub` 文件(由 Ed25519 算法加密),说明你已经有 SSH 密钥对了。可以移步到[向他人分享你的公钥](#向他人分享你的公钥)
3636
37-
### 生成新的Ed25519密钥对
37+
### 生成新的 Ed25519 密钥对
3838

3939
在终端中输入以下命令生成 SSH 密钥对:
4040

@@ -44,7 +44,7 @@ ssh-keygen
4444

4545
> [!tip]
4646
>
47-
>在有些网站上,他们会宣称使用上面的方式生成了RSA密钥对,这是基于[比较老的SSH协议规范](https://www.rfc-editor.org/rfc/rfc4252)。自[OpenSSH 9.5](https://www.openssh.com/releasenotes.html#9.5)起,使用上述方法生成的密钥对默认是Ed25519加密的
47+
>在有些网站上,他们会宣称使用上面的方式生成了 RSA 密钥对,这是基于[比较老的SSH协议规范](https://www.rfc-editor.org/rfc/rfc4252)。自[OpenSSH 9.5](https://www.openssh.com/releasenotes.html#9.5)起,使用上述方法生成的密钥对默认是 Ed25519 加密的
4848
4949
执行上述命令后,系统会提示你进行一系列配置。除非你有配置 passphrase 的需求并且知道自己在做什么,否则连按三个回车即可。
5050

@@ -79,7 +79,7 @@ cat ~/.ssh/id_ed25519.pub
7979

8080
观察到输出为 `ssh-ed25519 xxxxxxxxxxxxxxx xxxxx@xxxx`,这就是你的公钥,可以复制并分享给他人。
8181

82-
### 生成新的RSA密钥对
82+
### 生成新的 RSA 密钥对
8383

8484
在终端中输入以下命令生成 SSH 密钥对:
8585

@@ -121,9 +121,9 @@ cat ~/.ssh/id_rsa.pub
121121

122122
观察到输出为 `ssh-rsa xxxxxxxxxxxxxxx xxxxx@xxxx` ,这就是你的公钥,可以复制并分享给他人。
123123

124-
## 3. 删除密钥对
124+
## 3. 重置密钥对
125125

126-
注意,本模块内容仅作为了解,供忘记了密码的同学参考以重置SSH。其他同学不需要执行。另外,如果在此处重置了SSH,你还需要在GitHub中重新上传新的SSH
126+
注意,本模块内容仅作为了解,供忘记了密码的同学参考以重置 SSH 密钥对。其他同学不需要执行。另外,如果在此处重置了 SSH 密钥对,你还需要在 GitHub 中重新上传新的 SSH 密钥对
127127

128128
### 检查现有密钥
129129

@@ -137,21 +137,41 @@ ls ~/.ssh
137137

138138
### 删除密钥对
139139

140-
***使用bash命令删除文件需要非常小心,我们强烈建议你直接复制以下代码指令**
140+
***使用 bash 命令删除文件需要非常小心,我们强烈建议你直接复制以下代码指令**
141+
142+
下面两种删除密钥对方式中只要选择一种操作即可:
143+
144+
- 重置 SSH (这将同时删除已存储的所有服务器信息和受信的公钥,不推荐)
141145

142146
```bash
143147
rm -rf ~/.ssh/*
144148
```
145149

146-
或者你也可以使用
150+
- 删除特定的 SSH 密钥对,使用
147151

148152
```bash
149153
cd .ssh
150154
dir
151-
rm *
152155
```
153156

154-
导航到存储ssh的文件夹直接删除相应的密钥。请用你的密钥名称替换这里的*, 例如:`rm id_ed25519`, `rm id_ed25519.pub`
157+
此时终端会显示 SSH 中存储的信息,例如:
158+
159+
```bash
160+
id_rsa id_rsa.pub id_ed25519 id_ed25519.pub known_hosts known_hosts.old authorized_keys
161+
```
162+
163+
使用 `rm` 操作删除指定的密钥对,例如,删除 Ed25519 加密的密钥对:
164+
165+
```bash
166+
rm ~/.ssh/id_ed25519
167+
rm ~/.ssh/id_ed25519.pub
168+
```
169+
170+
如果要删除 RSA 加密的密钥对,将上面的 `ed25519` 改为 `rsa` 即可。
171+
172+
### 生成 SSH 密钥对
173+
174+
参见[上文](#2-生成-ssh-密钥对)
155175

156176
## 4. 使用 VS Code 的 Remote 插件进行远程开发
157177

0 commit comments

Comments
 (0)