Overview

Rye is a Ruby abstraction for executing shell commands via SSH. By default,
Rye errs on the side of caution by running in “safe-mode” which specifies a
default whitelist of commands and aggressively escapes all command
arguments. For example, file globs and the “rm” command are not available
in safe-mode, so you can't do this: rbox.rm('-rf',
'/etc/*/').

Rye does not require anything to be installed on the server side (other
than an SSH daemon) so it can be run from any machine with Ruby, OpenSSL,
and OpenSSH.

Example 7 – Local processes

For local processes, you can bypass Rye::Box and execute commands
directly with Rye.shell:

Rye.shell :uptime # => 11:02 up 16:01, 3 users

The first argument must be the command name and the remaining arguments are
sent directly as arguments to the command. They're not escaped like
with Rye::Box so you can use the asterisk, environment variables,
pipes, and redirects etc. Also note that you can specify single character
switches as symbols and you can separate arguments or put them into a
single String.

About Safe-Mode

You can't use file globs. This means you can't do this:
rbox.ls('*.rb'). ~ also doesn't work!

You can't use environment variables as arguments. This means you
can't do this: rbox.echo('$HOME'). However,
environment variables are available to the commands you run.

Pipes and operators don't work: |, &&, >, <, ||,
~, etc…

Backticks don't work either: procs=`ps aux`

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 Whitelist

Rye 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

Installation

However, in order to be sure the code you're installing hasn't been
tampered with, it's recommended that you verify the signiture. To do this,
you need to add my public key as a trusted certificate (you only need to do
this once):

# Add the public key as a trusted certificate
# (You only need to do this once)
$ curl -O https://raw.github.com/delano/rye/master/gem-public_cert.pem
$ gem cert --add gem-public_cert.pem

Then, when install the gem, do so with high security:

$ gem install rye -P HighSecurity

If you don't add the public key, you'll see an error like
“Couldn't verify data signature”. If you're still having trouble
let me know and I'll give you a hand.

Contributing

The easiest way to contribute is to open an issue for bugs and feature
requests. I'm also very open to thoughtful and interesting pull requests[github.com/delano/rye/pulls.
Fork and be merry.