I haven't been able to wrangle Net::SSH to do my bidding. "My bidding" in
this case, is maintaining an open channel between commands. I'm using
Net::SSH::Connection::Session#exec for all commands which is like a funky
helper method that opens a new channel each time it's called. This seems to
be okay for one-off commands but changing the directory only works for the
channel it's executed in. The next time exec is called, there's a new
channel which is back in the default (home) directory.

Long story short, the work around is to maintain the current directory
locally and send it with each command.

Open an SSH session with +@rye_host+. This called automatically when you
the first comamnd is run if it's not already connected. Raises a Rye::NoHost exception if +@rye_host+ is not
specified. Will attempt a password login up to 3 times if the initial
authentication fails.

reconnect Disconnect first if already connected. The default

is true. When set to false, connect will do nothing if already connected.

Returns the hash containing the parsed output of "env" on the remote
machine. If the initialize option :getenv was set to false, this
will return an empty hash. This is a lazy loaded method so it fetches the
remote envvars the first time this method is called.

puts rbox.getenv['HOME'] # => "/home/gloria" (remote)

NOTE: This method should not raise an exception under normal circumstances.

Uses the output of "useradd -D" to determine the default home directory.
This returns a GUESS rather than the a user's real home directory.
Currently used only by authorize_keys_remote. Only useful before you've
logged in. Otherwise check $HOME

If STDIN.tty? is true (i.e. if we're connected to a terminal with a human
at the helm), this will open an SSH connection via the regular SSH command
(via a call to system). This requires the SSH command-line executable
(ssh).

If STDIN.tty? is false or run is false, this will return the SSH
command (a String) that would have been run.

NOTE: As of Rye 0.9 you can run interactive
sessions with rye by calling any shell method without arguments.

Supply a block to be called after every command. It's called with one
argument: an instance of Rye::Rap.

When this block is supplied, the command does not raise an exception when
the exit code is greater than 0 (the typical behavior) so the block needs
to check the Rye::Rap object to determine whether an
exception should be raised.

Like batch, except it enables quiet mode before executing the block. After
executing the block, quiet mode is returned back to whichever state it was
previously in. In other words, this method won't enable quiet mode if it
was already disabled.

In quiet mode, the pre and post command hooks are not called. This is used
internally when calling commands like ls to check whether a file
path exists (to prevent polluting the logs).

Reconnect as another user. This is different from su= which executes
subsequent commands via +su -c COMMAND USER+.

newuser The username to reconnect as

NOTE: if there is an open connection, it's disconnected but not reconnected
because it's possible it wasn't connected yet in the first place (if you
create the instance with default settings for example)

Like batch, except it disables safe mode before executing the block. After
executing the block, safe mode is returned back to whichever state it was
previously in. In other words, this method won't enable safe mode if it was
already disabled.