ssh

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2021 License: MPL-2.0 Imports: 17 Imported by: 7

Documentation

Overview

Package SSH provides tooling for generating a temporary SSH keypair, and provides tooling for connecting to an instance via a tunnel.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FileSigner

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

FileSigner returns an ssh.Signer for a key file.

func FileSignerWithCert

func FileSignerWithCert(path string, certificatePath string) (ssh.Signer, error)

FileSigner returns an ssh.Signer for a key file.

func ParseTunnelArgument

func ParseTunnelArgument(forward string, direction ssh.TunnelDirection) (ssh.TunnelSpec, error)

ParseTunnelArgument parses an SSH tunneling argument compatible with the openssh client form. Valid formats: `port:host:hostport` NYI `[bind_address:]port:host:hostport`

func ReadCertificate

func ReadCertificate(certificatePath string, keySigner ssh.Signer) (ssh.Signer, error)

Types

type CreateKeyPairConfig

type CreateKeyPairConfig struct {
	// Type describes the key pair's type.
	Type KeyPairType

	// Bits represents the key pair's bits of entropy. E.g., 4096 for
	// a 4096 bit RSA key pair, or 521 for a ECDSA key pair with a
	// 521-bit curve.
	Bits int

	// Comment is the resulting key pair's comment. This is typically
	// used to identify the key pair's owner in the SSH user's
	// 'authorized_keys' file.
	Comment string
}

CreateKeyPairConfig describes how an SSH key pair should be created.

type FromPrivateKeyConfig

type FromPrivateKeyConfig struct {
	// RawPrivateKeyPemBlock is the raw private key that the key pair
	// should be loaded from.
	RawPrivateKeyPemBlock []byte

	// Comment is the key pair's comment. This is typically used
	// to identify the key pair's owner in the SSH user's
	// 'authorized_keys' file.
	Comment string
}

FromPrivateKeyConfig describes how an SSH key pair should be loaded from an existing private key.

type KeyPair

type KeyPair struct {
	// PrivateKeyPemBlock represents the key pair's private key in
	// ASN.1 Distinguished Encoding Rules (DER) format in a
	// Privacy-Enhanced Mail (PEM) block.
	PrivateKeyPemBlock []byte

	// PublicKeyAuthorizedKeysLine represents the key pair's public key
	// as a line in OpenSSH authorized_keys.
	PublicKeyAuthorizedKeysLine []byte

	// Comment is the key pair's comment. This is typically used
	// to identify the key pair's owner in the SSH user's
	// 'authorized_keys' file.
	Comment string
}

KeyPair represents an SSH key pair.

func KeyPairFromPrivateKey

func KeyPairFromPrivateKey(config FromPrivateKeyConfig) (KeyPair, error)

KeyPairFromPrivateKey returns a KeyPair loaded from an existing private key.

Supported key pair types include:

  • DSA
  • ECDSA
  • ED25519
  • RSA

func NewKeyPair

func NewKeyPair(config CreateKeyPairConfig) (KeyPair, error)

NewKeyPair generates a new SSH key pair using the specified CreateKeyPairConfig.

type KeyPairType

type KeyPairType string

KeyPairType represents different types of SSH key pairs. See the 'const' block for details.

const (

	// Markers for various SSH key pair types.
	Default KeyPairType = ""
	Rsa     KeyPairType = "RSA"
	Ecdsa   KeyPairType = "ECDSA"
	Dsa     KeyPairType = "DSA"
	Ed25519 KeyPairType = "ED25519"
)

func (KeyPairType) String

func (o KeyPairType) String() string

Jump to

Keyboard shortcuts

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