Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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.
- Host: GitHub
- URL: https://github.com/szuecs/simple_ssh
- Owner: szuecs
- License: mit
- Created: 2011-09-02T19:30:19.000Z (over 13 years ago)
- Default Branch: master
- Last Pushed: 2012-02-22T21:38:21.000Z (almost 13 years ago)
- Last Synced: 2024-04-27T03:26:48.327Z (8 months ago)
- Language: Ruby
- Homepage:
- Size: 93.8 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.rdoc
- Changelog: CHANGELOG.rdoc
- License: LICENSE
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 commandsssh.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 dictionaryssh.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.