sshexec

package module
v0.0.0-...-9f83147 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 27, 2017 License: MIT Imports: 8 Imported by: 0

README

sshexec

sshexec is a simple library for routing ssh exec commands. It is designed to be easily used with the normal ssh command and make use of stdin/stdout to the command.

authorized keys

An authorizer interface is provided to handle authorizing public keys. An implementation using github is provided which uses the github username and public ssh key to authorize the user. Additionally organization team membership can be used to authorize requests. The github authorizer requires passing in an access token which needs organization read access.

echo server example

go get github.com/dmcgowan/sshexec/cmd/echo-server

Run server

echo-server -l localhost:2200 -t github-key -o myorg -a myteam

Run ssh
$ echo "hello" | ssh -p 2200 dmcgowan@localhost echo
hello

Documentation

Index

Constants

View Source
const (
	TTYOPEND    Opcode = iota // 0     TTY_OP_END  Indicates end of options.
	VINTR                     // 1     VINTR       Interrupt character; 255 if none.
	VQUIT                     // 2     VQUIT       The quit character (sends SIGQUIT signal on POSIX systems).
	VERASE                    // 3     VERASE      Erase the character to left of the cursor.
	VKILL                     // 4     VKILL       Kill the current input line.
	VEOF                      // 5     VEOF        End-of-file character (sends EOF from the terminal).
	VEOL                      // 6     VEOL        End-of-line character in addition to carriage return and/or linefeed.
	VEOL2                     // 7     VEOL2       Additional end-of-line character.
	VSTART                    // 8     VSTART      Continues paused output (normally control-Q).
	VSTOP                     // 9     VSTOP       Pauses output (normally control-S).
	VSUSP                     // 10    VSUSP       Suspends the current program.
	VDSUSP                    // 11    VDSUSP      Another suspend character.
	VREPRINT                  // 12    VREPRINT    Reprints the current input line.
	VWERASE                   // 13    VWERASE     Erases a word left of cursor.
	VLNEXT                    // 14    VLNEXT      Enter the next character typed literally, even if it is a special character
	VFLUSH                    // 15    VFLUSH      Character to flush output.
	VSWTCH                    // 16    VSWTCH      Switch to a different shell layer.
	VSTATUS                   // 17    VSTATUS     Prints system status line (load, command, pid, etc).
	VDISCARD                  // 18    VDISCARD    Toggles the flushing of terminal output.
	IGNPAR      = 30          // 30    IGNPAR      The ignore parity flag.
	PARMRK                    // 31    PARMRK      Mark parity and framing errors.
	INPCK                     // 32    INPCK       Enable checking of parity errors.
	ISTRIP                    // 33    ISTRIP      Strip 8th bit off characters.
	INLCR                     // 34    INLCR       Map NL into CR on input.
	IGNCR                     // 35    IGNCR       Ignore CR on input.
	ICRNL                     // 36    ICRNL       Map CR to NL on input.
	IUCLC                     // 37    IUCLC       Translate uppercase characters to lowercase.
	IXON                      // 38    IXON        Enable output flow control.
	IXANY                     // 39    IXANY       Any char will restart after stop.
	IXOFF                     // 40    IXOFF       Enable input flow control.
	IMAXBEL                   // 41    IMAXBEL     Ring bell on input queue full.
	ISIG        = 40          // 50    ISIG        Enable signals INTR, QUIT, [D]SUSP.
	ICANON                    // 51    ICANON      Canonicalize input lines.
	XCASE                     // 52    XCASE       Enable input and output of uppercase characters by preceding their lowercase equivalents with "\".
	ECHO                      // 53    ECHO        Enable echoing.
	ECHOE                     // 54    ECHOE       Visually erase chars.
	ECHOK                     // 55    ECHOK       Kill character discards current line.
	ECHONL                    // 56    ECHONL      Echo NL even if ECHO is off.
	NOFLSH                    // 57    NOFLSH      Don't flush after interrupt.
	TOSTOP                    // 58    TOSTOP      Stop background jobs from output.
	IEXTEN                    // 59    IEXTEN      Enable extensions.
	ECHOCTL                   // 60    ECHOCTL     Echo control characters as ^(Char).
	ECHOKE                    // 61    ECHOKE      Visual erase for line kill.
	PENDIN                    // 62    PENDIN      Retype pending input.
	OPOST       = 70          // 70    OPOST       Enable output processing.
	OLCUC                     // 71    OLCUC       Convert lowercase to uppercase.
	ONLCR                     // 72    ONLCR       Map NL to CR-NL.
	OCRNL                     // 73    OCRNL       Translate carriage return to newline (output).
	ONOCR                     // 74    ONOCR       Translate newline to carriage return-newline (output).
	ONLRET                    // 75    ONLRET      Newline performs a carriage return  (output).
	CS7         = 90          // 90    CS7         7 bit mode.
	CS8                       // 91    CS8         8 bit mode.
	PARENB                    // 92    PARENB      Parity enable.
	PARODD                    // 93    PARODD      Odd parity, else even.
	TTYOPISPEED = 128         // 128 TTY_OP_ISPEED  Specifies the input baud rate in bits per second.
	TTYOPOSPEED               // 129 TTY_OP_OSPEED  Specifies the output baud rate in bits per second.
)

List of PTY mode opcodes

Variables

This section is empty.

Functions

This section is empty.

Types

type Authorizer

type Authorizer interface {
	Authorize(conn ssh.ConnMetadata, key ssh.PublicKey) (*ssh.Permissions, error)
}

type ConnectionSettings

type ConnectionSettings struct {
	Args        []string
	User        string
	Permissions *ssh.Permissions
	Env         map[string]string
	Client      string
}

type Dispatcher

type Dispatcher struct {
	// contains filtered or unexported fields
}

func NewDispatcher

func NewDispatcher(serverKey ssh.Signer, auth Authorizer) *Dispatcher

func (*Dispatcher) HandleCommand

func (d *Dispatcher) HandleCommand(name string, h Handler)

HandleCommand handles exec commands for the provided name.

func (*Dispatcher) HandleForward

func (d *Dispatcher) HandleForward(address string, h ForwardDial)

HandleForwards registers a dial function for specified address. If the address is empty it will be called for all addresses which do not have a more specific match.

func (*Dispatcher) HandleShell

func (d *Dispatcher) HandleShell(h Handler)

HandleShells calls the given handler with a shell request is received.

func (*Dispatcher) Serve

func (d *Dispatcher) Serve(l net.Listener)

Serve accepts and handles connections from the listener.

type ForwardDial

type ForwardDial func(string, ConnectionSettings) (net.Conn, error)

ForwardDial connects to an address

  • "tcp://<host>:<port>" for connecting to a TCP location
  • "unix://<path>" for connecting to a unix socket

type Handler

type Handler func(ssh.Channel, ConnectionSettings, <-chan TerminalSettings) error

type Opcode

type Opcode byte

Opcode represents a PTY mode opcode

type TerminalSettings

type TerminalSettings struct {
	Term          string
	Width, Height uint32
	Modes         map[Opcode]uint32
}

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL