Code Monkey home page Code Monkey logo

go-multi-ssh's Introduction

go-multi-ssh

CC BY-NC-SA 4.0

go-multi

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.

Usage

All three tools share a common set of features

  • -c connection test

    Performs a simple connection test and prints all execution targets.

  • -l none|block|inline label

    Sets 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 source
    • block prints a source label once per block; the next label will be printed after a different host sends text to stdout
    • inline prints a source label for every line

SSH specifics

  • -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 property tag. For any host specified within the index file the systems ssh_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 include

      Includes hosts with the given tag. i.e. mssh -t ubuntu

    • -T to exclude

      Ignores hosts with the given tag. i.e. mssh -T critical

    i.e. given the index file ./ssh_config with

    Host 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

DOCKER specifics

  • -s selector

    Specifies 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"

K8S specifics

  • -s selector

    Specifies 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 namespace

    Specifies the target namespace. i.e. kubectl mexec -n kube-system

License

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

CC BY-NC-SA 4.0

Resources

Icons/Graphics

go-multi-ssh's People

Watchers

 avatar Christian Winkler avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.