|
1 | 1 | # sshpro
|
2 |
| -批量管理工具,阉割版ansible |
| 2 | +批量管理工具,阉割版ansible,支持批量执行命令以及批量复制文件和文件夹 |
| 3 | + |
| 4 | +主机与被管理机器无需安装任何依赖,也不用配置互信,直接使用即可 |
3 | 5 |
|
4 | 6 | ## 使用
|
5 | 7 | 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 | +``` |
7 | 15 |
|
8 |
| -当前目录下会生成可执行文件sshpro,将文件链接到bin下:`ln -sv $PWD/sshpro /bin/sshpro` |
| 16 | +3. (可选,如果需要使用配置文件则需要配置)将配置文件模板复制到$HOME下 `cp .sshpro.yaml $HOME`,然后根据自己的情况修改模板 |
9 | 17 |
|
10 | 18 | ### 查看使用帮助
|
11 | 19 |
|
@@ -38,3 +46,47 @@ Flags:
|
38 | 46 |
|
39 | 47 | Use "sshpro [command] --help" for more information about a command.
|
40 | 48 | ```
|
| 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