mirror of
https://github.com/shanghai-edu/multissh.git
synced 2025-12-16 13:27:44 +00:00
version 0.1 release
This commit is contained in:
parent
1d08bcf541
commit
37bbc34df8
9 changed files with 294 additions and 57 deletions
81
README.MD
81
README.MD
|
|
@ -31,9 +31,9 @@ go build
|
|||
-j string
|
||||
jsonFile //保存大量主机,包括主机地址,SSH用户名,SSH密码,SSH端口,所需执行的cmd指令文件地址
|
||||
-outTxt bool
|
||||
outTxt (default false) //是否允许把结果保存到文件中,true为允许 false为默认值
|
||||
-t duration
|
||||
timeLimit (default 30) //最大并发访问时间 默认为30s
|
||||
outTxt (default false) //是否允许把结果保存到文件中,文件名为 ssh 连接的主机名(host 或 ip),true为允许 false为默认值
|
||||
-t int
|
||||
timeLimit (default 30) //单个 ssh 会话的最大时间,超过时间命令未执行完则超时 默认为30s
|
||||
-n int
|
||||
numLimit (default 20) //最大并发访问量 默认为20
|
||||
|
||||
|
|
@ -45,86 +45,109 @@ exit
|
|||
```
|
||||
**hostfile 示例**
|
||||
```
|
||||
10.10.15.101
|
||||
10.10.15.102
|
||||
192.168.15.101
|
||||
192.168.15.102
|
||||
```
|
||||
**ipfile 示例**
|
||||
```
|
||||
10.10.15.101-10.10.15.102
|
||||
192.168.15.101-192.168.15.102
|
||||
```
|
||||
|
||||
**ssh.json 示例**
|
||||
``
|
||||
{
|
||||
"SshHosts": [
|
||||
{
|
||||
"Host": "192.168.15.101",
|
||||
"Port": 22,
|
||||
"Username": "admin",
|
||||
"Password": "admin",
|
||||
"CmdFile": "cmd1.txt.example"
|
||||
},
|
||||
{
|
||||
"Host": "192.168.83.40",
|
||||
"Port": 22,
|
||||
"Username": "root",
|
||||
"Password": "root",
|
||||
"CmdFile": "cmd2.txt.example"
|
||||
}
|
||||
]
|
||||
}
|
||||
``
|
||||
|
||||
## 用法
|
||||
#### cmd string & host string
|
||||
```
|
||||
./multissh -cmd "show clock;exit" -hosts "10.10.15.101;10.10.15.102" -u admin -p admin
|
||||
./multissh -cmd "show clock;exit" -hosts "192.168.15.101;192.168.15.102" -u admin -p admin
|
||||
|
||||
10.10.15.101 ssh start
|
||||
192.168.15.101 ssh start
|
||||
sw-1#show clock
|
||||
05:26:40.649 UTC Tue Jun 6 2017
|
||||
sw-1#exit
|
||||
|
||||
10.10.15.101 ssh end
|
||||
192.168.15.101 ssh end
|
||||
|
||||
10.10.15.102 ssh start
|
||||
192.168.15.102 ssh start
|
||||
sw-2#show clock
|
||||
05:24:38.708 UTC Tue Jun 6 2017
|
||||
sw-2#exit
|
||||
|
||||
10.10.15.102 ssh end
|
||||
192.168.15.102 ssh end
|
||||
```
|
||||
|
||||
#### cmdfile & hostfile
|
||||
```
|
||||
./multissh -cmdfile cmd.txt -hostfile host.txt -u admin -p admin
|
||||
|
||||
10.10.15.101 ssh start
|
||||
192.168.15.101 ssh start
|
||||
sw-1#show clock
|
||||
05:29:43.269 UTC Tue Jun 6 2017
|
||||
sw-1#exit
|
||||
|
||||
10.10.15.101 ssh end
|
||||
192.168.15.101 ssh end
|
||||
|
||||
10.10.15.102 ssh start
|
||||
192.168.15.102 ssh start
|
||||
sw-2#show clock
|
||||
05:27:41.332 UTC Tue Jun 6 2017
|
||||
sw-2#exit
|
||||
|
||||
10.10.15.102 ssh end
|
||||
192.168.15.102 ssh end
|
||||
```
|
||||
|
||||
#### ipfile
|
||||
```
|
||||
./multissh -cmdfile cmd.txt -ipfile ip.txt -u admin -p admin
|
||||
|
||||
10.10.15.101 ssh start
|
||||
192.168.15.101 ssh start
|
||||
sw-1#show clock
|
||||
05:29:43.269 UTC Tue Jun 6 2017
|
||||
sw-1#exit
|
||||
|
||||
10.10.15.101 ssh end
|
||||
192.168.15.101 ssh end
|
||||
|
||||
10.10.15.102 ssh start
|
||||
192.168.15.102 ssh start
|
||||
sw-2#show clock
|
||||
05:27:41.332 UTC Tue Jun 6 2017
|
||||
sw-2#exit
|
||||
|
||||
10.10.15.102 ssh end
|
||||
192.168.15.102 ssh end
|
||||
```
|
||||
|
||||
#### ipfile
|
||||
#### ssh.json
|
||||
```
|
||||
./multissh -j jsonSample.json -t 30 -n 20 -outTxt true
|
||||
10.10.15.101 ssh start
|
||||
./multissh -j ssh.json -t 30 -n 20 -outTxt true
|
||||
192.168.15.101 ssh start
|
||||
sw-1#show clock
|
||||
05:29:43.269 UTC Tue Jun 6 2017
|
||||
sw-1#exit
|
||||
|
||||
10.10.15.101 ssh end
|
||||
192.168.15.101 ssh end
|
||||
|
||||
10.10.15.102 ssh start
|
||||
sw-2#show clock
|
||||
05:27:41.332 UTC Tue Jun 6 2017
|
||||
sw-2#exit
|
||||
192.168.83.40 ssh start
|
||||
2017年 06月 09日 星期五 09:33:11 CST
|
||||
2017年 06月 09日 星期五 09:33:14 CST
|
||||
192.168.83.40 ssh end
|
||||
```
|
||||
|
||||
10.10.15.102 ssh end
|
||||
```
|
||||
#### LICENSE
|
||||
Apache License 2.0
|
||||
Loading…
Add table
Add a link
Reference in a new issue