sshexpose

package module
v0.0.0-...-b589361 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2016 License: Apache-2.0 Imports: 10 Imported by: 0

README

ssh-expose

GoDoc

A simple package that makes it easy to write a interactive command line program that can be used locally or served over SSH.

Example

See the example directory for an .... example.

cd example
# Local mode
go run *.go

# SSH Mode
ssh-keygen -t rsa -f example_host_key_rsa
go run *.go -serve-ssh=localhost:2222
# Run 'ssh localhost -p 2222' on another terminal

TODO

  • Support authentication to sshd
  • Rate limiting and limite the num of connections
  • readline type stuff with tab completion, etc

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ServeLocal

func ServeLocal(icli ServeICLI)

ServeLocal will serve an interactive CLI locally. This takes care of providing a line based input method.

func ServeSSH

func ServeSSH(options SSHOptions) error

ServeSSH will run an SSH server that accepts connections.

Each incoming SSH session will result in a call to options.REPL.

Types

type SSHOptions

type SSHOptions struct {
	// ICLI defines the interactive CLI you want to serve
	ICLI ServeICLI

	// Addr is an IPv4 IP:port pair that you wish to serve on
	Addr string

	// PrivateHostKey is the host key to present when serving SSH.
	//
	// This can be generated with `ssh-keygen -t rsa -f my_host_key_rsa`
	PrivateHostKey string
}

SSHOptions defines the parameters for serving a REPL over SSH

type ServeICLI

type ServeICLI func(t Term)

ServeICLI should implement interactive CLI

type Term

type Term interface {
	ReadLine() (line string, err error)
	StdOut() io.Writer
	StdErr() io.Writer
	Close()
}

Term is a simple terminal abstraction.

This is what programs should use for all input/output with a user. It will work equally well over SSH or the local terminal.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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