Documentation
¶
Index ¶
- func ConnectShell(host string, name string, handler func(r io.Reader, w io.WriteCloser)) 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 ¶
This section is empty.
Functions ¶
func ConnectShell ¶
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 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