Project

sshelper

0.0
No commit activity in last 3 years
No release in over 3 years
Small application that helps you to automate mundane, remote tasks
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.3
>= 0
>= 0

Runtime

>= 0
 Project Readme

SSHelper

This gem is supposed to make your life easier if you have to do a lot of repetitive tasks over SSH. If you are sick of doing the constant ssh user@example.org, cd /opt/path/to/something, ./start.sh etc, then this tool is for you!

Installation

Install it as follows:

$ gem install sshelper

Usage

After installation, you will have to create a '.sshelper.json' file in your home directory:

$ touch ~/.sshelper.json # or ~/.sshelper.yml for the YAML format

Or, you can use the built in functionality to generate a template:

$ sshelper -t json
# or
$ sshelper -t yaml

Open it in your favorite editor:

$ nano ~/.sshelper.json
# or
$ nano ~/.sshelper.yml

And use the following structure to add labels (for YAML):

my_label1:
    description: View the content of the newest file on example.org and test.com
    servers:
        - host: example.org
          port: 22
          user: root
        - host: test.com
          port: 1234
          user: eddy
    commands:
        - ls -l
        - cat `ls -1rt | tail -1`
my_label2:
    description: List 1 file on example.org
    servers:
        - host: example.org
          port: 22
          user: root
    commands:
        - ls -1

Or if you prefer JSON:

{
  "my_label1": {
    "description": "View the content of the newest file on example.org and test.com",
    "servers": [
        {
          "host": "example.org",
          "port": 22,
          "user": "root"
        },
        {
          "host": "test.com",
          "port": 1234,
          "user": "eddy"
        }
      ],
    "commands": [
        "ls -l",
        "cat `ls -1rt | tail -1`"
      ]
  },
  "my_label2": {
    "description": "List 1 file on example.org"
    "servers": [
        {
          "host": "example.org",
          "port": 22,
          "user": "root"
        }
      ],
    "commands": [
        "ls -1"
      ]
  }
}

You can also define labels in both JSON and YAML config files. These files will be merged at runtime.

After you have added a configuration file with labels, servers and commands, you can do stuff like this:

$ sshelper my_label1

This will execute all commands defined under "my_label1" on all servers defined under that same block! Talking about enhancing your workflow...

To list all the labels you have defined with their description, you can do:

$ sshelper -l

Contributing

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