util

package
v0.0.0-...-d053c91 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2024 License: MIT Imports: 15 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetDefaultSigner

func GetDefaultSigner() (ssh.Signer, error)

func GetSignerFromFile

func GetSignerFromFile(path string) (ssh.Signer, error)

func MatchPatternList

func MatchPatternList(patterns []*Pattern, input string) bool

MatchPatternList returns true if the input matches any of the patterns in the list. Negated patterns are matched first; if a negated pattern matches, the function returns false immediately. If no patterns match, the function

func ParseAuthorizedKeys

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

func ParseSSHTimespec

func ParseSSHTimespec(value string) (time.Time, error)

func ParseTimePattern

func ParseTimePattern(patt string) (time.Time, time.Time, error)

func RenderTime

func RenderTime(seconds uint64) string

func ShowNotification

func ShowNotification(message string)

Types

type AllowedSigner

type AllowedSigner struct {
	Key         ssh.PublicKey
	Principals  []*Pattern
	Namespaces  []*Pattern
	IsCA        bool
	ValidAfter  *time.Time
	ValidBefore *time.Time
	Comment     string
}

func ParseAllowedSigners

func ParseAllowedSigners(in []byte) ([]AllowedSigner, error)

ParseAllowedSigners parses a list of AllowedSigners from a byte slice.

func (*AllowedSigner) Marshal

func (as *AllowedSigner) Marshal() MarshalledAllowedSigner

type AuthorizedKey

type AuthorizedKey struct {
	Key             ssh.PublicKey
	Comment         string
	Principals      []string
	IsCA            bool
	Command         sql.NullString
	Environment     map[string]string
	ExpiryTime      sql.NullTime
	AgentForwarding bool
	From            []*Pattern
	PortForwarding  bool
	Pty             bool
	UserRC          bool
	X11Forwarding   bool
	PermitListen    sql.NullString
	PermitOpen      sql.NullString
	NoTouchReq      bool
	VerifyReq       bool
	Tunnel          sql.NullString
}

AuthorizedKey represents an SSH authorized_keys entry

func NewAuthorizedKey

func NewAuthorizedKey(key ssh.PublicKey, comment string, options []string) (*AuthorizedKey, error)

func (*AuthorizedKey) MatchesPrincipal

func (k *AuthorizedKey) MatchesPrincipal(input string) bool

type MarshalledAllowedSigner

type MarshalledAllowedSigner struct {
	Key         string   `json:"key"` // in openssh format
	Principals  []string `json:"principals"`
	Namespaces  []string `json:"namespaces"`
	IsCA        bool     `json:"is_ca"`
	ValidAfter  int      `json:"valid_after"`  // unix timestamp
	ValidBefore int      `json:"valid_before"` // unix timestamp
	Comment     string   `json:"comment"`
}

func (*MarshalledAllowedSigner) Unmarshal

func (m *MarshalledAllowedSigner) Unmarshal() (AllowedSigner, error)

type Pattern

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

Pattern is a pattern in a Host declaration. Patterns are read-only values; create a new one with NewPattern().

func NewPattern

func NewPattern(s string) (*Pattern, error)

NewPattern creates a new Pattern for matching hosts. NewPattern("*") creates a Pattern that matches all hosts.

From the manpage, a pattern consists of zero or more non-whitespace characters, `*' (a wildcard that matches zero or more characters), or `?' (a wildcard that matches exactly one character). For example, to specify a set of declarations for any host in the ".co.uk" set of domains, the following pattern could be used:

Host *.co.uk

The following pattern would match any host in the 192.168.0.[0-9] network range:

Host 192.168.0.?

func (Pattern) String

func (p Pattern) String() string

String prints the string representation of the pattern.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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