Git Product home page Git Product logo

sshfront's Introduction

sshfront

CircleCI IRC Channel

A lightweight SSH server frontend where authentication and connections are controlled with command handlers / shell scripts.

Using sshfront

Usage: ./sshfront [options] <handler>

  -a="": authentication hook. empty=allow all
  -d=false: debug mode
  -e=false: pass environment to handler
  -h="0.0.0.0": ip to listen on
  -k="~/.ssh/id_rsa": private host key path
  -p="22": port to listen on

handler $command...

$command... command line arguments specified to run by the SSH client

The handler is a command that's used to handle all SSH connections. Output, stderr, and the exit code is returned to the client. If the client provides stdin, that's passed to the handler.

If the authentication hook was specified, any output is parsed as environment variables and added to the handler environment. $USER is always the SSH user used to connect and $SSH_ORIGINAL_COMMAND is the command specified from the client if not interactive.

auth-hook $user $key

  • $user argument is the name of the user being used to attempt the connection
  • $key argument is the public key data being provided for authentication

The auth hook is a command used for authenticating incoming SSH connections. If it returns with exit status 0, the connection will be allowed, otherwise it will be denied. The output of auth hook must be empty, or key-value pairs in the form KEY=value separated by newlines, which will be added to the environment of connection handler.

The auth hook is optional, but if not specified then all connections are allowed. It is a good idea to always specify an auth hook.

See example/authcheck auth hook that checks that the pub key is authorized. Usage:

sshfront -a example/authcheck

Examples

Many of these bypass authentication and may allow remote execution, do not run this in production.

Echo server:

server$ sshfront $(which echo)
client$ ssh $SERVER "hello world"
hello world

Echo host's environment to clients:

server$ sshfront -e $(env)
client$ ssh $SERVER
USER=root
HOME=/root
LANG=en_US.UTF-8
...

Bash server:

server$ sshfront $(which bash)
client$ ssh $SERVER
bash-4.3$ echo "this is a bash instance running on the server"
this is a bash instance running on the server

SSH forwarding:

server$ sshfront example/sshforward
client$ ssh alice@$SERVER
Forward ssh [email protected]...
Welcome to another.server

Sponsors

This project was made possible thanks to Deis and DigitalOcean.

License

MIT

sshfront's People

Contributors

epheph avatar lalyos avatar progrium avatar shazow avatar stokito avatar technosophos avatar thenathanblack avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sshfront's Issues

rename to sshfront?

I want to rename execd. This is a thread to discuss for a bit. As naming is subjective, it's easy to say "execd is fine" but I'd like add some requirements.

  • make it clearly about ssh
  • imply its uses as a programmable "frontend" (as in proxy/balancer/gateway, not ui)
  • ideally easier to say and read than "execd"
  • remain simple/short

As such, current best is "sshfront".

Invoke a handler on client disconnect

I'm not sure if this is possible, but it would be cool to be able to call a disconnected-handler that takes an argument user. This way, if your handler creates any artifacts, the disconnect-handler can clean up after it.

I think this is part of the disconnect, but not sure if that's correct or not.

Improve environment var passing

Some ideas:

  1. Using -e should explicitly add all of the host's environment key-value pairs from os.Environ()
  2. Inject arbitrary key-value pairs using execd -e foo="bar" -e BAZ="$BAZ" ...

Allow disconnecting a session via custom handler

It would be great to have some clock process every N seconds that could invoke a disconnection-handler. The handler would exit 0 to disconnect, and exit 1 to stay alive.

This would be useful for something like allowing for SSH session TTLs, or revoking SSH access at run-time through a call to an external api/service.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.