Skip to content

Commit 01a5359

Browse files
committed
docs: enhance language support and improve documentation clarity
- Add Simplified Chinese as an option in the language selection - Improve the phrasing of sentences for clarity in the GitHub Action description - Update instructions for enabling synchronous execution for multiple hosts - Clarify the default behavior for the cipher option - Change the wording for SSH command execution to enhance readability - Update the username in the example to a specific value - Revise instructions for copying SSH keys to include installation steps for the `clip` command - Adjust the phrasing for security practices regarding private key protection - Update the license statement to specify the MIT license more clearly - Change section titles for better consistency and clarity across languages Signed-off-by: appleboy <[email protected]>
1 parent d99ccf8 commit 01a5359

File tree

2 files changed

+95
-61
lines changed

2 files changed

+95
-61
lines changed

README.zh-cn.md

Lines changed: 73 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# 🚀 用于 GitHub Actions 的 SSH
22

3-
[English](./README.md) | [繁體中文](./README.zh-tw.md)
3+
[English](./README.md) | [繁體中文](./README.zh-tw.md) | 简体中文
44

5-
[GitHub Action](https://github.com/features/actions) 用于执行远程 SSH 命令
5+
一个用于执行远程 SSH 命令的 [GitHub Action](https://github.com/features/actions)
66

77
![ssh workflow](./images/ssh-workflow.png)
88

@@ -12,7 +12,7 @@
1212

1313
## 输入变量
1414

15-
更详细的信息,请参考 [action.yml](./action.yml)
15+
有关更详细的信息,请参阅 [action.yml](./action.yml)
1616

1717
| 输入参数 | 描述 | 默认值 |
1818
| ------------------------- | ----------------------------------------------------- | ------ |
@@ -22,9 +22,9 @@
2222
| username | SSH 用户名 | |
2323
| password | SSH 密码 | |
2424
| protocol | SSH 协议版本(tcp, tcp4, tcp6) | tcp |
25-
| sync | 如果有多个主机,启用同步执行 | false |
25+
| sync | 如果指定了多个主机,则启用同步执行 | false |
2626
| use_insecure_cipher | 使用不安全的密码算法 | false |
27-
| cipher | 允许的密码算法。如果未指定,则使用适当的算法 | |
27+
| cipher | 允许的密码算法。如果未指定,则使用适当的默认值 | |
2828
| timeout | SSH 连接到主机的超时时间 | 30s |
2929
| command_timeout | SSH 命令的超时时间 | 10m |
3030
| key | SSH 私钥的内容,例如 ~/.ssh/id_rsa 的原始内容 | |
@@ -54,7 +54,7 @@
5454

5555
## 使用方法
5656

57-
执行远程 SSH 命令
57+
执行远程 SSH 命令
5858

5959
```yaml
6060
name: remote ssh command
@@ -68,71 +68,88 @@ jobs:
6868
uses: appleboy/[email protected]
6969
with:
7070
host: ${{ secrets.HOST }}
71-
username: ${{ secrets.USERNAME }}
71+
username: linuxserver.io
7272
password: ${{ secrets.PASSWORD }}
7373
port: ${{ secrets.PORT }}
7474
script: whoami
7575
```
7676
77-
画面输出
77+
输出:
7878
7979
```sh
8080
======CMD======
8181
whoami
8282
======END======
83-
out: ***
83+
linuxserver.io
8484
===============================================
8585
✅ Successfully executed commands to all hosts.
8686
===============================================
8787
```
8888

8989
### 设置 SSH 密钥
9090

91-
请在创建 SSH 密钥并使用 SSH 密钥时遵循以下步骤。最佳做法是在本地机器上创建 SSH 密钥而不是远程机器上。请使用 Github Secrets 中指定的用户名登录。生成 RSA 密钥:
91+
请按照以下步骤创建和使用 SSH 密钥。
92+
最佳做法是在本地机器上创建 SSH 密钥,而不是在远程机器上。
93+
使用 GitHub Secrets 中指定的用户名登录并生成 RSA 密钥对:
9294

9395
### 生成 RSA 密钥
9496

9597
```bash
96-
ssh-keygen -t rsa -b 4096 -C [email protected]
98+
ssh-keygen -t rsa -b 4096 -C "[email protected]"
9799
```
98100

99101
### 生成 ed25519 密钥
100102

101103
```bash
102-
ssh-keygen -t ed25519 -a 200 -C [email protected]
104+
ssh-keygen -t ed25519 -a 200 -C "[email protected]"
103105
```
104106

105107
将新生成的密钥添加到已授权的密钥中。详细了解已授权的密钥请点[此处](https://www.ssh.com/ssh/authorized_keys/)
106108

107109
### 将 RSA 密钥添加到已授权密钥中
108110

109111
```bash
110-
cat .ssh/id_rsa.pub | ssh b@B cat >> .ssh/authorized_keys
112+
cat .ssh/id_rsa.pub | ssh b@B 'cat >> .ssh/authorized_keys'
111113
```
112114

113115
### 将 ed25519 密钥添加到已授权密钥中
114116

115117
```bash
116-
cat .ssh/id_ed25519.pub | ssh b@B cat >> .ssh/authorized_keys
118+
cat .ssh/id_ed25519.pub | ssh b@B 'cat >> .ssh/authorized_keys'
117119
```
118120

119-
复制私钥内容,然后将其粘贴到 Github Secrets 中。
121+
复制私钥内容,然后将其粘贴到 GitHub Secrets 中。
120122

121-
### 复制 rsa 私钥内容
123+
### 复制 RSA 私钥内容
124+
125+
在复制私钥之前,按照以下步骤安装 `clip` 命令:
122126

123127
```bash
124-
clip < ~/.ssh/id_rsa
128+
# Ubuntu
129+
sudo apt-get install xclip
130+
```
131+
132+
复制私钥:
133+
134+
```bash
135+
# macOS
136+
pbcopy < ~/.ssh/id_rsa
137+
# Ubuntu
138+
xclip < ~/.ssh/id_rsa
125139
```
126140

127141
### 复制 ed25519 私钥内容
128142

129143
```bash
130-
clip < ~/.ssh/id_ed25519
144+
# macOS
145+
pbcopy < ~/.ssh/id_ed25519
146+
# Ubuntu
147+
xclip < ~/.ssh/id_ed25519
131148
```
132149

133150
有关无需密码登录 SSH 的详细信息,请[见该网站](http://www.linuxproblem.org/art_9.html)
134151

135-
**来自读者的注意事项** 根据您的 SSH 版本,您可能还需要进行以下更改:
152+
**注意**:根据您的 SSH 版本,您可能还需要进行以下更改:
136153

137154
- 将公钥放在 `.ssh/authorized_keys2`
138155
-`.ssh` 的权限更改为 700
@@ -146,19 +163,19 @@ clip < ~/.ssh/id_ed25519
146163
ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey]
147164
```
148165

149-
请确保您所选择的密钥算法得到支持。在 Ubuntu 20.04 或更高版本上,您必须明确允许使用 SSH-RSA 算法。请在 OpenSSH 守护进程文件中添加以下行(它可以是 `/etc/ssh/sshd_config``/etc/ssh/sshd_config.d/` 中的一个附加文件):
166+
请确保您所选择的密钥算法得到支持。在 Ubuntu 20.04 或更高版本上,您必须明确允许使用 ssh-rsa 算法。请在 OpenSSH 守护进程文件中添加以下行(它可以是 `/etc/ssh/sshd_config``/etc/ssh/sshd_config.d/` 中的一个附加文件):
150167

151168
```bash
152169
CASignatureAlgorithms +ssh-rsa
153170
```
154171

155-
或者,`Ed25519` 密钥在 OpenSSH 中默认被接受。如果需要,您可以使用它来替代 RSA
172+
或者,`ed25519` 密钥在 OpenSSH 中默认被接受。如果需要,您可以使用它来替代 RSA
156173

157174
```bash
158-
ssh-keygen -t ed25519 -a 200 -C [email protected]
175+
ssh-keygen -t ed25519 -a 200 -C "[email protected]"
159176
```
160177

161-
### Example
178+
### 示例
162179

163180
#### 使用密码执行远程 SSH 命令
164181

@@ -203,14 +220,27 @@ ssh-keygen -t ed25519 -a 200 -C ”[email protected]
203220
204221
![result](./images/output-result.png)
205222
223+
#### 从文件执行命令
224+
225+
```yaml
226+
- name: file commands
227+
uses: appleboy/[email protected]
228+
with:
229+
host: ${{ secrets.HOST }}
230+
username: ${{ secrets.USERNAME }}
231+
key: ${{ secrets.KEY }}
232+
port: ${{ secrets.PORT }}
233+
script_path: scripts/script.sh
234+
```
235+
206236
#### 多台主机
207237
208238
```diff
209239
- name: multiple host
210240
uses: appleboy/[email protected]
211241
with:
212-
- host: foo.com
213-
+ host: foo.com,bar.com
242+
- host: "foo.com"
243+
+ host: "foo.com,bar.com"
214244
username: ${{ secrets.USERNAME }}
215245
key: ${{ secrets.KEY }}
216246
port: ${{ secrets.PORT }}
@@ -219,27 +249,16 @@ ssh-keygen -t ed25519 -a 200 -C ”[email protected]
219249
ls -al
220250
```
221251
222-
#### Commands from a file
223-
224-
```yaml
225-
- name: file commands
226-
uses: appleboy/[email protected]
227-
with:
228-
host: ${{ secrets.HOST }}
229-
username: ${{ secrets.USERNAME }}
230-
key: ${{ secrets.KEY }}
231-
port: ${{ secrets.PORT }}
232-
script_path: scripts/script.sh
233-
```
252+
默认的 `port` 值是 `22`。
234253

235254
#### 多个不同端口的主机
236255

237256
```diff
238257
- name: multiple host
239258
uses: appleboy/[email protected]
240259
with:
241-
- host: foo.com
242-
+ host: foo.com:1234,bar.com:5678
260+
- host: "foo.com"
261+
+ host: "foo.com:1234,bar.com:5678"
243262
username: ${{ secrets.USERNAME }}
244263
key: ${{ secrets.KEY }}
245264
script: |
@@ -253,7 +272,7 @@ ssh-keygen -t ed25519 -a 200 -C ”[email protected]
253272
- name: multiple host
254273
uses: appleboy/[email protected]
255274
with:
256-
host: foo.com,bar.com
275+
host: "foo.com,bar.com"
257276
+ sync: true
258277
username: ${{ secrets.USERNAME }}
259278
key: ${{ secrets.KEY }}
@@ -263,14 +282,14 @@ ssh-keygen -t ed25519 -a 200 -C ”[email protected]
263282
ls -al
264283
```
265284

266-
#### 将环境变量传递到 Shell 脚本
285+
#### 将环境变量传递到 shell 脚本
267286

268287
```diff
269288
- name: pass environment
270289
uses: appleboy/[email protected]
271290
+ env:
272-
+ FOO: BAR
273-
+ BAR: FOO
291+
+ FOO: "BAR"
292+
+ BAR: "FOO"
274293
+ SHA: ${{ github.sha }}
275294
with:
276295
host: ${{ secrets.HOST }}
@@ -279,19 +298,19 @@ ssh-keygen -t ed25519 -a 200 -C ”[email protected]
279298
port: ${{ secrets.PORT }}
280299
+ envs: FOO,BAR,SHA
281300
script: |
282-
echo I am $FOO
283-
echo I am $BAR
284-
echo sha: $SHA
301+
echo "I am $FOO"
302+
echo "I am $BAR"
303+
echo "sha: $SHA"
285304
```
286305

287306
_在 `env` 对象中,您需要将每个环境变量作为字符串传递,传递 `Integer` 数据类型或任何其他类型可能会产生意外结果。_
288307

289308
#### 如何使用 `ProxyCommand` 连接远程服务器?
290309

291310
```bash
292-
+———+ +-———+ +————+
293-
| Laptop | <> | Jumphost | <> | FooServer |
294-
+———+ +-———+ +————+
311+
+--------+ +----------+ +-----------+
312+
| Laptop | <--> | Jumphost | <--> | FooServer |
313+
+--------+ +----------+ +-----------+
295314
```
296315

297316
在您的 `~/.ssh/config` 文件中,您会看到以下内容。
@@ -329,9 +348,9 @@ Host FooServer
329348
ls -al
330349
```
331350

332-
#### 如何保护私钥?
351+
#### 保护私钥
333352

334-
密码短语通常用于加密私钥。这使得攻击者无法单独使用密钥文件。文件泄露可能来自备份或停用的硬件,黑客通常可以从受攻击系统中泄露文件。因此,保护私钥非常重要
353+
密码短语通常用于加密私钥。这使得密钥文件本身对攻击者无用。文件泄露可能来自备份或停用的硬件,黑客通常可以从受攻击系统中泄露文件。
335354

336355
```diff
337356
- name: ssh key passphrase
@@ -351,10 +370,10 @@ Host FooServer
351370

352371
设置 SSH 主机指纹验证可以帮助防止中间人攻击。在设置之前,运行以下命令以获取 SSH 主机指纹。请记得将 `ed25519` 替换为您适当的密钥类型(`rsa`、 `dsa`等),而 `example.com` 则替换为您的主机。
353372

354-
现代 OpenSSH 版本中,需要提取的**默认密钥**类型是 `rsa`(从版本 5.1 开始)、`ecdsa`(从版本 6.0 开始)和 `ed25519`(从版本 6.7 开始)。
373+
在现代 OpenSSH 版本中,默认提取的密钥类型是 `rsa`(从版本 5.1 开始)、`ecdsa`(从版本 6.0 开始)和 `ed25519`(从版本 6.7 开始)。
355374

356375
```sh
357-
ssh example.com ssh-keygen -l -f /etc/ssh/ssh_host_ed25519_key.pub | cut -d ’ ‘ -f2
376+
ssh example.com ssh-keygen -l -f /etc/ssh/ssh_host_ed25519_key.pub | cut -d ' ' -f2
358377
```
359378

360379
现在您可以调整您的配置:
@@ -379,4 +398,4 @@ ssh example.com ssh-keygen -l -f /etc/ssh/ssh_host_ed25519_key.pub | cut -d ’
379398

380399
## 授权方式
381400

382-
本项目中的脚本和文档采用 [MIT](LICENSE) 许可证 发布。
401+
本项目中的脚本和文档采用 [MIT 许可证](LICENSE) 发布。

README.zh-tw.md

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# 🚀 GitHub Actions 的 SSH
22

3-
[English](./README.md) | [简体中文](./README.zh-cn.md)
3+
[English](./README.md) | 繁體中文 | [简体中文](./README.zh-cn.md)
44

55
[GitHub Action](https://github.com/features/actions) 用於執行遠端 SSH 命令。
66

@@ -68,7 +68,7 @@ jobs:
6868
uses: appleboy/[email protected]
6969
with:
7070
host: ${{ secrets.HOST }}
71-
username: ${{ secrets.USERNAME }}
71+
username: linuxserver.io
7272
password: ${{ secrets.PASSWORD }}
7373
port: ${{ secrets.PORT }}
7474
script: whoami
@@ -80,7 +80,7 @@ jobs:
8080
======CMD======
8181
whoami
8282
======END======
83-
out: ***
83+
linuxserver.io
8484
===============================================
8585
✅ Successfully executed commands to all hosts.
8686
===============================================
@@ -120,19 +120,34 @@ cat .ssh/id_ed25519.pub | ssh b@B 'cat >> .ssh/authorized_keys'
120120

121121
### 複製 rsa 私鑰內容
122122

123+
在複製私鑰之前,請按照以下說明安裝 `clip` 命令:
124+
125+
```bash
126+
# Ubuntu
127+
sudo apt-get install xclip
128+
```
129+
130+
複製私鑰:
131+
123132
```bash
124-
clip < ~/.ssh/id_rsa
133+
# macOS
134+
pbcopy < ~/.ssh/id_rsa
135+
# Ubuntu
136+
xclip < ~/.ssh/id_rsa
125137
```
126138

127139
### 複製 ed25519 私鑰內容
128140

129141
```bash
130-
clip < ~/.ssh/id_ed25519
142+
# macOS
143+
pbcopy < ~/.ssh/id_ed25519
144+
# Ubuntu
145+
xclip < ~/.ssh/id_ed25519
131146
```
132147

133148
有關無需密碼登錄 SSH 的詳細信息,請[參見該網站](http://www.linuxproblem.org/art_9.html)
134149

135-
**來自讀者的注意事項** 根據您的 SSH 版本,您可能還需要進行以下更改:
150+
**注意**:根據您的 SSH 版本,您可能還需要進行以下更改:
136151

137152
- 將公鑰放在 `.ssh/authorized_keys2`
138153
-`.ssh` 的權限更改為 700
@@ -203,7 +218,7 @@ ssh-keygen -t ed25519 -a 200 -C "[email protected]"
203218
204219
![result](./images/output-result.png)
205220
206-
#### Commands from a file
221+
#### 從文件中執行命令
207222
208223
```yaml
209224
- name: file commands

0 commit comments

Comments
 (0)