ssh

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2023 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UploadBufferSize = 1 * 1024 // 1KB

	LoggerContextKey      = "logger"
	RequestIDContextKey   = "request_id"
	FingerprintContextKey = "fingerprint"
	UserIDContextKey      = "user_id"

	FileRequestPrefix = "f:"
)

Variables

View Source
var (
	ErrFileNotFound      = errors.New("file not found")
	ErrFileTooLarge      = errors.New("file too large")
	ErrNilProgram        = errors.New("nil program")
	ErrPrivateFileAccess = errors.New("private file access")
	ErrUnknownCommand    = errors.New("unknown command")
	ErrSignPublicFile    = errors.New("unable to sign public file")
	ErrOpOnNonOwnedFile  = errors.New("operation on non-owned file")
)
View Source
var (
	ErrFlagRequied = errors.New("flag required")
	ErrFlagParse   = errors.New("parse error")
)

Functions

func AssignUser

func AssignUser(database db.DB, externalAddress url.URL) func(next ssh.Handler) ssh.Handler

AssignUser will attempt to match a user with a public key fingerprint. If a user is not found, one will be created with the current fingerprint attached.

func BlockIfNoPublicKey

func BlockIfNoPublicKey(next ssh.Handler) ssh.Handler

BlockIfNoPublicKey will stop any SSH connections that aren't using public key authentication. If blocked, it will print a helpful message to the user.

func WithAuthorizedKeys added in v0.3.0

func WithAuthorizedKeys(authorizedKeys []ssh.PublicKey) func(next ssh.Handler) ssh.Handler

WithAuthorizedKeys will block any SSH connections that aren't using a public key in the authorized key list. If authorizedKeys is empty, this middleware will be a no-op.

func WithLogger

func WithLogger(next ssh.Handler) ssh.Handler

WithLogger will create a logger for each SSH session.

func WithRequestID

func WithRequestID(next ssh.Handler) ssh.Handler

WithRequestID will generate a unique request ID for each SSH session.

func WithSessionMetrics

func WithSessionMetrics(next ssh.Handler) ssh.Handler

WithSessionMetrics will record metrics for each SSH session.

Types

type Confirm

type Confirm struct {
	Question string
}

func (*Confirm) Prompt

func (c *Confirm) Prompt(sesh ssh.Session) (bool, error)

func (*Confirm) Questionf

func (c *Confirm) Questionf(format string, v ...interface{})

type DeleteFlags

type DeleteFlags struct {
	*flag.FlagSet

	Force bool
}

func (*DeleteFlags) Parse

func (df *DeleteFlags) Parse(out io.Writer, args []string) error

type Notification

type Notification struct {
	Color     lipgloss.TerminalColor
	Title     string
	Message   string
	WithStyle func(s *lipgloss.Style)
}

func (*Notification) Messagef

func (n *Notification) Messagef(format string, v ...interface{})

func (*Notification) Render

func (n *Notification) Render(sesh ssh.Session)

func (*Notification) Titlef

func (n *Notification) Titlef(format string, v ...interface{})

type Service

type Service struct {
	*ssh.Server
}

func New

func New(cfg *config.Config, db db.DB) (*Service, error)

type SessionHandler

type SessionHandler struct {
	Config *config.Config
	DB     db.DB
}

func (*SessionHandler) DeleteFile

func (h *SessionHandler) DeleteFile(sesh *UserSession, file *snips.File)

func (*SessionHandler) DownloadFile

func (h *SessionHandler) DownloadFile(sesh *UserSession, file *snips.File)

func (*SessionHandler) FileRequest

func (h *SessionHandler) FileRequest(sesh *UserSession)

func (*SessionHandler) HandleFunc

func (h *SessionHandler) HandleFunc(_ ssh.Handler) ssh.Handler

func (*SessionHandler) Interactive

func (h *SessionHandler) Interactive(sesh *UserSession)

func (*SessionHandler) SignFile

func (h *SessionHandler) SignFile(sesh *UserSession, file *snips.File)

func (*SessionHandler) Upload

func (h *SessionHandler) Upload(sesh *UserSession)

type SignFlags

type SignFlags struct {
	*flag.FlagSet

	TTL time.Duration
}

func (*SignFlags) Parse

func (sf *SignFlags) Parse(out io.Writer, args []string) error

type UploadFlags

type UploadFlags struct {
	*flag.FlagSet

	Private   bool
	Extension string
	TTL       time.Duration
}

func (*UploadFlags) Parse

func (uf *UploadFlags) Parse(out io.Writer, args []string) error

type UserSession

type UserSession struct {
	ssh.Session
}

func (*UserSession) Error

func (sesh *UserSession) Error(err error, title string, f string, v ...interface{})

func (*UserSession) IsFileRequest

func (sesh *UserSession) IsFileRequest() bool

func (*UserSession) IsPTY

func (sesh *UserSession) IsPTY() bool

func (*UserSession) PublicKeyFingerprint

func (sesh *UserSession) PublicKeyFingerprint() string

func (*UserSession) RequestID

func (sesh *UserSession) RequestID() string

func (*UserSession) RequestedFileID

func (sesh *UserSession) RequestedFileID() string

func (*UserSession) UserID

func (sesh *UserSession) UserID() string

Jump to

Keyboard shortcuts

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