ssh

package
v0.0.0-...-0384855 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2024 License: MIT Imports: 14 Imported by: 4

Documentation

Overview

todo we should move this to oses as platform specific

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Options *ClientOptions

	Session *ssh.Session
	// contains filtered or unexported fields
}

func NewClient

func NewClient(ctx context.Context, logger *slog.Logger, options *ClientOptions) *Client

func (*Client) Close

func (s *Client) Close()

func (*Client) CombinedOutput

func (s *Client) CombinedOutput(cmds ...string) ([]byte, error)

func (*Client) CombinedRead

func (s *Client) CombinedRead() ([]byte, error)

func (*Client) Connect

func (s *Client) Connect() (*ssh.Session, error)

Connect to the server, open a session and run a command.

func (*Client) Exec

func (s *Client) Exec(commands ...string) error

func (*Client) Output

func (s *Client) Output(cmds ...string) ([]byte, error)

func (*Client) OutputPtrs

func (s *Client) OutputPtrs(ptrs []*string) error

func (*Client) PossibleRebootWait

func (c *Client) PossibleRebootWait()

func (*Client) RawClient

func (s *Client) RawClient() (*ssh.Client, error)

func (*Client) ReadStderr

func (s *Client) ReadStderr() ([]byte, error)

func (*Client) ReadStdout

func (s *Client) ReadStdout() ([]byte, error)

func (*Client) RemoteInfo

func (s *Client) RemoteInfo() (*RemoteInfo, error)

func (*Client) Run

func (s *Client) Run(cmds ...string) error

func (*Client) Shell

func (s *Client) Shell() error

type ClientOptions

type ClientOptions struct {
	Host      string
	User      string
	Password  string
	IOStreams *streams.IO
	Timeout   time.Duration
}

type RemoteInfo

type RemoteInfo struct {
	OS                string `json:"os" yaml:"os"`
	Hostname          string `json:"hostname" yaml:"hostname"`
	KernelVersion     string `json:"kernel_version" yaml:"kernel_version"`
	KernelRelease     string `json:"kernel_release" yaml:"kernel_release"`
	Architecture      string `json:"arch" yaml:"arch"`
	HetznerRescueMode string `json:"hetzner_rescue_mode" yaml:"hetzner_rescue_mode"`
}

Jump to

Keyboard shortcuts

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