package sshimport (gossh)typeSignalstring// POSIX signals as listed in RFC 4254 Section 6.10.const (SIGABRTSignal = "ABRT"SIGALRMSignal = "ALRM"SIGFPESignal = "FPE"SIGHUPSignal = "HUP"SIGILLSignal = "ILL"SIGINTSignal = "INT"SIGKILLSignal = "KILL"SIGPIPESignal = "PIPE"SIGQUITSignal = "QUIT"SIGSEGVSignal = "SEGV"SIGTERMSignal = "TERM"SIGUSR1Signal = "USR1"SIGUSR2Signal = "USR2")// DefaultHandler is the default Handler used by Serve.varDefaultHandlerHandler// Option is a functional option handler for Server.typeOptionfunc(*Server) error// Handler is a callback for handling established SSH sessions.typeHandlerfunc(Session)// BannerHandler is a callback for displaying the server banner.typeBannerHandlerfunc(ctx Context) string// PublicKeyHandler is a callback for performing public key authentication.typePublicKeyHandlerfunc(ctx Context, key PublicKey) bool// PasswordHandler is a callback for performing password authentication.typePasswordHandlerfunc(ctx Context, password string) bool// KeyboardInteractiveHandler is a callback for performing keyboard-interactive authentication.typeKeyboardInteractiveHandlerfunc(ctx Context, challenger gossh.KeyboardInteractiveChallenge) bool// PtyCallback is a hook for allowing PTY sessions.typePtyCallbackfunc(ctx Context, pty Pty) bool// SessionRequestCallback is a callback for allowing or denying SSH sessions.typeSessionRequestCallbackfunc(sess Session, requestType string) bool// ConnCallback is a hook for new connections before handling.// It allows wrapping for timeouts and limiting by returning// the net.Conn that will be used as the underlying connection.typeConnCallbackfunc(ctx Context, conn net.Conn) net.Conn// LocalPortForwardingCallback is a hook for allowing port forwardingtypeLocalPortForwardingCallbackfunc(ctx Context, destinationHost string, destinationPort uint32) bool// ReversePortForwardingCallback is a hook for allowing reverse port forwardingtypeReversePortForwardingCallbackfunc(ctx Context, bindHost string, bindPort uint32) bool// ServerConfigCallback is a hook for creating custom default server configstypeServerConfigCallbackfunc(ctx Context) *gossh.ServerConfig// ConnectionFailedCallback is a hook for reporting failed connections// Please note: the net.Conn is likely to be closed at this pointtypeConnectionFailedCallbackfunc(conn net.Conn, err error)// Window represents the size of a PTY window.typeWindowstruct { Width int Height int}// Pty represents a PTY request and configuration.typePtystruct { Term string Window Window// HELP WANTED: terminal modes!}// Serve accepts incoming SSH connections on the listener l, creating a new// connection goroutine for each. The connection goroutines read requests and// then calls handler to handle sessions. Handler is typically nil, in which// case the DefaultHandler is used.func ( net.Listener, Handler, ...Option) error { := &Server{Handler: }for , := range {if := .SetOption(); != nil {return } }return .Serve()}// ListenAndServe listens on the TCP network address addr and then calls Serve// with handler to handle sessions on incoming connections. Handler is typically// nil, in which case the DefaultHandler is used.func ( string, Handler, ...Option) error { := &Server{Addr: , Handler: }for , := range {if := .SetOption(); != nil {return } }return .ListenAndServe()}// Handle registers the handler as the DefaultHandler.func ( Handler) {DefaultHandler = }// KeysEqual is constant time compare of the keys to avoid timing attacks.func (, PublicKey) bool {// avoid panic if one of the keys is nil, return false insteadif == nil || == nil {returnfalse } := .Marshal() := .Marshal()return (len() == len() && subtle.ConstantTimeCompare(, ) == 1)}
The pages are generated with Goldsv0.8.2. (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds.