util

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrKeyPassphraseRequired = errors.New("the ssh key requires a passphrase")

ErrKeyPassphraseRequired is a sentinel error for missing passphrases

Functions

func ErrorContains

func ErrorContains(out error, want string) bool

ErrorContains checks error contents see https://stackoverflow.com/a/55803656

func LoadAuthorizedKeys

func LoadAuthorizedKeys(filename string) (map[ssh.PublicKey]bool, error)

LoadAuthorizedKeys loads authorized_keys from file

func LoadPrivateKey

func LoadPrivateKey(filename string) (ssh.Signer, error)

LoadPrivateKey loads a private key from file (best not to use)

func LoadPrivateKeyBytesWithPassword

func LoadPrivateKeyBytesWithPassword(keyBytes []byte, passphrase []byte) (ssh.Signer, error)

LoadPrivateKeyBytesWithPassword loads a private key with password from bytes

func LoadPrivateKeyWithPassword

func LoadPrivateKeyWithPassword(filename string, passphrase []byte) (ssh.Signer, error)

LoadPrivateKeyWithPassword loads a private key with password from file

func LoadPublicKey

func LoadPublicKey(filename string) (ssh.PublicKey, error)

LoadPublicKey loads a public key from file

func LoadPublicKeyBytes

func LoadPublicKeyBytes(key []byte) (ssh.PublicKey, error)

LoadPublicKeyBytes loads a public key from bytes

Types

type Settings

type Settings struct {
	Validity     uint32            `yaml:"validity"`
	Organisation string            `yaml:"organisation"`
	Banner       string            `yaml:"banner"`
	Extensions   map[string]string `yaml:"extensions,flow"`
	Users        []*UserPrincipals `yaml:"user_principals"`
	// contains filtered or unexported fields
}

Settings sets out the main yaml settings structure, which incorporates a slice of UserPrincipals together with general server settings

func SettingsLoad

func SettingsLoad(yamlFilePath string) (Settings, error)

SettingsLoad loads a settings yaml file into a Settings struct

func (*Settings) UserByFingerprint

func (s *Settings) UserByFingerprint(fp string) (*UserPrincipals, error)

UserByFingerprint extracts a user's UserPrincipals struct by public key fingerprint

type UserPrincipals

type UserPrincipals struct {
	Name        string
	Principals  []string
	PublicKey   ssh.PublicKey
	Fingerprint string
}

UserPrincipals are configured in the yaml settings file to have certificates created for the stated Principals given access to the sshagentca server with SSHPublicKey. SSH Key fingerprints are used for lookups as these are more convenient for logging. See settings.example.yaml for the example settings file.

func (*UserPrincipals) UnmarshalYAML

func (up *UserPrincipals) UnmarshalYAML(value *yaml.Node) (err error)

UnmarshalYAML unmarshals the Users slice of a yaml file

Jump to

Keyboard shortcuts

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