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
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request