sshx

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2023 License: MIT Imports: 12 Imported by: 1

README

License go.mod Go version GoDoc Latest tag Go Report

standard SSH package eXtended

// TODO

Documentation

Index

Constants

View Source
const ErrSignerNotFound sentinelError = "signer not found"

ErrSignerNotFound is return when the signer is expected to exist but does not.

Variables

This section is empty.

Functions

This section is empty.

Types

type Agent

type Agent struct{ agent.Agent }

Agent contains all kind of methods to manipulate ssh agent.

func NewAgent

func NewAgent() (*Agent, func() error, error)

NewAgent creates a new ssh agent from the unix socket contained in the SSH_AUTH_SOCK environment variable.

func (*Agent) GetSignerMatchingPublicKey

func (a *Agent) GetSignerMatchingPublicKey(pubKey PublicKey) (ssh.Signer, error)

GetSignerMatchingPublicKey returns a signer from the agent matching the provided public key.

func (*Agent) RemoveMatchingPublicKey

func (a *Agent) RemoveMatchingPublicKey(pubKey PublicKey) error

RemoveMatchingPublicKey removes all keys matching the provided public key.

func (*Agent) UpsertCertificate

func (a *Agent) UpsertCertificate(privateKey PrivateKey, cert Certificate) error

UpsertCertificate replaces the provided private key and cert from the agent, if the provided cert is valid.

func (*Agent) UpsertKey

func (a *Agent) UpsertKey(privateKey PrivateKey) error

UpsertKey replaces the provided private key in the agent (remove if exists in the agent then insert it).

type Certificate

type Certificate ssh.Certificate

Certificate aliases ssh.Certificate to extend it.

func NewCertificateFromOpenSSHAuthorizedKeyBytes

func NewCertificateFromOpenSSHAuthorizedKeyBytes(raw []byte) (*Certificate, error)

NewCertificateFromOpenSSHAuthorizedKeyBytes creates a certificate from an authorized ssh key formatted bytes.

func NewCertificateFromOpenSSHAuthorizedKeyFile

func NewCertificateFromOpenSSHAuthorizedKeyFile(filePath string) (*Certificate, error)

NewCertificateFromOpenSSHAuthorizedKeyFile creates a certificate from an authorized ssh key formatted file.

func (Certificate) IsValid

func (c Certificate) IsValid() error

IsValid returns true if a certificate is valid.

type Client

type Client struct {
	*ssh.Client
	// contains filtered or unexported fields
}

Client wraps ssh.Client handle liveness and bridges.

func NewClient

func NewClient(cfg *ClientConfig) (*Client, error)

NewClient returns a new Client.

func (*Client) CheckLivenessUntilNotAlive

func (c *Client) CheckLivenessUntilNotAlive(ctx context.Context, aliveCheckInterval time.Duration, notAliveCountExit uint) error

CheckLivenessUntilNotAlive checks liveness every aliveCheckInterval, if consecutive liveness failure count reach notAliveCountExit, an error is returned.

func (*Client) Close

func (c *Client) Close() error

Close closes the underlying client and all bridges.

func (*Client) IsAlive

func (c *Client) IsAlive() error

IsAlive sends a keepalive ssh request.

type ClientConfig

type ClientConfig struct {
	Addr            string
	SSHClientConfig ssh.ClientConfig
	Bridge          *ClientConfig
}

ClientConfig stores the ssh configuration.

func (*ClientConfig) Validate

func (cfg *ClientConfig) Validate() error

Validate returns whenever the configuration is valid.

type PrivateKey

type PrivateKey interface {
	Signer() ssh.Signer
	PublicKey() PublicKey

	Raw() crypto.PrivateKey
	Equal(PrivateKey) error
}

PrivateKey defines common methods for all ssh private keys.

func NewPrivateKeyFromPEMBytes

func NewPrivateKeyFromPEMBytes(raw []byte, passphraseGetter func() ([]byte, error)) (PrivateKey, error)

NewPrivateKeyFromPEMBytes parses an SSH private key from PEM bytes.

func NewPrivateKeyFromPEMFile

func NewPrivateKeyFromPEMFile(filePath string, passphraseGetter func() ([]byte, error)) (PrivateKey, error)

NewPrivateKeyFromPEMFile parses an SSH private key from a pem file.

func WrapPrivateKey

func WrapPrivateKey(cryptoPrivKey crypto.PrivateKey) (PrivateKey, error)

WrapPrivateKey wraps the provided crypto.PrivateKey.

type PublicKey

type PublicKey interface {
	ssh.PublicKey

	Raw() crypto.PublicKey
	Equal(PublicKey) error
	String() string
}

PublicKey defines common methods for all ssh public keys.

func NewPublicKeyFromOpenSSHAuthorizedKeyBytes

func NewPublicKeyFromOpenSSHAuthorizedKeyBytes(raw []byte) (PublicKey, error)

NewPublicKeyFromOpenSSHAuthorizedKeyBytes parses an SSH public key from PEM bytes.

func NewPublicKeyFromOpenSSHAuthorizedKeyFile

func NewPublicKeyFromOpenSSHAuthorizedKeyFile(filePath string) (PublicKey, error)

NewPublicKeyFromOpenSSHAuthorizedKeyFile parses an SSH public key from PEM file.

func WrapSSHPublicKey

func WrapSSHPublicKey(sshPublicKey ssh.PublicKey) PublicKey

WrapSSHPublicKey wraps the provided ssh.PublicKey.

Jump to

Keyboard shortcuts

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