ssh

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2023 License: MIT Imports: 27 Imported by: 1

Documentation

Overview

Package ssh implements SSH transport.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DialConnCtx

func DialConnCtx(ctx context.Context, conn net.Conn, addr string, config *ssh.ClientConfig) (*ssh.Client, error)

func DialCtx

func DialCtx(ctx context.Context, network, addr string, config *ssh.ClientConfig) (*ssh.Client, error)

DialCtx ssh.Dial version with context arg

Types

type Endpoint

type Endpoint struct {
	Host string
	Port int
	User string
}

func NewEndpoint

func NewEndpoint(s string) *Endpoint

func (*Endpoint) String

func (endpoint *Endpoint) String() string

type SSHSignersLogger

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

SSHSignersLogger wraps ssh.Signer interface in order to log actions relateds to keys

func NewSSHSignersLogger

func NewSSHSignersLogger(s ssh.Signer, logger *zap.Logger) *SSHSignersLogger

func (SSHSignersLogger) PublicKey

func (m SSHSignersLogger) PublicKey() ssh.PublicKey

func (SSHSignersLogger) Sign

func (m SSHSignersLogger) Sign(rand io.Reader, data []byte) (*ssh.Signature, error)

type SSHSignersLoggerAlgorithmSigner

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

func NewSSHSignersAlgorithmSignerLogger

func NewSSHSignersAlgorithmSignerLogger(s ssh.AlgorithmSigner, logger *zap.Logger) *SSHSignersLoggerAlgorithmSigner

func (SSHSignersLoggerAlgorithmSigner) PublicKey

func (SSHSignersLoggerAlgorithmSigner) Sign

func (m SSHSignersLoggerAlgorithmSigner) Sign(rand io.Reader, data []byte) (*ssh.Signature, error)

func (SSHSignersLoggerAlgorithmSigner) SignWithAlgorithm

func (m SSHSignersLoggerAlgorithmSigner) SignWithAlgorithm(rand io.Reader, data []byte, algorithm string) (*ssh.Signature, error)

type SSHTunnel

type SSHTunnel struct {
	Server *Endpoint
	Config *ssh.ClientConfig
	// contains filtered or unexported fields
}

func NewSSHTunnel

func NewSSHTunnel(tunnel string, credentials credentials.Credentials, opts ...SSHTunnelOption) *SSHTunnel

func (*SSHTunnel) Close

func (m *SSHTunnel) Close()

func (*SSHTunnel) CreateConnect

func (m *SSHTunnel) CreateConnect(ctx context.Context) error

func (*SSHTunnel) IsConnected

func (m *SSHTunnel) IsConnected() bool

func (*SSHTunnel) StartForward

func (m *SSHTunnel) StartForward(remoteAddr string) (net.Conn, error)

type SSHTunnelOption

type SSHTunnelOption func(m *SSHTunnel)

func SSHTunnelWithLogger

func SSHTunnelWithLogger(log *zap.Logger) SSHTunnelOption

type Streamer

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

func NewNetconfStreamer

func NewNetconfStreamer(host string, credentials credentials.Credentials, opts ...StreamerOption) *Streamer

func NewStreamer

func NewStreamer(host string, credentials credentials.Credentials, opts ...StreamerOption) *Streamer

func (*Streamer) Close

func (m *Streamer) Close()

func (*Streamer) Cmd

func (m *Streamer) Cmd(ctx context.Context, cmd string) (gcmd.CmdRes, error)

func (*Streamer) Download

func (m *Streamer) Download(filePaths []string, recurse bool) (map[string]streamer.File, error)

func (*Streamer) EnableSFTP

func (m *Streamer) EnableSFTP()

func (*Streamer) GetConfig

func (m *Streamer) GetConfig(ctx context.Context) (*ssh.ClientConfig, error)

func (*Streamer) GetCredentials

func (m *Streamer) GetCredentials() credentials.Credentials

func (*Streamer) HasFeature

func (m *Streamer) HasFeature(feature streamer.Const) bool

func (*Streamer) Init

func (m *Streamer) Init(ctx context.Context) error

func (*Streamer) InitAgentForward

func (m *Streamer) InitAgentForward() error

func (*Streamer) Read

func (m *Streamer) Read(ctx context.Context, size int) ([]byte, error)

func (*Streamer) ReadTo

func (m *Streamer) ReadTo(ctx context.Context, expr expr.Expr) (streamer.ReadRes, error)

func (*Streamer) SetCredentialsInterceptor

func (m *Streamer) SetCredentialsInterceptor(inter func(credentials.Credentials) credentials.Credentials)

func (*Streamer) SetReadTimeout

func (m *Streamer) SetReadTimeout(timeout time.Duration) time.Duration

func (*Streamer) SetTrace

func (m *Streamer) SetTrace(cb trace.CB)

func (*Streamer) Upload

func (m *Streamer) Upload(filePaths map[string]streamer.File) error

func (*Streamer) WithCloseSessionCallback

func (m *Streamer) WithCloseSessionCallback(fn func(*ssh.Session) error)

func (*Streamer) WithOpenSessionCallback

func (m *Streamer) WithOpenSessionCallback(fn func(*ssh.Session) error)

func (*Streamer) Write

func (m *Streamer) Write(text []byte) error

type StreamerOption

type StreamerOption func(*Streamer)

func WithEnv

func WithEnv(key, value string) StreamerOption

func WithKnownHostsFiles

func WithKnownHostsFiles(files ...string) (StreamerOption, error)

func WithLogger

func WithLogger(log *zap.Logger) StreamerOption

func WithPort

func WithPort(port int) StreamerOption

func WithProgram

func WithProgram(program, programData string) StreamerOption

func WithSSHNetconf

func WithSSHNetconf() StreamerOption

func WithSSHTunnel

func WithSSHTunnel(tunnel Tunnel) StreamerOption

WithSSHTunnel sets tunnel as ssh proxy. We do not close after usage because it can be shared with other connections.

func WithTrace

func WithTrace(trace trace.CB) StreamerOption

type Tunnel

type Tunnel interface {
	Close()
	IsConnected() bool
	CreateConnect(context.Context) error
	StartForward(addr string) (net.Conn, error)
}

Jump to

Keyboard shortcuts

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