ssh

package
v0.0.0-...-a6e3fde Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseHostKey

func ParseHostKey(line string) (gossh.PublicKey, error)

ParseHostKey parses a pinned OpenSSH public host key line, e.g. "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAA... some comment".

func ParsePrivateKey

func ParsePrivateKey(data []byte) (gossh.Signer, error)

Types

type Config

type Config struct {
	Host    string
	Port    int
	User    string
	Signer  gossh.Signer
	HostKey gossh.PublicKey
}

type Transport

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

func New

func New(ctx context.Context, cfg Config) (*Transport, error)

func (*Transport) Close

func (t *Transport) Close() error

func (*Transport) ProbePath

func (t *Transport) ProbePath(ctx context.Context, path string) (transport.PathState, error)

ProbePath implements transport.Transport. Absence is PROVEN, never guessed from a status code: the walk starts at "/" — the one anchor that must exist on any Linux target — and descends component by component. At every step, all previously traversed prefixes have been positively stat-verified as directories, so when a later component reports SSH_FX_NO_SUCH_FILE, ENOTDIR is impossible: servers (OpenSSH included) map both ENOENT and ENOTDIR onto that one status, and the walk is what removes the ambiguity. A missing component is therefore proven absence of everything beneath it — including a deployRoot that does not exist yet, which is a legitimate fresh-target fact, not an error. A non-directory where a directory is required, a permission failure, any other protocol code, and transport failures are errors — "cannot establish" is never mapped to absence.

The walk trusts that each stat sees a stable namespace for its duration; an external actor rewriting an already-verified parent mid-walk is outside v0.1's threat model (the toolkit serializes its own operations, and SFTP offers no openat-style atomic walk to do better without disguising an assumption as atomicity).

func (*Transport) Put

Put stages req.Content atomically at req.Path via a dedicated SFTP session. The session is owned by this call: the subsystem request, the SFTP handshake and the transfer all run on one worker goroutine, so a single session.Close() on context cancellation unblocks the worker at any stage — including while the handshake is still waiting for the server's version packet. Closing the session leaves the shared SSH connection usable for later operations.

func (*Transport) Run

Jump to

Keyboard shortcuts

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