func NewServerConn(c net.Conn, config *ServerConfig) (*ServerConn, <-chan NewChannel, <-chan *Request, error) {
	fullConf := *config
	fullConf.SetDefaults()
	if fullConf.MaxAuthTries == 0 {
		fullConf.MaxAuthTries = 6
	}
	s := &connection{
		sshConn: sshConn{conn: c},
	}
	perms, err := s.serverHandshake(&fullConf)
	if err != nil {
		c.Close()
		return nil, nil, nil, err
	}
	return &ServerConn{s, perms}, s.mux.incomingChannels, s.mux.incomingRequests, nil
}
NewServerConn starts a new SSH server with c as the underlying
transport.  It starts with a handshake and, if the handshake is
unsuccessful, it closes the connection and returns an error.  The
Request and NewChannel channels must be serviced, or the connection
will hang.
package ssh
import (
	"bytes"
	"errors"
	"fmt"
	"io"
	"net"
	"strings"
)
type Permissions struct {
	CriticalOptions map[string]string
	Extensions map[string]string
}
type ServerConfig struct {
	Config
	hostKeys []Signer
	NoClientAuth bool
	MaxAuthTries int
	PasswordCallback func(conn ConnMetadata, password []byte) (*Permissions, error)
	PublicKeyCallback func(conn ConnMetadata, key PublicKey) (*Permissions, error)
	KeyboardInteractiveCallback func(conn ConnMetadata, client KeyboardInteractiveChallenge) (*Permissions, error)
	AuthLogCallback func(conn ConnMetadata, method string, err error)
	ServerVersion string
}
func (s *ServerConfig) AddHostKey(key Signer) {
	for i, k := range s.hostKeys {
		if k.PublicKey().Type() == key.PublicKey().Type() {
			s.hostKeys[i] = key
			return
		}
	}
	s.hostKeys = append(s.hostKeys, key)
}
type cachedPubKey struct {
	user       string
	pubKeyData []byte
	result     error
	perms      *Permissions
}
const maxCachedPubKeys = 16
type pubKeyCache struct {
	keys []cachedPubKey
}
func (c *pubKeyCache) get(user string, pubKeyData []byte) (cachedPubKey, bool) {
	for _, k := range c.keys {
		if k.user == user && bytes.Equal(k.pubKeyData, pubKeyData) {
			return k, true
		}
	}
	return cachedPubKey{}, false
}
func (c *pubKeyCache) add(candidate cachedPubKey) {
	if len(c.keys) < maxCachedPubKeys {
		c.keys = append(c.keys, candidate)
	}
}
type ServerConn struct {
	Conn
	Permissions *Permissions
}