Skip to content

Small application that helps you to automate mundane, remote tasks

License

Notifications You must be signed in to change notification settings

kvannotten/sshelper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 [email protected], 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

About

Small application that helps you to automate mundane, remote tasks

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages