Project

simple_ssh

0.0
No commit activity in last 3 years
No release in over 3 years
simple_ssh is a simple wrapper around the net-ssh gem. * You want to execute a list of commands on a list of hosts using ssh? * You want to analyze the results within a script? If your answers for these questions are yes then simple_ssh is for you.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 2.13
~> 3.10

Runtime

~> 2.0
 Project Readme

SimpleSSH¶ ↑

home

github.com/szuecs/simple_ssh

DESCRIPTION¶ ↑

simple_ssh is a simple wrapper around the net-ssh gem.

  • You want to execute a list of commands on a list of hosts using ssh?

  • You want to analyze the results within a script?

If your answers for these questions are yes then simple_ssh is for you.

Examples¶ ↑

Configuration¶ ↑

  • Simple configuration of command list execution by hosts using a block.

    ssh = SimpleSsh::SimpleSSH.configure do |cfg|
      cfg.user = "root"
      cfg.hosts << "192.168.143.153"
      cfg.cmds  << "whoami"
      cfg.cmds  << "id"
      cfg.keys  << "~/.ssh/id_rsa"
    end
    ssh.execute #=> {"192.168.143.153"=>{"whoami"=>"root", "id"=>"uid=0(root) gid=0(root) groups=0(root)"}}
    puts ssh
    #192.168.143.153:
    #        whoami: root
    #        id: uid=0(root) gid=0(root) groups=0(root)
    
  • Configuration by dictionary or block or both

    ssh = SimpleSsh::SimpleSSH.configure(:cmds => ["hostname"], :user => "root") do |cfg|
      cfg.hosts << "192.168.143.153"
      cfg.cmds  << "whoami"
      cfg.keys  << "~/.ssh/id_rsa"
    end
    

Command execution¶ ↑

  • Execute the configured hosts and commands

    ssh.execute
    
  • Execute a block

    ssh.execute do |ch|
      ch.cmds << "echo yeaha"
      ch.cmds << "echo yeaha | openssl dgst -sha1"
    end
    

Using results¶ ↑

  • Get results by hosts dictionary

    ssh.result_by_host["192.168.143.153"] #=> {"hostname"=>"foreman-squeeze", "whoami"=>"root"}
    
  • Get results by cmd dictionary

    ssh.result_by_cmd["whoami"] #=> {"192.168.143.153"=>"root"}
    
  • Dump yaml

    ssh.to_yaml #=> "--- \n192.168.143.153: \n  hostname: foreman-squeeze\n  whoami: root\n"
    
  • Dump csv

    ssh.to_csv(";") #=> "host;cmd;result\n192.168.143.153;hostname;foreman-squeeze\n192.168.143.153;whoami;root"
    

REQUIREMENTS¶ ↑

  • net-ssh

INSTALL¶ ↑

% sudo gem install simple_ssh

AUTHORS¶ ↑

Sandor Szücs, sandor.szuecs@fu-berlin.de

LICENSE¶ ↑

See LICENSE file.