multissh并行 SSH 执行工具
multissh
一个简单的并行 SSH 工具,可以批量的对主机通过 SSH 执行命令组合。
支持:
-
并发执行
-
单次执行多条命令
-
ip 地址段自动匹配主机(192.168.0.1-192.168.0.100)
-
ssh 用户名/密码认证
-
ssh key 认证
-
json 格式输出
-
输出到文本,文件名为 host.txt
编译
go get ./...
go build
release
可以直接下载编译好的 release 版本
提供 win64 和 linux64 两个平台的可执行文件
https://github.com/shanghai-edu/multissh/releases/
命令体系
# ./multissh -h
Usage of ./multissh:
-c string
cfg File Path
-ciphers string
ciphers
-cmdfile string
cmdfile path
-cmds string
cmds
-hostfile string
hostfile path
-hosts string
host address list
-ipfile string
ipfile path
-ips string
ip address list
-j print output in json format
-k string
ssh private key
-l In linux mode,multi command combine with && ,such as date&&cd /opt&&ls
-n int
max execute number (default 20)
-outTxt
write result into txt
-p string
password
-port int
ssh port (default 22)
-t int
max timeout (default 30)
-u string
username
-v show version
cmdfile 示例
show clock
hostfile 示例
192.168.31.21
192.168.15.102
ipfile 示例
192.168.15.101-192.168.15.103
192.168.31.21-192.168.31.22
ssh.json 示例
{
"SshHosts": [
{
"Host": "192.168.31.51",
"Port": 22,
"Username": "admin",
"Password": "admin",
"cmds":"show clock;show clock"
},
{
"Host": "192.168.80.131",
"Port": 22,
"Username": "root",
"Password": "",
"key": "./server.key",
"linuxMode": true,
"CmdFile": "cmd2.txt.example"
}
]
}
评论
