Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/szuecs/simple_ssh

SimpleSsh is a simple wrapper around the net-ssh gem.
https://github.com/szuecs/simple_ssh

Last synced: 4 days ago
JSON representation

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

Awesome Lists containing this project

README

        

= SimpleSSH
home :: https://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, [email protected]

== LICENSE

See LICENSE file.