Coder Social home page Coder Social logo

mssh's Introduction

This is multissh golang repo

This is useful if you work on bunch of server ( in my case like 200 ) and not able to install some manager system like ansiable. ( I have puppet, but puppet is so slow )

Usually if we need quick run command in multiable server, we might do this:

for host in `cat hostsfile`; do
  echo $host
  ssh $host "/usr/bin/sudo ifconfig|grep inet"
done

If you have less then 10 servers, it's fine, but if you have more, more and more in the future...

This is very light and make it super fast.

The only thing you need to do is like that:

in your hosts file

hostname1.com
hostname2.net:20

It's able to detect if you have different port running sshd, default is 22 if you don't add :port

package main

import (
    "flag"
    "github.com/kiyor/mssh"
)

var (
    file *string = flag.String("hostsfile", "", "use hostsfile")
    cmd *string = flag.String("cmd", "hostname", "execute command")
)

func main() {
    flag.Parse()
    var hosts []string

    hosts = mssh.GetHostsByFile(*file)

    var conf mssh.Conf
    conf.User = "kiyor"
    conf.Key = "/home/kiyor/.ssh/id_rsa"
    conf.Command = *cmd
    mssh.Ssh(hosts, conf)
    }
./yourbinary -hostsfile host -cmd "ifconfig|grep inet"

That's all, it will send 24 request at same time. It's lite, it's quick, you don't need full path, and support nohup.out

some option

conf.Sudo = false //option default=false                                           
conf.Debug = false //option default=false
conf.Workers = 24 //option default=24
conf.Background = false //option default=false

mssh's People

Contributors

anuaimi avatar kiyor avatar

Watchers

 avatar  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.