rye / 0.7.4
| Short description: | Run SSH commands on a bunch of machines safely and in parallel | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Category: | Library/Net | ||||||||||||||||
| Status: | beta | ||||||||||||||||
| Created: | 2009-04-05 02:50:24 GMT | ||||||||||||||||
| Last update: | 2009-06-04 10:12:15 GMT | ||||||||||||||||
| Owner: | delano (Projects of this owner) | ||||||||||||||||
| Homepage: | http://github.com/delano/rye | ||||||||||||||||
| Download: | http://github.com/delano/rye/tarball/latest | ||||||||||||||||
| License: | BSD-type | ||||||||||||||||
| Dependency: |
|
||||||||||||||||
| Description: | Rye - v0.7Safely run SSH commands on a bunch of machines at the same time (from Ruby). Rye is similar to Rush but everything happens over SSH (no HTTP daemon) and the default settings are less powerful (for safety). For example, file globs and the "rm" command are disabled so unless otherwise specified, you can’t do this: rbox.rm(’-rf’, ’/etc/**/*’). InstallationOne of:
$ sudo gem install rye
$ sudo gem install delano-rye --source http://gems.github.com/
$ git clone git://github.com/delano/rye.git
See bin/try for examples! EXAMPLE 1 — SSH AuthorizationDoes it annoy you to manually authorize remote SSH accounts? Rye can help! Enable passwordless logins to HOST1 and HOST2:
$ rye authorize HOST1 HOST2
This will copy your public SSH keys to the ~/.ssh/authorized_keys and ~/.ssh/authorized_keys2 files on the remote machine(s). See rye -h for more info EXAMPLE 2 — Basic Usage
rbox = Rye::Box.new('localhost')
rbox.uptime # => 11:02 up 16:01, 3 users
rbox['/usr/bin'].pwd # => /usr/bin
You can specify environment variables
rbox.setenv(:RYE, "Forty Creek")
rbox.env # => ['HOME=/home/rye', 'RYE=Forty Creek', ...]
EXAMPLE 3 — Accessing Multiple Machines
rset = Rye::Set.new
rbox = Rye::Box.new
rset.add_boxes(rbox, 'localhost') # Add boxes as hostnames or objects
Calling methods on Rye::Set objects is very similar to calling them on Rye::Box objects. In fact, it’s identical:
p rset.uptime # => [[14:19:02 up 32 days, 19:35 ...], [14:19:02 up 30 days, 01:35]]
p rset['/etc'].ls # => [['file1', 'file2', ...], ['life1', 'life2', ...]]
EXAMPLE 4 — FILE TRANSFERS
rbox = Rye::Box.new("localhost", :info => true)
dir_upload = "#{Rye.sysinfo.tmpdir}/rye-upload/"
dir_download = "#{Rye.sysinfo.tmpdir}/rye-download/"
rbox.upload("#{RYE_HOME}/README.rdoc",
"#{RYE_HOME}/LICENSE.txt", dir_upload)
applejack = StringIO.new("Some in-memory content")
rbox.upload(applejack, "#{dir_upload}/applejack.txt")
p rbox.ls(dir_upload) # => [README.rdoc, LICENSE.txt, applejack.txt]
p rbox.cat("#{dir_upload}/applejack.txt") # => "Some in-memory content"
filecontent = StringIO.new
rbox.download("#{dir_upload}/applejack.txt", filecontent)
p filecontent.read
About Safe-ModeIn safe-mode:
Why? In safe-mode, all command arguments are escaped which turns all arguments into their literal values. Using a Ruby interface to execute shell commands is pretty awesome, particularly to run them on several machines simultaneously. That’s a lot of power and it’s potentially very dangerous. That’s why Rye disables this stuff by default. There’s probably a way to do it safely but it’s not obvious yet (to me). If you have any ideas, I’d love to hear them! Command WhitelistRye permits only a limited number of system commands to be run. This default whitelist is defined in Rye::Cmd but you can add your own commands as you please (see Example 3). Dependencies
Known IssuesThis list will grow. If you find one let me know!
Thanks
More InfoCredits
LicenseSee: LICENSE.txt |
||||||||||||||||
| Versions: | [0.8.5 (2009-07-16)] [0.8.4 (2009-07-01)] [0.7.4 (2009-06-04)] [0.6.2 (2009-04-30)] [0.5.0 (2009-04-18)] [0.3.1 (2009-04-05)] | ||||||||||||||||