Skip to content

Commit 5f1998d

Browse files
authored
Update README.md
1 parent 41901b4 commit 5f1998d

File tree

1 file changed

+55
-3
lines changed

1 file changed

+55
-3
lines changed

README.md

+55-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
11
# sshpro
2-
批量管理工具,阉割版ansible
2+
批量管理工具,阉割版ansible,支持批量执行命令以及批量复制文件和文件夹
3+
4+
主机与被管理机器无需安装任何依赖,也不用配置互信,直接使用即可
35

46
## 使用
57
1. git clone https://github.com/pythonzm/sshpro.git
6-
2. cd sshpro && go build
8+
2. 生成可执行文件
9+
10+
```bash
11+
cd sshpro
12+
go build
13+
ln -sv $PWD/sshpro /bin/sshpro # 将可执行文件链接到/bin目录下,可选
14+
```
715

8-
当前目录下会生成可执行文件sshpro,将文件链接到bin下:`ln -sv $PWD/sshpro /bin/sshpro`
16+
3. (可选,如果需要使用配置文件则需要配置)将配置文件模板复制到$HOME下 `cp .sshpro.yaml $HOME`,然后根据自己的情况修改模板
917

1018
### 查看使用帮助
1119

@@ -38,3 +46,47 @@ Flags:
3846

3947
Use "sshpro [command] --help" for more information about a command.
4048
```
49+
50+
## 部分使用案例
51+
52+
### 批量执行命令(不使用配置文件)
53+
```shell
54+
[root@test sshpro]# sshpro --hosts 10.1.7.239,10.1.7.240 -u root -P 123456 -c uptime
55+
10.1.7.239 | SUCCESS =>
56+
15:49:08 up 3 days, 5:52, 3 users, load average: 0.00, 0.01, 0.05
57+
58+
10.1.7.240 | FAILED => dial tcp 10.1.7.240:22: i/o timeout
59+
```
60+
61+
### 批量执行命令(使用配置文件,需要使用-g参数)
62+
```shell
63+
[root@test sshpro]# sshpro -g centos -c uptime # centos组内主机全部执行uptime命令
64+
10.1.7.239 | SUCCESS =>
65+
15:52:23 up 3 days, 5:56, 3 users, load average: 0.00, 0.01, 0.05
66+
67+
10.1.7.198 | SUCCESS =>
68+
15:52:22 up 93 days, 3:49, 4 users, load average: 0.05, 0.03, 0.00
69+
70+
10.1.7.199 | UNREACHABLE => dial tcp 10.1.7.199:22: connect: no route to host
71+
```
72+
73+
### 批量复制文件(传递文件夹需要-r参数,不使用配置文件)
74+
```
75+
[root@test sshpro]# sshpro copy --hosts 10.1.7.239,10.1.7.238 -u root -P 123456 -s /tmp/aa/a.log -d /tmp/
76+
10.1.7.239 | SUCCESS =>
77+
/tmp/aa/a.log 传输完成
78+
79+
10.1.7.238 | UNREACHABLE => dial tcp 10.1.7.238:22: connect: no route to host
80+
```
81+
82+
### 批量复制文件(传递文件夹需要-r参数,使用配置文件)
83+
```shell
84+
[root@test sshpro]# sshpro copy -g centos -s /tmp/aa/a.log -d /tmp/
85+
10.1.7.198 | SUCCESS =>
86+
/tmp/aa/a.log 传输完成
87+
88+
10.1.7.239 | SUCCESS =>
89+
/tmp/aa/a.log 传输完成
90+
91+
10.1.7.199 | UNREACHABLE => dial tcp 10.1.7.199:22: connect: no route to host
92+
```

0 commit comments

Comments
 (0)