Documentation
¶
Overview ¶
Package sshclient provides configuration structs for constructing SSH clients.
Example ¶
package main import ( "context" "encoding/json" "htdvisser.dev/exp/ssh/sshclient" ) func main() { configJSON := `{ "address": "localhost:2222", "host_key": { "source": "known_hosts", "known_hosts": { "file": "testdata/known_hosts" } }, "username": "testuser", "auth_methods": [ { "method": "private_keys", "private_keys": [ { "file": "testdata/id_ed25519" }, { "file": "testdata/id_ecdsa" }, { "file": "testdata/id_rsa" } ] }, { "method": "password", "password": "testpassword" } ] }` var config sshclient.ConnectConfig if err := json.Unmarshal([]byte(configJSON), &config); err != nil { // handle error return } _, client, err := config.Dial(context.Background()) if err != nil { // handle error return } client.Close() }
Output:
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AuthMethodConfig ¶
type AuthMethodConfig struct { Method string `json:"method" yaml:"method"` Password string `json:"password" yaml:"password"` PrivateKeys []hssh.PrivateKeyConfig `json:"private_keys" yaml:"private_keys"` AWSKMS aws.KMSConfig `json:"aws_kms" yaml:"aws_kms"` }
AuthMethodConfig is the configuration for the authentication method.
func (AuthMethodConfig) Validate ¶
func (c AuthMethodConfig) Validate() error
Validate validates the configuration and returns an error if it is not valid.
type BannerConfig ¶
type BannerConfig struct { }
BannerConfig is the configuration for handling the banner received from the SSH server.
func (BannerConfig) Validate ¶
func (BannerConfig) Validate() error
Validate validates the configuration and returns an error if it is not valid.
type ConnectConfig ¶
type ConnectConfig struct { Address string `json:"address" yaml:"address"` Jump string `json:"jump" yaml:"jump"` Timeout time.Duration `json:"timeout,omitempty" yaml:"timeout,omitempty"` KeepAlive time.Duration `json:"keep_alive,omitempty" yaml:"keep_alive,omitempty"` HostKey HostKeyConfig `json:"host_key,omitempty" yaml:"host_key,omitempty"` Banner BannerConfig `json:"banner,omitempty" yaml:"banner,omitempty"` ClientVersion string `json:"client_version,omitempty" yaml:"client_version,omitempty"` Username string `json:"username" yaml:"username"` AuthMethods []AuthMethodConfig `json:"auth_methods" yaml:"auth_methods"` }
ConnectConfig is the configuration for connecting to an SSH server.
func (ConnectConfig) Validate ¶
func (c ConnectConfig) Validate() error
Validate validates the configuration and returns an error if it is not valid.
type HostKeyConfig ¶
type HostKeyConfig struct { Source string `json:"source" yaml:"source"` KnownHosts struct { File string `json:"file" yaml:"file"` } `json:"known_hosts" yaml:"known_hosts"` }
HostKeyConfig is the configuration for host key verification.
func (HostKeyConfig) Validate ¶
func (c HostKeyConfig) Validate() error
Validate validates the configuration and returns an error if it is not valid.