func New(signer ssh.Signer, auth func(ssh.ConnMetadata, ssh.PublicKey) (*User, error), setup func(*Session) error) *Server {
	server := &Server{
		Authenticator: auth,
		Setup:         setup,
		Dialer:        net.Dial,
	}
	server.sshConfig = &ssh.ServerConfig{
		PublicKeyCallback: server.auth,
	}
	server.sshConfig.AddHostKey(signer)
	return server
}
New returns a Server initialized with the provided signer and callbacks.
package sshmux
import (
	"errors"
	"fmt"
	"io"
	"net"
	"time"
	"golang.org/x/crypto/ssh"
)
type Remote struct {
	Names []string
	Description string
	Address string
	Username string
}
type User struct {
	PublicKey ssh.PublicKey
	Name string
}
type Session struct {
	Conn *ssh.ServerConn
	User *User
	Remotes []*Remote
	PublicKey ssh.PublicKey
}
type Server struct {
	Authenticator func(ssh.ConnMetadata, ssh.PublicKey) (*User, error)
	Setup func(*Session) error
	Interactive func(io.ReadWriter, *Session) (*Remote, error)
	Selected func(*Session, string) error
	Dialer func(network, address string) (net.Conn, error)
	UsernamePrompt func(io.ReadWriter, *Session) (string, error)
	ConnectionTimeout time.Duration
	sshConfig *ssh.ServerConfig
}
type publicKey struct {
	publicKey     []byte
	publicKeyType string
}
func (p *publicKey) Marshal() []byte {
	b := make([]byte, len(p.publicKey))
	copy(b, p.publicKey)
	return b
}
func (p *publicKey) Type() string {
	return p.publicKeyType
}
func (p *publicKey) Verify([]byte, *ssh.Signature) error {
	return errors.New("verify not implemented")
}
func (s *Server) HandleConn(c net.Conn) {
	sshConn, chans, reqs, err := ssh.NewServerConn(c, s.sshConfig)
	if err != nil {
		c.Close()
		return
	}
	defer sshConn.Close()
	if sshConn.Permissions == nil || sshConn.Permissions.Extensions == nil {
		return
	}
	ext := sshConn.Permissions.Extensions
	pk := &publicKey{
		publicKey:     []byte(ext["pubKey"]),
		publicKeyType: ext["pubKeyType"],
	}
	user, err := s.Authenticator(sshConn, pk)
	if err != nil {
		return
	}
	session := &Session{
		Conn:      sshConn,
		User:      user,
		PublicKey: pk,
	}
	s.Setup(session)
	go func() {
		for req := range reqs {
			switch req.Type {
			case "keepalive@openssh.com":
				if req.WantReply {
					req.Reply(true, []byte{})
				}
			default:
				req.Reply(false, []byte{})
			}
		}
	}()
	for newChannel := range chans {
		switch newChannel.ChannelType() {
		case "session":
			go s.SessionForward(session, newChannel)
		case "direct-tcpip":
			go s.ChannelForward(session, newChannel)
		case "tcpip-forward":
			newChannel.Reject(ssh.UnknownChannelType, "sshmux server cannot remote forward ports, please ProxyJump to a host first")
		default:
			newChannel.Reject(ssh.UnknownChannelType, fmt.Sprintf("sshmux server cannot handle %s channel types, please ProxyJump to a host first", newChannel.ChannelType()))
		}
	}
}
func (s *Server) Serve(l net.Listener) error {
	for {
		conn, err := l.Accept()
		if err != nil {
			return err
		}
		go s.HandleConn(conn)
	}
}
func (s *Server) auth(conn ssh.ConnMetadata, key ssh.PublicKey) (*ssh.Permissions, error) {
	k := key.Marshal()
	t := key.Type()
	perm := &ssh.Permissions{
		Extensions: map[string]string{
			"pubKey":     string(k),
			"pubKeyType": t,
		},
	}
	_, err := s.Authenticator(conn, key)
	if err == nil {
		return perm, nil
	}
	return nil, err
}