Documentation
¶
Overview ¶
Package sshx implements native SSH connectivity and SFTP-backed filesystems.
Index ¶
- func AgentEndpoint(explicit string) string
- func DeployHelper(ctx context.Context, connection *Connection, platform Platform, ...) (*sftp.Client, io.Closer, error)
- func DetectPlatform(ctx context.Context, runner Runner) (Platform, Archiver, error)
- type Archiver
- type CapabilityError
- type Config
- type Connection
- type Factory
- type Jump
- type Platform
- type Runner
- type SFTPBackend
- func (s *SFTPBackend) Chmod(name string, mode fs.FileMode) error
- func (s *SFTPBackend) Chtimes(name string, atime, mtime time.Time) error
- func (s *SFTPBackend) CommitAbsent(stagePath, destination string) error
- func (s *SFTPBackend) Create(name string, mode fs.FileMode) (fsx.Writable, error)
- func (*SFTPBackend) Dir(name string) string
- func (*SFTPBackend) Join(parts ...string) string
- func (s *SFTPBackend) Lstat(name string) (fs.FileInfo, error)
- func (s *SFTPBackend) MkdirAll(name string, mode fs.FileMode) error
- func (s *SFTPBackend) Open(name string) (io.ReadCloser, error)
- func (s *SFTPBackend) ReadDir(name string) ([]fs.DirEntry, error)
- func (s *SFTPBackend) Readlink(name string) (string, error)
- func (s *SFTPBackend) RemoveAll(name string) error
- func (s *SFTPBackend) Rename(oldPath, newPath string) error
- func (s *SFTPBackend) Symlink(target, name string) error
- type SecretPrompt
- type Target
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AgentEndpoint ¶
AgentEndpoint returns an explicit SSH_AUTH_SOCK value or the native platform default when the platform defines one.
func DeployHelper ¶
func DeployHelper(ctx context.Context, connection *Connection, platform Platform, binaryPath, digest string) (*sftp.Client, io.Closer, error)
DeployHelper uploads a verified Courier binary and starts its embedded SFTP server. The returned closer removes the remote staging directory.
Types ¶
type Archiver ¶
Archiver is either a discovered remote executable or the built-in fallback.
func SelectArchiver ¶
SelectArchiver deterministically picks a platform-appropriate executable.
type CapabilityError ¶
CapabilityError identifies a remote feature gap eligible for an optional helper.
func (*CapabilityError) Error ¶
func (e *CapabilityError) Error() string
func (*CapabilityError) Unwrap ¶
func (e *CapabilityError) Unwrap() error
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config wraps the established OpenSSH config parser with Courier resolution.
func EmptyConfig ¶
EmptyConfig returns valid configuration for hosts without a user config file.
func LoadConfig ¶
LoadConfig loads OpenSSH configuration, including Host patterns and Include.
type Connection ¶
type Connection struct {
Target Target
SFTP *sftp.Client
SSH *ssh.Client
// contains filtered or unexported fields
}
Connection owns SFTP and every SSH hop used to reach it.
func (*Connection) Close ¶
func (c *Connection) Close() error
Close releases SFTP, SSH hops in reverse order, and agent connections.
type Factory ¶
type Factory struct {
Config *Config
DefaultUser string
KnownHosts string
AgentSocket string
Prompt SecretPrompt
ReadFile func(string) ([]byte, error)
DialContext func(context.Context, string, string) (net.Conn, error)
DialAgent func(string) (net.Conn, error)
NewSFTP func(*ssh.Client) (*sftp.Client, error)
SFTPFallback func(context.Context, *Connection, *CapabilityError) (*sftp.Client, io.Closer, error)
ClientConfig func(Target, []ssh.AuthMethod) (*ssh.ClientConfig, error)
}
Factory resolves configuration and opens independently authenticated clients.
type SFTPBackend ¶
type SFTPBackend struct {
// contains filtered or unexported fields
}
SFTPBackend adapts an authenticated SFTP client to fsx.Backend.
func NewSFTPBackend ¶
func NewSFTPBackend(client *sftp.Client) *SFTPBackend
NewSFTPBackend constructs a POSIX-path remote filesystem.
func (*SFTPBackend) Chtimes ¶
func (s *SFTPBackend) Chtimes(name string, atime, mtime time.Time) error
func (*SFTPBackend) CommitAbsent ¶ added in v0.2.0
func (s *SFTPBackend) CommitAbsent(stagePath, destination string) error
CommitAbsent uses the standard SFTP v3 rename, whose contract requires the destination not to exist, instead of the overwrite-capable POSIX extension.
func (*SFTPBackend) Dir ¶
func (*SFTPBackend) Dir(name string) string
func (*SFTPBackend) Join ¶
func (*SFTPBackend) Join(parts ...string) string
func (*SFTPBackend) Open ¶
func (s *SFTPBackend) Open(name string) (io.ReadCloser, error)
func (*SFTPBackend) RemoveAll ¶
func (s *SFTPBackend) RemoveAll(name string) error
func (*SFTPBackend) Rename ¶
func (s *SFTPBackend) Rename(oldPath, newPath string) error
func (*SFTPBackend) Symlink ¶
func (s *SFTPBackend) Symlink(target, name string) error
type SecretPrompt ¶
SecretPrompt obtains a password or key passphrase without command-line use.