Remotus provides a simple ruby interface for pooling remote SSH and WinRM connections and managing remote credentials. Custom authentication stores may be added to allow remote credentials to be automatically retrieved.


Add this line to your application's Gemfile:

gem 'remotus'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install remotus


# Initialize a new connection pool to remotehost.local and auto-determine whether to use SSH or WinRM
connection = Remotus.connect("remotehost.local")

# Initialize a new connection pool to remotehost.local with a defined protocol and port
connection = Remotus.connect("remotehost.local", proto: :ssh, port: 2222)

# Initialize a new connection pool to remotehost.local with a defined protocol and port and arbitrary metadata
connection = Remotus.connect("remotehost.local", proto: :ssh, port: 2222, company: "Test Corp", location: "Oslo")

# Create a credential for the new connection pool
connection.credential ="username", "password")

# Run a command on the remote host
result ="hostname")

# => "hostname"

# => "remotehost.local\n"

# => ""

# => "remotehost.local\n"

# => 0

# Run a command on the remote host with sudo (Linux only, requires password to be specified)
result ="ls /root", sudo: true)

# Run a script on the remote host
connection.run_script("/local/", "/remote/path/")

# Run a script on the remote host with arguments
connection.run_script("/local/", "/remote/path/", "arg1", "arg2")

# Upload a file to the remote host
connection.upload("/local/file.txt", "/remote/path/file.txt")

# Download a file from the remote host"/remote/path/file.txt", "/local/file.txt")

Full documentation is available in the Remotus GitHub Pages.

Extending Remotus

Remotus may be extended by adding more authentication stores to gather remote credential data from centralized services.

Authentication Stores

More authentication stores may be added by creating a new class that inherits from Remotus::Auth::Store and implementing the credential method. The credential method should receive a Remotus::SshConnection or Remotus::WinrmConnection and an options hash and return a Remotus::Auth::Credential or nil if no credential can be found.

Once a new authentication store has been defined, ensure it is used by Remotus by adding it to Remotus::Auth.stores.

# Define a new authentication store that returns "<hostname>_password" for any connection
# This is for demonstration purposes only, please do not use any password with your hostname or "password" in it :)
require "remotus"

class SimpleStore < Remotus::Auth::Store
  def credential(connection, **options)

# Add the authentication store to the array of existing authentication stores
Remotus::Auth.stores <<

# Use the authentication store
connection = Remotus.connect("remotehost.local", proto: :ssh)
# => "remotehost.local_password"


After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and the created tag, and push the .gem file to


Bug reports and pull requests are welcome on GitHub at


The gem is available as open source under the terms of the MIT License.