sshserver

package
v0.0.11 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 16, 2022 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Auth

type Auth struct {
	// contains filtered or unexported fields
}

func NewAuth

func NewAuth(
	fileManager FileReader,
	privateKeyManager PrivateKeyParser,
	authorizedKeyManager AuthorizedKeyParserChecker,
	hostKeyFilePath string,
	authorizedUsers []AuthorizedUser,
) *Auth

func (*Auth) BuildHostKeySigner

func (a *Auth) BuildHostKeySigner() (ssh.Signer, error)

func (*Auth) CheckPublicKeyValidity

func (a *Auth) CheckPublicKeyValidity(
	username string,
	passedKey ssh.PublicKey,
) (bool, error)

type AuthorizedKeyManager

type AuthorizedKeyManager struct{}

func NewAuthorizedKeyManager

func NewAuthorizedKeyManager() AuthorizedKeyManager

func (AuthorizedKeyManager) CheckPublicKeyEqualsAuthorizedKey

func (AuthorizedKeyManager) CheckPublicKeyEqualsAuthorizedKey(
	publicKey ssh.PublicKey,
	authorizedKey ssh.PublicKey,
) bool

func (AuthorizedKeyManager) ParseAuthorizedKeys

func (AuthorizedKeyManager) ParseAuthorizedKeys(
	authorizedKeysBytes []byte,
) ([]ssh.PublicKey, error)

type AuthorizedKeyParserChecker

type AuthorizedKeyParserChecker interface {
	ParseAuthorizedKeys(authorizedKeysBytes []byte) ([]ssh.PublicKey, error)
	CheckPublicKeyEqualsAuthorizedKey(publicKey, authorizedKey ssh.PublicKey) bool
}

type AuthorizedUser

type AuthorizedUser struct {
	UserName               string
	AuthorizedKeysFilePath string
}

type FileReader

type FileReader interface {
	ReadFile(filePath string) ([]byte, error)
}

type PTYManager

type PTYManager struct{}

func NewPTYManager

func NewPTYManager() PTYManager

func (PTYManager) SetWindowSize

func (PTYManager) SetWindowSize(f *os.File, width, height int)

type PTYWindowSizer

type PTYWindowSizer interface {
	SetWindowSize(f *os.File, width, height int)
}

type PrivateKeyManager

type PrivateKeyManager struct{}

func NewPrivateKeyManager

func NewPrivateKeyManager() PrivateKeyManager

func (PrivateKeyManager) ParsePrivateKey

func (PrivateKeyManager) ParsePrivateKey(
	privateKeyBytes []byte,
) (ssh.Signer, error)

type PrivateKeyParser

type PrivateKeyParser interface {
	ParsePrivateKey(privateKeyBytes []byte) (ssh.Signer, error)
}

type ServerAuther

type ServerAuther interface {
	BuildHostKeySigner() (ssh.Signer, error)
	CheckPublicKeyValidity(username string, passedKey ssh.PublicKey) (bool, error)
}

type ServerBuilder

type ServerBuilder struct {
	// contains filtered or unexported fields
}

func NewServerBuilder

func NewServerBuilder(
	auth ServerAuther,
	listenAddr string,
) ServerBuilder

func (ServerBuilder) Build

func (s ServerBuilder) Build() (*ssh.Server, error)

type Session

type Session struct {
	// contains filtered or unexported fields
}

func NewSession

func NewSession(
	manager SessionExecShellManager,
) Session

func (Session) Start

func (s Session) Start(sshSession ssh.Session)

type SessionExecShellManager

type SessionExecShellManager interface {
	ManageShellInEnv(sshSession ssh.Session) error
	ManageShellPTYInEnv(sshSession ssh.Session) error
	ManageExecInEnv(sshSession ssh.Session) error
	ManageShellPTY(sshSession ssh.Session) error
	ManageShell(sshSession ssh.Session) error
	ManageExec(sshSession ssh.Session) error
}

type SessionManager

type SessionManager struct {
	// contains filtered or unexported fields
}

func NewSessionManager

func NewSessionManager(
	userCommandBuilder UserCommandBuilder,
	ptyManager PTYWindowSizer,
) SessionManager

func (SessionManager) ManageExec

func (s SessionManager) ManageExec(sshSession ssh.Session) error

func (SessionManager) ManageExecInEnv

func (s SessionManager) ManageExecInEnv(sshSession ssh.Session) error

func (SessionManager) ManageShell

func (s SessionManager) ManageShell(sshSession ssh.Session) error

func (SessionManager) ManageShellInEnv

func (s SessionManager) ManageShellInEnv(sshSession ssh.Session) error

func (SessionManager) ManageShellPTY

func (s SessionManager) ManageShellPTY(sshSession ssh.Session) error

func (SessionManager) ManageShellPTYInEnv

func (s SessionManager) ManageShellPTYInEnv(sshSession ssh.Session) error

type UserCommandBuilder

type UserCommandBuilder interface {
	Build(args ...string) *exec.Cmd
	BuildShell() *exec.Cmd
	BuildShellPTY() *exec.Cmd
}

type UserCommandManager

type UserCommandManager struct {
	// contains filtered or unexported fields
}

func NewUserCommandManager

func NewUserCommandManager(
	user *user.User,
) UserCommandManager

func (UserCommandManager) Build

func (u UserCommandManager) Build(args ...string) *exec.Cmd

func (UserCommandManager) BuildShell

func (u UserCommandManager) BuildShell() *exec.Cmd

func (UserCommandManager) BuildShellPTY

func (u UserCommandManager) BuildShellPTY() *exec.Cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL