ssh

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2023 License: MPL-2.0 Imports: 18 Imported by: 11 modules, 9 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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