Repository is archived
No commit activity in last 3 years
No release in over 3 years
There's a lot of open issues
An SSHKit backend that allows you to execute interactive commands on your servers.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 12.0.0
~> 3.6.0

Runtime

~> 1.12
 Project Readme

SSHKit::Interactive

Gem Version Build Status

An SSHKit backend that allows you to execute interactive commands on your servers. Remote commands that you might want to use this for:

  • A Rails console
  • A text editor
  • less
  • etc.

Installation

Add this line to your application's Gemfile:

gem 'sshkit-interactive', require: false

And then execute:

$ bundle

If you're using Capistrano, add the following to your Capfile:

require 'sshkit/interactive'

Usage

Running interactive commands will make a system call to ssh under the hood.

DSL

Using the DSL, simply put the command within the run_interactively block. In Capistrano, it might look something like this:

namespace :rails do
  desc "Run Rails console"
  task :console do
    run_interactively primary(:app) do
      execute(:rails, :console)
    end
  end
end

It is also possible to set directory and user the Capistrano way:

namespace :rails do
  desc "Run Rails console"
  task :console do
    run_interactively primary(:app) do
      within current_path do
        as user: :foobar do
          execute(:rails, :console)
        end
      end
    end
  end
end

And it is possible to set the shell to be used:

namespace :foo do
  task :bar do
    run_interactively primary(:app), shell: '/bin/bash' do
      ...
    end
  end
end

### Manually setting the backend

Use the [interactive backend](lib/sshkit/interactive/backend.rb) and execute commands as normal:

```ruby
SSHKit.config.backend = SSHKit::Interactive::Backend
hosts = %w{my.server.com}
on hosts do |host|
  execute(:vim)
end

Contributing

  1. Fork it
  2. Clone it
  3. Create your feature branch (git checkout -b my-new-feature)
  4. Commit your changes (git commit -am 'Add some feature')
  5. Push to the branch (git push origin my-new-feature)
  6. Create a new Pull Request