Turn SSH into a thin client specifically for your app
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
tests/unit
CHANGELOG.md fix changelog Mar 22, 2017
Dockerfile.test Pinned base Docker image Aug 8, 2016
LICENSE Create LICENSE Apr 28, 2014
Makefile release 0.7.0 Mar 22, 2017
README.md Adds sshcommand list to README.md Jun 30, 2016
circle.yml
package.json make bpkg friendly Jul 2, 2014
sshcommand Only allow one key per file in acl-add Mar 22, 2017

README.md

sshcommand Build Status

Simplifies running a single command over SSH, and manages authorized keys (ACL) and users in order to do so.

It basically simplifies running:

ssh user@server 'ls -l <your-args>'

into:

ssh ls@server <your-args>

Commands

sshcommand create     <USER> <COMMAND>          # Creates a user forced to run command when SSH connects
sshcommand acl-add    <USER> <NAME> <KEY_FILE>  # Adds named SSH key to user from STDIN or argument
sshcommand acl-remove <USER> <NAME>             # Removes SSH key by name
sshcommand list       <USER>                    # Lists SSH user keys by name
sshcommand help       <COMMAND>                 # Shows help information

Example

On a server, create a new command user:

$ sshcommand create cmd /path/to/command

On your computer, add authorized keys with your key:

$ cat ~/.ssh/id_rsa.pub | ssh root@server sshcommand acl-add cmd progrium

If the public key is already on the server, you may also specify it as an argument:

$ ssh root@server sshcommand acl-add cmd progrium ~/.ssh/id_rsa.pub

Now anywhere with the private key you can easily run:

$ ssh cmd@server

Anything you pass as the command string will be appended to the command. You can use this to pass arguments or if your command takes subcommands, expose those subcommands easily.

$ /path/to/command subcommand

Can be run remotely with:

$ ssh cmd@server subcommand

When adding an authorized key, you can also specify custom options for AUTHORIZED_KEYS by specifying the SSHCOMMAND_ALLOWED_KEYS environment variable. This should be a list of comma-separated options. The default keys are as follows:

no-agent-forwarding,no-user-rc,no-X11-forwarding,no-port-forwarding

This can be useful for cases where the ssh server does not allow certain options or you wish to further constrain a user's environment. Please see man sshd for more information.