Documentation ¶
Index ¶
Constants ¶
const ( // SSHKeySize is the size of the SSH key. SSHKeySize = 4096 KnownHostsFile = "grafana_pdc_known_hosts" )
const ( // The exit code sent by the pdc server when the connection limit is reached. ConnectionLimitReachedCode = 254 ConnectionAlreadyExistsCode = 253 )
Variables ¶
This section is empty.
Functions ¶
func RequireSSHVersionAbove9_2 ¶ added in v0.0.24
Types ¶
type Client ¶ added in v0.0.6
type Client struct { *services.BasicService SSHCmd string // SSH command to run, defaults to "ssh". Require for testing. // contains filtered or unexported fields }
Client is a client for ssh. It configures and runs ssh commands
func NewClient ¶
func NewClient(cfg *Config, logger log.Logger, km *KeyManager) *Client
NewClient returns a new SSH client in an idle state
func (*Client) Collect ¶ added in v0.0.33
func (s *Client) Collect(ch chan<- prometheus.Metric)
func (*Client) Describe ¶ added in v0.0.33
func (s *Client) Describe(ch chan<- *prometheus.Desc)
func (*Client) SSHFlagsFromConfig ¶ added in v0.0.6
SSHFlagsFromConfig generates the array of flags to pass to the ssh command. It does not stop default flags from being overidden, but only the first instance of `-o` flags are used.
type Config ¶
type Config struct { Args []string // deprecated KeyFile string SSHFlags []string // Additional flags to be passed to ssh(1). e.g. --ssh-flag="-vvv" --ssh-flag="-L 80:localhost:80" Port int LogLevel string PDC pdc.Config LegacyMode bool SkipSSHValidation bool // ForceKeyFileOverwrite forces a new ssh key pair to be generated. ForceKeyFileOverwrite bool // CertExpiryWindow is the time before the certificate expires to renew it. CertExpiryWindow time.Duration // CertCheckCertExpiryPeriod is how often to check that the current certificate // is valid and regenerate it if necessary. CertCheckCertExpiryPeriod time.Duration URL *url.URL // MetricsAddr is the port to expose metrics on MetricsAddr string ParseMetrics bool // Used for local development. // DevPort is the port number for the PDC gateway DevPort int }
Config represents all configurable properties of the ssh package.
func DefaultConfig ¶ added in v0.0.6
func DefaultConfig() *Config
DefaultConfig returns a Config with some sensible defaults set
func (Config) KeyFileDir ¶ added in v0.0.6
func (*Config) RegisterFlags ¶ added in v0.0.6
type KeyManager ¶ added in v0.0.6
type KeyManager struct {
// contains filtered or unexported fields
}
TODO KeyManager implements KeyManager. If needed, it gets new certificates signed by the PDC API.
If the service starts successfully, then the key and cert files will exist. It will attempt to reuse existing keys and certs if they exist.
func NewKeyManager ¶ added in v0.0.6
NewKeyManager returns a new KeyManager in an idle state
func (*KeyManager) CreateKeys ¶ added in v0.0.6
func (km *KeyManager) CreateKeys(ctx context.Context, forceNewKeys bool) error
CreateKeys checks that the SSH public key, private key, certificate and known_hosts files for existence and validity, and generates new ones if required.