ssh

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2026 License: MIT Imports: 35 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AUTHKEY_PASSWORD = "password"
	AUTHKEY_AGENT    = "agent"
	AUTHKEY_KEY      = "key"
	AUTHKEY_CERT     = "cert"
	AUTHKEY_PKCS11   = "pkcs11"
)
View Source
const SSH_AUTH_SOCK = "SSH_AUTH_SOCK"

Variables

This section is empty.

Functions

func BuildInteractiveLocalRCShellCommand added in v0.10.0

func BuildInteractiveLocalRCShellCommand(localrcPath []string, decoder string, compress bool, uncompress string) string

func BuildLocalRCShellCommand added in v0.10.0

func BuildLocalRCShellCommand(localrcPath []string, decoder string, compress bool, uncompress string) string

func InteractiveLocalRCStartupMarker added in v0.10.0

func InteractiveLocalRCStartupMarker() string

func IsConnectorManagedSSHRuntime added in v0.10.0

func IsConnectorManagedSSHRuntime(prepared conf.PreparedConnector) bool

func StartParallelForwards added in v0.8.0

func StartParallelForwards(connect *sshlib.Connect, config conf.ServerConfig) error

StartParallelForwards starts only the reverse-side forwards that can be applied independently per connection in parallel workflows.

Types

type AuthKey

type AuthKey struct {
	// auth type:
	//   - password
	//   - agent
	//   - key
	//   - cert
	//   - pkcs11
	Type string

	// auth type value:
	//   - key(path)
	//     ex.) ~/.ssh/id_rsa
	//   - cert(path)
	//     ex.) ~/.ssh/id_rsa.crt
	//   - pkcs11(libpath)
	//     ex.) /usr/local/lib/opensc-pkcs11.so
	Value string
}

AuthKey Auth map key struct.

type PathSet

type PathSet struct {
	Base      string
	PathSlice []string
}

use scp,sftp

type Run

type Run struct {
	ServerList []string
	Conf       conf.Config

	// ControlMasterOverride temporarily overrides the config setting for
	// this run. nil means use the config value as-is.
	ControlMasterOverride *bool

	// Mode value in
	//     - shell
	//     - cmd
	Mode string

	// tty use (-t option)
	IsTerm bool

	// parallel connect (-p option)
	IsParallel bool

	// not run (-N option)
	IsNone bool

	// x11 forwarding (-X option)
	X11 bool

	// Trusted X11 flag (-Y option)
	X11Trusted bool

	// use or not-use local bashrc.
	// IsNotBashrc takes precedence.
	IsBashrc    bool
	IsNotBashrc bool

	// local/remote Port Forwarding
	PortForward []*conf.PortForward

	// TODO(blacknon): Delete old keys
	// L or R
	PortForwardMode string

	// local port num (ex. 11080).
	PortForwardLocal string

	// remote host and port (ex. localhost:11080).
	PortForwardRemote string

	// Dynamic Port Forwarding
	// set localhost port num (ex. 11080).
	DynamicPortForward string

	// HTTP Dynamic Port Forwarding
	// set localhost port num (ex. 11080).
	HTTPDynamicPortForward string

	// Reverse Dynamic Port Forwarding
	// set remotehost port num (ex. 11080).
	ReverseDynamicPortForward string

	// HTTP Reverse Dynamic Port Forwarding
	// set remotehost port num (ex. 11080).
	HTTPReverseDynamicPortForward string

	// NFS Dynamic Forward
	// set localhost port num (ex. 12049).
	NFSDynamicForwardPort string

	// NFS Dynamic Forward Path
	// set remotehost path (ex. /path/to/remote).
	NFSDynamicForwardPath string

	// NFS Reverse Dynamic Forward
	// set remotehost port num (ex. 12049).
	NFSReverseDynamicForwardPort string

	// NFS Reverse Dynamic Forward Path
	// set localhost path (ex. /path/to/local).
	NFSReverseDynamicForwardPath string

	// SMB Dynamic Forward
	// set localhost port num (ex. 12445).
	SMBDynamicForwardPort string

	// SMB Dynamic Forward Path
	// set remotehost path (ex. /path/to/remote).
	SMBDynamicForwardPath string

	// SMB Reverse Dynamic Forward
	// set remotehost port num (ex. 12445).
	SMBReverseDynamicForwardPort string

	// SMB Reverse Dynamic Forward Path
	// set localhost path (ex. /path/to/local).
	SMBReverseDynamicForwardPath string

	// Tunnel device (-w equivalent). Enable and units.
	TunnelEnabled bool
	TunnelLocal   int
	TunnelRemote  int

	// Exec command
	ExecCmd []string

	// ConnectorAttachSession resumes a connector-managed shell session by id.
	ConnectorAttachSession string

	// ConnectorDetach starts a connector-managed shell session without attaching.
	ConnectorDetach bool

	// enable/disable print header in command mode
	EnableHeader  bool
	DisableHeader bool

	// Enable/Disable stdoutMutex
	EnableStdoutMutex bool

	// StdinData from pipe flag
	IsStdinPipe bool

	// ShareConnect reuses the monitor SSH connection for interactive terminals.
	ShareConnect bool

	// ActiveTunnel holds the active tunnel created for this Run (if any)
	ActiveTunnel *sshlib.Tunnel

	// ConnectorRuntime executes provider-managed connector plans.
	ConnectorRuntime connectorruntime.Executor
	// contains filtered or unexported fields
}

Run

func (*Run) CreateAuthMethodMap

func (r *Run) CreateAuthMethodMap()

CreateAuthMethodMap Create ssh.AuthMethod, into r.AuthMethodMap.

func (*Run) CreateConnectorManagedSSHConnectDirect added in v0.10.0

func (r *Run) CreateConnectorManagedSSHConnectDirect(server string) (*sshlib.Connect, error)

func (*Run) CreateSFTPClient added in v0.10.0

func (r *Run) CreateSFTPClient(server string) (*sftp.Client, io.Closer, error)

CreateSFTPClient creates an SFTP client for the target server. Connector-backed servers may provide an alternative transport such as `ssh -s sftp`; traditional servers continue to use go-sshlib directly.

func (*Run) CreateSFTPClientHandle added in v0.10.0

func (r *Run) CreateSFTPClientHandle(server string) (*SFTPClientHandle, error)

func (*Run) CreateSshConnect

func (r *Run) CreateSshConnect(server string) (connect *sshlib.Connect, err error)

CreateSshConnect return *sshlib.Connect this vaule in ssh.Client with proxy.

func (*Run) CreateSshConnectDirect

func (r *Run) CreateSshConnectDirect(server string) (connect *sshlib.Connect, err error)

CreateSshConnectDirect returns *sshlib.Connect with ControlMaster/ControlPersist disabled. This is used by features that require a concrete *ssh.Client (e.g. SFTP clients).

func (*Run) ParallelIgnoredFeatures added in v0.8.0

func (r *Run) ParallelIgnoredFeatures(server string) []string

ParallelIgnoredFeatures lists forwarding settings that are intentionally skipped for per-host parallel sessions because they require local listeners.

func (*Run) PrepareParallelForwardConfig added in v0.8.0

func (r *Run) PrepareParallelForwardConfig(server string) (c conf.ServerConfig)

PrepareParallelForwardConfig returns only the forwarding settings that are safe to apply independently to each parallel connection.

func (*Run) PrintConnectInfo

func (r *Run) PrintConnectInfo(server string, connect *sshlib.Connect, cfg conf.ServerConfig)

PrintConnectInfo centralizes informational output related to a created connection (ControlMaster state, local rc usage, etc.). Call this after CreateSshConnect returns a valid *sshlib.Connect.

func (*Run) PrintSelectServer

func (r *Run) PrintSelectServer()

PrintSelectServer is printout select server. use ssh login header.

func (*Run) ProviderBridgeDialer added in v0.10.0

func (r *Run) ProviderBridgeDialer(server string) connectorruntime.Dialer

func (*Run) RunConnectorCommand added in v0.10.0

func (r *Run) RunConnectorCommand(server string, command []string, stdin io.Reader, stdout, stderr io.Writer) (int, error)

func (*Run) RunConnectorCommandLine added in v0.10.0

func (r *Run) RunConnectorCommandLine(server, commandLine string, stdin io.Reader, stdout, stderr io.Writer) (int, error)

func (*Run) RunConnectorLocalPortForward added in v0.10.0

func (r *Run) RunConnectorLocalPortForward(server string) error

func (*Run) RunConnectorShell added in v0.10.0

func (r *Run) RunConnectorShell(server string) error

func (*Run) SetupSshAgent

func (r *Run) SetupSshAgent()

func (*Run) Start

func (r *Run) Start()

Start ssh connect

func (*Run) UsesConnector added in v0.10.0

func (r *Run) UsesConnector(server string) bool

type SFTPClientHandle added in v0.10.0

type SFTPClientHandle struct {
	Client     *sftp.Client
	Closer     io.Closer
	SSHConnect *sshlib.Connect
}

Jump to

Keyboard shortcuts

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