Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
CLI utility to bookmark multiple ssh connections with hierarchy. My first ruby script :)
Ruby

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
autotest
bin
completions
features
lib
spec
.autotest
.gitignore
.rspec
Gemfile
Gemfile.lock
README.rdoc
Rakefile
gpl-2.0.txt
runssh.gemspec

README.rdoc

Introduction

A CLI utility to bookmark ssh connections with hierarchy and run various ssh commands on these bookmarks. Supported operations are:

  • Login

  • Scp

  • Copy ssh key

  • Run remote command

  • Create local tunnel

This requires you to have the ssh and scp binaries in your path and optionally the ssh-copy-id binary (for copying ssh key).

Installation

You must have ruby and rubygems installed and then run: gem install runssh

Zsh Completion

Finally we have a fully functional zsh completion. It includes options, subcommands and path completions.

To install just copy the completions/_runssh file which is included in the gem (run gem contents runssh to get the path to this file) to one of the directories in your $fpath.

Note: I don't really know how it works. I just read some docs, looked at a few samples (mainly _cvs) and went through a lot of trial and error until it worked for me. I hope it'll work for you as well :)

Bash Completion

Bash completion is not as complete as the zsh one. It only supports path completions. Since I'm now using zsh, I have very little interest in improving this. Anybody willing to contribute?

To install just copy the completions/runssh_comp.sh file which is included in the gem (run gem contents runssh to get the path to this file) to /etc/bash-completion.d/ (or wherever your bash completion files reside).

Usage

For usage run runssh without arguments.

Host Definition

Host definition is a collection of attributes that help us define a host bookmark. The only required attribute is a hostname. All other attributes (login, remote command, local tunnel info, ssh option, etc) is optional.

Bookmarks

The bookmarks consists of a host definition inside nested groups. These groups could hold other groups or host definitions. Here is an example of bookmarks:

customer1:
    location1:
        host1
        host2
    location2:
        host3
        host4
        sublocation:
            host5
customer2:
    office:
        host1
        ...

You can decide to arrange your bookmarks by customers and/or location and/or internal/external addresses etc. To access a host definition you specify the full path to that host. In the above example to access host2 (e.g, print it's definition) run:

runssh print customer1 location1 host2

requirements:

Dependencies (runtime and development) are specified in runssh.gemspec. When installing through gem, dependencies will be installed by default. For development, you need to install bundler 1.0.x and run (inside the project directory):

bundle install

License

This program is distributed under the GPL v2 license.

History

0.1.0

  • Initial release. Simple bookmarks (host and user),only shell operation supported.

0.1.1

  • Improved docs.

0.2.0

  • New config file structure - with config file version discovery and update.

  • Some output improvements.

  • Added support for remote commands.

  • Rewrite of some of the elements. The next release will introduce further rewrite.

  • Added support for ruby 1.9.2.

0.2.1

  • Fixed docs.

0.2.2

  • Enabled overriding hostname when invoking shell (Could be used to bookmark a host with changing addresses - e.g. in EC2)

  • Enabled definition of (local) ssh tunneling. Currently only in the shell command.

0.4 (0.3)

(Originally this was meant to be 0.3 but I made a mistake in the version file and there's no going back …)

  • The print subcommand now prints the local tunnel if defined.

  • It's possible to bookmark (local) tunnels.

  • Remote command are run with pseudo terminal (ssh -t) by default. Can be disabled with -T.

  • Added (unsafe) option for deleting conflicting host key - The conflicting line must be specified manually (probably from the error message in the previous command), and currently we only deal with ~/.ssh/known_hosts file.

  • Added ssh options support. These could be specified when saving or when running shell. As an unsafe shortcut, there is an option to connect to a host without verifying the key. This is mainly useful for local virtual machines, or similar occasion where security is not an issue.

  • Implemented copying public key to remote host's authorized_keys file (via ssh-copy-id).

  • Documentation fixes.

  • Changed behavior upon prompt cancellation (in delete and import) - It now aborts execution instead of exit 0.

  • Some code refactoring (CLI class).

  • CLI Tests refactorings:

    • Created cucumber features.

    • Fixed tests to test features and not implementations.

0.4.1

  • Doc fixes regarding version skip.

0.4.2

  • If, when exporting, the output file exists, the user is prompted for approval.

  • Completion now works for commands that requires options (e.g. add) even if the required option is not given.

  • Finally - proper zsh completion :)

0.4.3

  • Added missing options/arguments completions to the shell subcommand.

0.5.0

  • Added scp support.

0.5.1

  • Added example to the documentation.

0.5.2

  • Zsh completion now completes the local target.

0.5.3

  • Fixed inconsistency between gemspec and bin/runssh with dependencies versions. I'm using fixed versions so it could be used in default ubuntu which comes with rubygems 1.3.x :(

TODO for 1.0

  • Merge configurations - The default import behaviour should be to merge configuraitons instead of overwriting them. Overwriting them should come as an option.

TODO for later

  • Rename (or move) host definition.

  • Automatic deletion of empty groups.

  • Shell via gateway (connect to a firewall and from there open shell to the host).

Something went wrong with that request. Please try again.