Documentation ¶
Index ¶
- Variables
- func ConnectShell(host string, name string, handler func(r io.Reader, w io.WriteCloser) error) error
- func Fingerprint(k ssh.PublicKey) string
- func MakeAuth(auth Auth) *ssh.ServerConfig
- func MakeNoAuth() *ssh.ServerConfig
- func NewClientConfig(name string) *ssh.ClientConfig
- func NewInputLimiter() rateio.Limiter
- func NewRandomSigner(bits int) (ssh.Signer, error)
- func ReadLimitConn(conn net.Conn, limiter rateio.Limiter) net.Conn
- func SetLogger(w io.Writer)
- type Auth
- type Connection
- type SSHListener
- type Terminal
Constants ¶
This section is empty.
Variables ¶
var ErrNoSessionChannel = errors.New("no session channel")
var ErrNotSessionChannel = errors.New("terminal requires session channel")
Functions ¶
func ConnectShell ¶
func ConnectShell(host string, name string, handler func(r io.Reader, w io.WriteCloser) error) error
ConnectShell makes a barebones SSH client session, used for testing.
func Fingerprint ¶
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 ¶
NewInputLimiter returns a rateio.Limiter with sensible defaults for differentiating between humans typing and bots spamming.
func NewRandomSigner ¶
NewRandomSigner generates a random key of a desired bit length.
func ReadLimitConn ¶
ReadLimitConn returns a net.Conn whose io.Reader interface is rate-limited by limiter.
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 ClientVersion() []byte Close() error }
Connection is an interface with fields necessary to operate an sshd host.
type SSHListener ¶
type SSHListener struct { net.Listener RateLimit func() rateio.Limiter HandlerFunc func(term *Terminal) // contains filtered or unexported fields }
Container for the connection and ssh-related configuration
func ListenSSH ¶
func ListenSSH(laddr string, config *ssh.ServerConfig) (*SSHListener, error)
Make an SSH listener socket
func (*SSHListener) Serve ¶
func (l *SSHListener) Serve()
Accept incoming connections as terminal requests and yield them
type Terminal ¶
type Terminal struct { terminal.Terminal Conn Connection Channel ssh.Channel // contains filtered or unexported fields }
Extending ssh/terminal to include a closer interface
func NewSession ¶
func NewSession(conn *ssh.ServerConn, channels <-chan ssh.NewChannel) (*Terminal, error)
Find session channel and make a Terminal from it
func NewTerminal ¶
func NewTerminal(conn *ssh.ServerConn, ch ssh.NewChannel) (*Terminal, error)
Make new terminal from a session channel