sshkit

package module
v0.0.0-...-527d323 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2015 License: MIT Imports: 14 Imported by: 0

README

GoDoc License Build Status

go-sshkit

Toolkit for building SSH servers and clients in Go.

Based on code from ssh-chat.

License

MIT.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConnectShell

func ConnectShell(host string, name string, handler func(r io.Reader, w io.WriteCloser)) error

ConnectShell makes a barebones SSH client session, used for testing.

func Fingerprint

func Fingerprint(k ssh.PublicKey) string

Fingerprint performs a SHA256 BASE64 fingerprint of the PublicKey, similar to OpenSSH. See: https://anongit.mindrot.org/openssh.git/commit/?id=56d1c83cdd1ac

func MakeAuth

func MakeAuth(auth Auth) *ssh.ServerConfig

MakeAuth makes an ssh.ServerConfig which performs authentication against an Auth implementation.

func MakeNoAuth

func MakeNoAuth() *ssh.ServerConfig

MakeNoAuth makes a simple ssh.ServerConfig which allows all connections. Primarily used for testing.

func NewClientConfig

func NewClientConfig(name string) *ssh.ClientConfig

NewClientConfig creates a barebones ssh.ClientConfig to be used with ssh.Dial.

func NewInputLimiter

func NewInputLimiter() rateio.Limiter

NewInputLimiter returns a rateio.Limiter with sensible defaults for differentiating between humans typing and bots spamming.

func NewRandomSigner

func NewRandomSigner(bits int) (ssh.Signer, error)

NewRandomSigner generates a random key of a desired bit length.

func ReadLimitConn

func ReadLimitConn(conn net.Conn, limiter rateio.Limiter) net.Conn

ReadLimitConn returns a net.Conn whose io.Reader interface is rate-limited by limiter.

func SetLogger

func SetLogger(w io.Writer)

SetLogger replaces the library's log writer

Types

type Auth

type Auth interface {
	// Whether to allow connections without a public key.
	AllowAnonymous() bool
	// Given address and public key, return if the connection should be permitted.
	Check(net.Addr, ssh.PublicKey) (bool, error)
}

Auth is used to authenticate connections based on public keys.

type Connection

type Connection interface {
	PublicKey() ssh.PublicKey
	RemoteAddr() net.Addr
	Name() string
	Close() error
}

Connection is an interface with fields necessary to operate an sshkit host.

type SSHListener

type SSHListener struct {
	net.Listener

	RateLimit func() rateio.Limiter
	// contains filtered or unexported fields
}

SSHListener is a container for the connection and ssh-related configuration

func ListenSSH

func ListenSSH(laddr string, config *ssh.ServerConfig) (*SSHListener, error)

ListenSSH makes an SSH listener socket

func (*SSHListener) ServeTerminal

func (l *SSHListener) ServeTerminal() <-chan *Terminal

ServeTerminal accepts incoming connections as terminal requests and yield them

type Terminal

type Terminal struct {
	terminal.Terminal
	Conn    Connection
	Channel ssh.Channel
}

Terminal is extending ssh/terminal to include a closer interface

func NewSession

func NewSession(conn *ssh.ServerConn, channels <-chan ssh.NewChannel) (term *Terminal, err error)

NewSession finds a session channel and makes a Terminal from it

func NewTerminal

func NewTerminal(conn *ssh.ServerConn, ch ssh.NewChannel) (*Terminal, error)

NewTerminal creates a Terminal from a session channel

func (*Terminal) Close

func (t *Terminal) Close() error

Close terminal and ssh connection

Jump to

Keyboard shortcuts

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