clissh

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2026 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckLocalPath

func CheckLocalPath(path string) (string, error)

CheckLocalPath see if file exists and determine if it is a directory. Error is returned if file is not exists.

func CreateEmptyTmpFile

func CreateEmptyTmpFile(sett settings.Settings) (string, error)

Types

type Agent

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

func NewAgent

func NewAgent(sshSettings settings.Settings, agentSettings *session.AgentSettings) *Agent

func (*Agent) AddKeys

func (a *Agent) AddKeys(keys []session.AgentPrivateKey) error

TODO replace with x/crypto/ssh/agent ?

func (*Agent) Start

func (a *Agent) Start() error

func (*Agent) Stop

func (a *Agent) Stop()

type Client

type Client struct {
	SessionSettings *session.Session
	Agent           *Agent

	InitializeNewAgent bool
	// contains filtered or unexported fields
}

func NewClient

func NewClient(sett settings.Settings, session *session.Session, privKeys []session.AgentPrivateKey, initNewAgent bool) *Client

func (*Client) Check

func (s *Client) Check() connection.Check

Check is used to upload script and execute it on remote server

func (*Client) Command

func (s *Client) Command(name string, arg ...string) connection.Command

Command is used to run commands on remote server

func (*Client) File

func (s *Client) File() connection.File

File is used to upload and download files and directories

func (*Client) IsStopped

func (s *Client) IsStopped() bool

func (*Client) KubeProxy

func (s *Client) KubeProxy() connection.KubeProxy

KubeProxy is used to start kubectl proxy and create a tunnel from local port to proxy port

func (*Client) Loop

func (s *Client) Loop(fn connection.SSHLoopHandler) error

Loop Looping all available hosts

func (*Client) OnlyPreparePrivateKeys

func (s *Client) OnlyPreparePrivateKeys() error

func (*Client) PrivateKeys

func (s *Client) PrivateKeys() []session.AgentPrivateKey

func (*Client) RefreshPrivateKeys

func (s *Client) RefreshPrivateKeys() error

func (*Client) ReverseTunnel

func (s *Client) ReverseTunnel(address string) connection.ReverseTunnel

ReverseTunnel is used to open remote (R) tunnel

func (*Client) Session

func (s *Client) Session() *session.Session

func (*Client) Settings

func (s *Client) Settings() settings.Settings

func (*Client) Start

func (s *Client) Start() error

func (*Client) Stop

func (s *Client) Stop()

Stop the client

func (*Client) Tunnel

func (s *Client) Tunnel(address string) connection.Tunnel

Tunnel is used to open local (L) and remote (R) tunnels

func (*Client) UploadScript

func (s *Client) UploadScript(scriptPath string, args ...string) connection.Script

UploadScript is used to upload script and execute it on remote server

func (*Client) WithID

func (s *Client) WithID(id string) *Client

type Command

type Command struct {
	*process.Executor

	Session *session.Session

	Name string
	Args []string
	Env  []string

	SSHArgs []string
	// contains filtered or unexported fields
}

func NewCommand

func NewCommand(sett settings.Settings, sess *session.Session, name string, arg ...string) *Command

func (*Command) Cmd

func (c *Command) Cmd(ctx context.Context)

func (*Command) CombinedOutput

func (c *Command) CombinedOutput(ctx context.Context) ([]byte, error)

func (*Command) OnCommandStart

func (c *Command) OnCommandStart(fn func())

func (*Command) Output

func (c *Command) Output(ctx context.Context) ([]byte, []byte, error)

func (*Command) Sudo

func (c *Command) Sudo(ctx context.Context)

func (*Command) WithEnv

func (c *Command) WithEnv(env map[string]string)

func (*Command) WithSSHArgs

func (c *Command) WithSSHArgs(args ...string)

func (*Command) WithTimeout

func (c *Command) WithTimeout(timeout time.Duration)

type File

type File struct {
	Session *session.Session
	// contains filtered or unexported fields
}

func NewFile

func NewFile(sett settings.Settings, sess *session.Session) *File

func (*File) Download

func (f *File) Download(ctx context.Context, remotePath, dstPath string) error

func (*File) DownloadBytes

func (f *File) DownloadBytes(ctx context.Context, remotePath string) ([]byte, error)

Download remote file and returns its content as an array of bytes.

func (*File) Upload

func (f *File) Upload(ctx context.Context, srcPath, remotePath string) error

func (*File) UploadBytes

func (f *File) UploadBytes(ctx context.Context, data []byte, remotePath string) error

UploadBytes creates a tmp file and upload it to remote dstPath

type KubeProxy

type KubeProxy struct {
	*kubeproxy.BaseKubeProxy
}

func NewKubeProxy

func NewKubeProxy(client *Client) *KubeProxy

type ReverseTunnel

type ReverseTunnel struct {
	Session *session.Session
	Address string
	// contains filtered or unexported fields
}

func NewReverseTunnel

func NewReverseTunnel(sett settings.Settings, sess *session.Session, address string) *ReverseTunnel

func (*ReverseTunnel) StartHealthMonitor

func (t *ReverseTunnel) StartHealthMonitor(ctx context.Context, checker connection.ReverseTunnelChecker, killer connection.ReverseTunnelKiller)

func (*ReverseTunnel) Stop

func (t *ReverseTunnel) Stop()

func (*ReverseTunnel) String

func (t *ReverseTunnel) String() string

func (*ReverseTunnel) Up

func (t *ReverseTunnel) Up() error

type Tunnel

type Tunnel struct {
	Session *session.Session
	Type    string // Remote or Local
	Address string
	// contains filtered or unexported fields
}

func NewTunnel

func NewTunnel(sett settings.Settings, sess *session.Session, ttype, address string) *Tunnel

func (*Tunnel) HealthMonitor

func (t *Tunnel) HealthMonitor(errorOutCh chan<- error)

func (*Tunnel) Stop

func (t *Tunnel) Stop()

func (*Tunnel) String

func (t *Tunnel) String() string

func (*Tunnel) Up

func (t *Tunnel) Up(ctx context.Context) error

type UploadScript

type UploadScript struct {
	ScriptPath string
	Args       []string
	// contains filtered or unexported fields
}

func NewUploadScript

func NewUploadScript(sett settings.Settings, client *Client, scriptPath string, args ...string) *UploadScript

func (*UploadScript) Execute

func (u *UploadScript) Execute(ctx context.Context) ([]byte, error)

func (*UploadScript) ExecuteBundle

func (u *UploadScript) ExecuteBundle(ctx context.Context, parentDir, bundleDir string) ([]byte, error)

func (*UploadScript) IsSudo

func (u *UploadScript) IsSudo() bool

func (*UploadScript) Settings

func (u *UploadScript) Settings() settings.Settings

func (*UploadScript) Sudo

func (u *UploadScript) Sudo()

func (*UploadScript) UploadDir

func (u *UploadScript) UploadDir() string

func (*UploadScript) WithBundlerOpts

func (u *UploadScript) WithBundlerOpts(opts ...connection.BundlerOption)

func (*UploadScript) WithCleanupAfterExec

func (u *UploadScript) WithCleanupAfterExec(doCleanup bool)

WithCleanupAfterExec option tells if ssh executor should delete uploaded script after execution was attempted or not. It does not care if script was executed successfully of failed.

func (*UploadScript) WithEnvs

func (u *UploadScript) WithEnvs(envs map[string]string)

func (*UploadScript) WithExecuteUploadDir

func (u *UploadScript) WithExecuteUploadDir(dir string)

func (*UploadScript) WithNoLogStepOutOnError

func (u *UploadScript) WithNoLogStepOutOnError(enabled bool)

func (*UploadScript) WithStdoutHandler

func (u *UploadScript) WithStdoutHandler(handler func(string))

func (*UploadScript) WithTimeout

func (u *UploadScript) WithTimeout(timeout time.Duration)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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