go-multi-ssh is a small tool used to execute commands on multiple remote machines. The current feature set allows execution on
- multiple remote hosts via SSH
- multiple pods in a kubernetes cluster
- multiple container on a docker host
While the execution via SSH is done by a standalone program both kubernetes and docker integrates as
plugin kubectl mexec
and docker mexec
respectively.
Any contents streamed via stdout
and stderr
will be captured and printed on the local machine again
using stdout
and stderr
.
All three tools share a common set of features
-
-c
connection testPerforms a simple connection test and prints all execution targets.
-
-l none|block|inline
labelSets a label type to mark the output with the source execution host.
none
omits any output labels; the content will be delivered line-by-line regardless of the sourceblock
prints a source label once per block; the next label will be printed after a different host sends text tostdout
inline
prints a source label for every line
-
-i
index file (defaults to./ssh_config
)Specifies an index file containing target hosts. The index file follows the
ssh_config
file format rules SSH DOCs but has an additional propertytag
. For any host specified within the index file the systemsssh_config
are used for fill missing connection infos. i.e.-
~/.ssh/config
Host * IdentityFile ~/.ssh/%h_id_rsa Host target-host.lan User login
-
./ssh_config
Host target-host.lan
Will lead to a login attempt using
[email protected]
with the key file~/.ssh/target-host.lan_id_rsa
. -
-
Tags
Tags can be used to further narrow down the list of target hosts.
Use :
-
-t
to includeIncludes hosts with the given tag. i.e.
mssh -t ubuntu
-
-T
to excludeIgnores hosts with the given tag. i.e.
mssh -T critical
i.e. given the index file
./ssh_config
withHost gateway.lan Host prox-host-1.lan Tag ubuntu Tag hypervisor Host ubuntu-1.lan Tag ubuntu Host dns.lan Tag ubuntu Tag dns Host dns.iot Tag ubuntu Tag dns Host dns.phone Tag ubuntu Tag dns Host mqtt-broker.iot Tag ubuntu Host home-assistant.iot Tag ubuntu
The following calls will target :
call gateway.lan prox-host-1.lan ubuntu-1.lan dns.lan dns.iot dns.phone home-assistant.iot mqtt-broker.iot mssh -t ubuntu
☐ ☑ ☑ ☑ ☑ ☑ ☑ ☑ mssh -t ubuntu -T hypervisor
☐ ☐ ☑ ☑ ☑ ☑ ☑ ☑ mssh -t dns
☐ ☐ ☐ ☑ ☑ ☑ ☐ ☐ mssh -t hypervisor
☐ ☑ ☐ ☐ ☐ ☐ ☐ ☐ mssh
☑ ☑ ☑ ☑ ☑ ☑ ☑ ☑ -
-
-s
selectorSpecifies a selector to select target containers by filtering them using the container label feature. Docker DOCs. i.e.
docker mexec -s "com.example.foo=bar"
-
-s
selectorSpecifies a selector to select target pods by filtering them using the pod label feature. See Kubernetes DOCs. i.e.
kubectl mexec -s "app.kubernetes.io/component=database"
-
-n
namespaceSpecifies the target namespace. i.e.
kubectl mexec -n kube-system
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.