bylib

package
v22.11.9 Latest Latest
Warning

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

Go to latest
Published: May 30, 2023 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PublicKeyFromStr

func PublicKeyFromStr(keyStr string) ssh.AuthMethod

PublicKeyFromStr ...

Types

type LibCommand

type LibCommand struct {
	// contains filtered or unexported fields
}

LibCommand defines an SSH command

func (*LibCommand) Close

func (sc *LibCommand) Close() fail.Error

Close this function exists only to provide compatibility with previous SSH api

func (*LibCommand) Display

func (sc *LibCommand) Display() string

Display ...

func (*LibCommand) NewRunWithTimeout

func (sc *LibCommand) NewRunWithTimeout(ctx context.Context, outs outputs.Enum, timeout time.Duration) (int, string, string, fail.Error)

NewRunWithTimeout ...

func (*LibCommand) Output

func (sc *LibCommand) Output() (_ []byte, ferr error)

Output runs the command and returns its standard output. Any returned error will usually be of type *ExitError. If c.Stderr was nil, Output populates ExitError.Stderr.

func (*LibCommand) RunWithTimeout

func (sc *LibCommand) RunWithTimeout(ctx context.Context, outs outputs.Enum, timeout time.Duration) (int, string, string, fail.Error)

RunWithTimeout ...

func (*LibCommand) String

func (sc *LibCommand) String() string

type Profile

type Profile struct {
	Hostname               string        `json:"hostname"`
	IPAddress              string        `json:"ip_address"`
	Port                   int           `json:"port"`
	User                   string        `json:"user"`
	PrivateKey             string        `json:"private_key"`
	LocalPort              int           `json:"-"`
	LocalHost              string        `json:"local_host"`
	GatewayConfig          sshapi.Config `json:"primary_gateway_config,omitempty"`
	SecondaryGatewayConfig sshapi.Config `json:"secondary_gateway_config,omitempty"`
}

Profile helper to manage ssh session

func NewConnector

func NewConnector(ac sshapi.Config) (*Profile, fail.Error)

func NewProfile

func NewProfile(hostname string, ipAddress string, port int, user string, privateKey string, localPort int, localHost string, gatewayConfig sshapi.Config, secondaryGatewayConfig sshapi.Config) *Profile

func (*Profile) Command

func (sconf *Profile) Command(cmdString string) (*LibCommand, fail.Error)

Command returns the cmd struct to execute cmdString remotely

func (*Profile) Config

func (sconf *Profile) Config() (sshapi.Config, fail.Error)

func (*Profile) CopyWithTimeout

func (sconf *Profile) CopyWithTimeout(ctx context.Context, remotePath string, localPath string, isUpload bool, timeout time.Duration) (int, string, string, fail.Error)

CopyWithTimeout ...

func (*Profile) CreatePersistentTunneling

func (sconf *Profile) CreatePersistentTunneling() fail.Error

func (*Profile) CreateTunneling

func (sconf *Profile) CreateTunneling(ctx context.Context) (*sshtunnel.SSHTunnel, *Profile, error)

CreateTunneling ...

func (*Profile) Enter

func (sconf *Profile) Enter(ctx context.Context, username string, _ string) (ferr fail.Error)

Enter runs interactive shell

func (*Profile) GetGatewayConfig

func (sconf *Profile) GetGatewayConfig(num uint) (sshapi.Config, fail.Error)

func (*Profile) GetHostname

func (sconf *Profile) GetHostname() (string, fail.Error)

func (*Profile) GetIPAddress

func (sconf *Profile) GetIPAddress() (string, fail.Error)

func (*Profile) GetLocalHost

func (sconf *Profile) GetLocalHost() (string, fail.Error)

func (*Profile) GetLocalPort

func (sconf *Profile) GetLocalPort() (uint, fail.Error)

func (*Profile) GetPort

func (sconf *Profile) GetPort() (uint, fail.Error)

func (*Profile) GetPrimaryGatewayConfig

func (sconf *Profile) GetPrimaryGatewayConfig() (sshapi.Config, fail.Error)

func (*Profile) GetPrivateKey

func (sconf *Profile) GetPrivateKey() (string, fail.Error)

func (*Profile) GetSecondaryGatewayConfig

func (sconf *Profile) GetSecondaryGatewayConfig() (sshapi.Config, fail.Error)

func (*Profile) GetUser

func (sconf *Profile) GetUser() (string, fail.Error)

func (*Profile) HasGateways

func (sconf *Profile) HasGateways() (bool, fail.Error)

func (*Profile) NewCommand

func (sconf *Profile) NewCommand(_ context.Context, cmdString string) (sshapi.Command, fail.Error)

NewCommand returns the cmd struct to execute cmdString remotely

func (*Profile) NewSudoCommand

func (sconf *Profile) NewSudoCommand(_ context.Context, cmdString string) (sshapi.Command, fail.Error)

NewSudoCommand returns the cmd struct to execute cmdString remotely. Command is executed with sudo

func (*Profile) SudoCommand

func (sconf *Profile) SudoCommand(cmdString string) (*LibCommand, fail.Error)

SudoCommand returns the cmd struct to execute cmdString remotely. Command is executed with sudo

func (*Profile) WaitServerReady

func (sconf *Profile) WaitServerReady(ctx context.Context, phase string, timeout time.Duration) (out string, err fail.Error)

WaitServerReady waits until the SSH server is ready the 'timeout' parameter is in minutes

type Tunnel

type Tunnel struct {
	// contains filtered or unexported fields
}

Tunnel a SSH tunnel

Jump to

Keyboard shortcuts

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