ssh

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: Apache-2.0 Imports: 24 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const TransferLimit = 1 << 30

TransferLimit bounds every SSH file transfer in either direction.

Variables

This section is empty.

Functions

func AtStage

func AtStage(err error, stage string) error

AtStage appends the failing stage to a fault while bounding untrusted text.

func Connect

func Connect(ctx context.Context, profile protocol.SshProfile, credential protocol.SshCredential) (*cryptossh.Client, error)

func ConnectWithRecovery

func ConnectWithRecovery(ctx context.Context, clock clockwork.Clock, profile protocol.SshProfile, credential protocol.SshCredential) (*cryptossh.Client, error)

ConnectWithRecovery wraps Connect with the bounded pre-authentication recovery. Connect hides its TCP error, so after a dial failure on macOS one classification dial decides whether the host was unreachable. Handshake, authentication, SFTP and remote effects are never repeated.

func Download

func Download(client *sftp.Client, path string, local io.Writer) (uint64, string, error)

Download stages a browsed remote file and returns its size and BLAKE3 revision. Nothing remote changes, so every failure is definite.

func Interrupted

func Interrupted(stage string) error

Interrupted reports a transfer whose destination state is unconfirmed.

func List

func List(client *sftp.Client, path string, after *protocol.SshCursor) (protocol.SshDirectory, error)

List reads one sorted page of a canonicalized remote directory.

func Modify

func Modify(client *sftp.Client, path string, action protocol.SshFileAction) error

Modify creates, copies, moves or removes one remote entry.

func OpenSFTP

func OpenSFTP(client *cryptossh.Client) (*sftp.Client, error)

OpenSFTP starts the SFTP subsystem on an authenticated connection.

func PageEntries

func PageEntries(entries []protocol.FileEntry, after *protocol.SshCursor) ([]protocol.FileEntry, *protocol.SshCursor)

PageEntries orders directories first, then exact byte order of names, and returns the page after the cursor with the continuation when more remain.

func Run

func Run(ctx context.Context, client *cryptossh.Client, command string) (protocol.SshOutcome, error)

Run executes one remote command and retains bounded output. Cancelling ctx closes the channel and returns ctx.Err(); the remote process may continue, so the caller reports that outcome as unknown.

func TransferDownload

func TransferDownload(client *sftp.Client, path string, local io.Writer) (uint64, string, error)

TransferDownload copies a remote file for worktree publication. Remote failures are uncertain and carry the stage that could not be confirmed.

func TransferUpload

func TransferUpload(client *sftp.Client, source *os.File, localPath, remotePath string) (uint64, error)

TransferUpload copies an opened worktree file to the remote host. The file a transfer creates is private to the remote account.

func Upload

func Upload(client *sftp.Client, path string, source io.Reader, size uint64, overwrite bool) (uint64, error)

Upload publishes a staged upload to its explicit remote path. An existing entry is a conflict unless the stage asked to overwrite it.

func ValidatePath

func ValidatePath(path string) error

ValidatePath accepts an explicit remote destination. Remote paths are not a sandbox: the saved profile's account decides what they can reach.

func ValidateRemotePath

func ValidateRemotePath(path string) error

ValidateRemotePath applies the stricter transfer rule: no control characters.

func VerifyHostKey

func VerifyHostKey(trusted *protocol.SshHostKey, key cryptossh.PublicKey) error

Types

type HostKeyRequired

type HostKeyRequired struct {
	Key     protocol.SshHostKey
	Changed bool
}

func (*HostKeyRequired) Error

func (*HostKeyRequired) Error() string

func (*HostKeyRequired) Outcome

func (required *HostKeyRequired) Outcome() protocol.SshOutcome

Jump to

Keyboard shortcuts

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