ssh

package module
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: Apache-2.0 Imports: 13 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var PreferredKexAlgos = []string{
	kexAlgoCurve25519SHA256, kexAlgoCurve25519SHA256LibSSH,
	kexAlgoECDH256, kexAlgoECDH384, kexAlgoECDH521,
	kexAlgoDH14SHA256, kexAlgoDH14SHA1,
	kexAlgoDHGEXSHA256,
}

PreferredKeyAlgos is aligned with the preferredKeyAlgos from golang/crypto with the exception of: - No support for diffie-hellman-group1-sha1. - Includes kexAlgoDHGEXSHA256 as the least preferred option.

Functions

func ScanHostKey

func ScanHostKey(host string, timeout time.Duration, clientHostKeyAlgos []string, hashKeys bool) ([]byte, error)

ScanHostKey collects the given host's preferred public key for the host. Any errors (e.g. authentication failures) are ignored, except if no key could be collected from the host.

clientHostKeyAlgos defines what HostKey algorithms to be used by the ssh client when using `ssh.Dial`. The default is empty, which defaults to Golang's preferred HostKey algorithms.

func SetPreferredKeyAlgos added in v0.1.0

func SetPreferredKeyAlgos(config *ssh.ClientConfig)

SetPreferredKeyAlgos sets the PreferredKexAlgos on a given ClientConfig.

Types

type ECDSAGenerator

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

func (*ECDSAGenerator) Generate

func (g *ECDSAGenerator) Generate() (*KeyPair, error)

type Ed25519Generator

type Ed25519Generator struct{}

func (*Ed25519Generator) Generate

func (g *Ed25519Generator) Generate() (*KeyPair, error)

type HostKeyCollector

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

HostKeyCollector offers a StoreKey method which provides an HostKeyCallBack to collect public keys from an SSH server.

func (*HostKeyCollector) GetKnownKeys

func (c *HostKeyCollector) GetKnownKeys() []byte

GetKnownKeys returns the collected public keys in bytes.

func (*HostKeyCollector) StoreKey

func (c *HostKeyCollector) StoreKey() ssh.HostKeyCallback

StoreKey stores the public key in bytes as returned by the host. To collect multiple public key types from the host, multiple SSH dials need with the ClientConfig HostKeyAlgorithms set to the algorithm you want to collect.

type KeyPair

type KeyPair struct {
	PublicKey  []byte
	PrivateKey []byte
}

KeyPair holds the public and private key PEM block bytes.

func GenerateKeyPair added in v0.3.3

func GenerateKeyPair(keyType KeyPairType) (*KeyPair, error)

GenerateKeyPair generates a keypair based on KeyPairType.

type KeyPairGenerator

type KeyPairGenerator interface {
	Generate() (*KeyPair, error)
}

func NewECDSAGenerator

func NewECDSAGenerator(c elliptic.Curve) KeyPairGenerator

func NewEd25519Generator

func NewEd25519Generator() KeyPairGenerator

func NewRSAGenerator

func NewRSAGenerator(bits int) KeyPairGenerator

type KeyPairType added in v0.3.3

type KeyPairType string
const (
	// RSA_4096 represents a RSA keypair with 4096 bits.
	RSA_4096 KeyPairType = "rsa-4096"
	// ECDSA_P256 represents a ecdsa keypair using Curve P-256.
	ECDSA_P256 KeyPairType = "ecdsa-p256"
	// ECDSA_P384 represents a ecdsa keypair using Curve P-384.
	ECDSA_P384 KeyPairType = "ecdsa-p384"
	// ECDSA_P521 represents a ecdsa keypair using Curve P-521.
	ECDSA_P521 KeyPairType = "ecdsa-p521"
	// ED25519 represents a ed25519 keypair.
	ED25519 KeyPairType = "ed25519"
)

type RSAGenerator

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

func (*RSAGenerator) Generate

func (g *RSAGenerator) Generate() (*KeyPair, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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