Documentation ¶
Index ¶
- type HostKey
- type HostKeyAlgorithm
- type Intercept
- type SSH2
- func (ssh *SSH2) Context(parent component.InstallationContext) component.InstallationContext
- func (ssh2 *SSH2) HandleRoute(ctx context.Context, path string) (http.Handler, error)
- func (ssh2 *SSH2) Intercepts() []Intercept
- func (ssh *SSH2) Path() string
- func (ssh2 *SSH2) ReadOrMakeHostKey(progress io.Writer, ctx context.Context, privateKeyPath string, ...) (key gossh.Signer, err error)
- func (ssh2 *SSH2) Routes() component.Routes
- func (ssh2 *SSH2) Server(ctx context.Context, privateKeyPath string, progress io.Writer) (*ssh.Server, error)
- func (ssh *SSH2) Stack() component.StackWithResources
- func (ssh2 *SSH2) UseOrMakeHostKey(progress io.Writer, ctx context.Context, server *ssh.Server, ...) error
- func (ssh2 *SSH2) UseOrMakeHostKeys(progress io.Writer, ctx context.Context, server *ssh.Server, ...) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HostKey ¶
type HostKey interface { ssh.Signer // Algorithm is the Algorithm used by this HostKey implementation. Algorithm() HostKeyAlgorithm // Generate generates a new HostKey, discarding whatever was previsouly contained. // // keySize is the desired public key size in bits. When keySize is 0, a sensible default is used. // random is the source of randomness. If random is nil, crypto/rand.Reader will be used. Generate(ctx context.Context, keySize int, random io.Reader) error // MarshalPEM marshals the private key into a pem.Block to be used for exporting. // The format is not guaranteed to follow any kind of standard, only that it is readable with the corresponding UnmarshalPEM. MarshalPEM() (*pem.Block, error) // UnmarshalPEM unmarshals the private key from a pem.Block. // It is only compatible with whatever MarshalPEM() outputted. UnmarshalPEM(block *pem.Block) error }
HostKey represents an pair of ssh private key and algorithm. Once the hostkey is generated or loaded, it is safe for concurrent accesses.
func NewHostKey ¶
func NewHostKey(algorithm HostKeyAlgorithm) HostKey
NewHostKey returns a new empty HostKey for the provided HostKey Algorithm. An unsupported HostKeyAlgorithm will result in a call to panic().
type HostKeyAlgorithm ¶
type HostKeyAlgorithm string
HostKeyAlgorithm is an enumerated value that represents a specific algorithm used for host keys.
const ( // RSAAlgorithm represents the RSA Algorithm RSAAlgorithm HostKeyAlgorithm = "rsa" // ED25519Algorithm represents the ED25519 algorithm ED25519Algorithm HostKeyAlgorithm = "ed25519" )
type Intercept ¶
func (Intercept) ExamplePort ¶
ExamplePort returns a local port that can be forwarded to without root rights
type SSH2 ¶
type SSH2 struct { component.Base Dependencies struct { SQL *sql.SQL Instances *instances.Instances Auth *auth.Auth Keys *sshkeys.SSHKeys } // contains filtered or unexported fields }
func (*SSH2) Context ¶
func (ssh *SSH2) Context(parent component.InstallationContext) component.InstallationContext
func (*SSH2) HandleRoute ¶
func (*SSH2) Intercepts ¶
func (*SSH2) ReadOrMakeHostKey ¶
func (ssh2 *SSH2) ReadOrMakeHostKey(progress io.Writer, ctx context.Context, privateKeyPath string, algorithm HostKeyAlgorithm) (key gossh.Signer, err error)
ReadOrMakeHostKey attempts to load a host key from the given privateKeyPath. If the path does not exist, a new key is generated.
This function assumes that if there is a host key in privateKeyPath it uses the provided HostKeyAlgorithm. It makes no attempt at verifiying this; the key mail fail to load and return an error, or it may load incorrect data.
func (*SSH2) Server ¶
func (ssh2 *SSH2) Server(ctx context.Context, privateKeyPath string, progress io.Writer) (*ssh.Server, error)
Server returns an ssh server that implements the main ssh server
func (*SSH2) Stack ¶
func (ssh *SSH2) Stack() component.StackWithResources
func (*SSH2) UseOrMakeHostKey ¶
func (ssh2 *SSH2) UseOrMakeHostKey(progress io.Writer, ctx context.Context, server *ssh.Server, privateKeyPath string, algorithm HostKeyAlgorithm) error
UseOrMakeHostKey attempts to load a host key from the given privateKeyPath. If the path does not exist, a new host key is generated. It then adds this hostkey to the priovided server.
All parameters except the server are passed to ReadOrMakeHostKey. Please see the appropriate documentation for that function.
func (*SSH2) UseOrMakeHostKeys ¶
func (ssh2 *SSH2) UseOrMakeHostKeys(progress io.Writer, ctx context.Context, server *ssh.Server, privateKeyPath string, algorithms []HostKeyAlgorithm) error
UseOrMakeHostKeys is like UseOrMakeHostKey except that it accepts multiple HostKeyAlgorithms. For each key algorithm, the privateKeyPath is appended with "_" + the name of the algorithm in question.
When algorithms is nil, picks a reasonable set of default algorithms.