ssh

package
v0.10.2 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2022 License: MPL-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Contains the port that the ssh server should listen on. The number should be
	// base 10 encoded.
	ENVSSHPort = "WAYPOINT_EXEC_PLUGIN_SSH"

	// hostKey contains an SSH RSA private key, marshaled as PKCS1 and armored
	// with base64. This will be used as the servers host key and verified
	// by the client when it connects.
	ENVHostKey = "WAYPOINT_EXEC_PLUGIN_SSH_HOST_KEY"

	ENVUserKey = "WAYPOINT_EXEC_PLUGIN_SSH_KEY"
)

Variables

View Source
var ErrMissingSSHKey = errors.New("missing ssh key information in environment")

Functions

func DecodeFromEnv

func DecodeFromEnv() (ssh.Signer, ssh.PublicKey, error)

DecodeFromEnv reads the processes environment data and decodes the host and user keys from it, returning ready to use representations of those keys.

func MarshalPrivateKey

func MarshalPrivateKey(key *rsa.PrivateKey) string

MarshalPrivateKey converts the key to a string, such that UnmarshalPrivateKey can return the same key.

func MarshalPublicKey

func MarshalPublicKey(key *rsa.PublicKey) string

MarshalPublicKey converts a PubilcKey into a string that can be decoded by UnmarshalPublicKey.

func UnmarshalPrivateKey

func UnmarshalPrivateKey(str string) (*rsa.PrivateKey, error)

UnmarshalPrivateKey parses the string into a rsa.PrivateKey.

func UnmarshalPublicKey

func UnmarshalPublicKey(str string) (*rsa.PublicKey, ssh.PublicKey, error)

UnmarshalPublicKey parses a string into a PubilcKey. Both keys are the same value, just different representations.

Types

type SSHKeyMaterial

type SSHKeyMaterial struct {
	// The rsa host key to use for the SSH server. Armored as a string for easy passage.
	HostPrivate string

	// The public half of the host key. Use this to authenticate the server when connecting.
	HostPublic ssh.PublicKey

	// The private key of the client. Use this to authenticate with the server as the client.
	UserPrivate ssh.Signer

	// The public half of the client key. The server uses this to authenticate the client.
	UserPublic string

	// The raw user key, provided in for further usage.
	UserKey *rsa.PrivateKey

	// The raw host key, provided in for further usage.
	HostKey *rsa.PrivateKey
}

SSHKeyMaterial holds the key material required to setup an SSH connection between a server and client. These are commonly used by exec plugins and the waypoint entrypoint to create adhoc ssh servers that can run a users command.

func GenerateKeys

func GenerateKeys() (*SSHKeyMaterial, error)

GenerateKeys generates a new SSHKeyMaterial with random keys.

Jump to

Keyboard shortcuts

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