Documentation
¶
Overview ¶
Package sftp implements a Backend backed by an SFTP remote server.
Index ¶
- func HostKeyFile(file string) (ssh.HostKeyCallback, error)
- func HostKeyFingerprint(fingerprint string) (ssh.HostKeyCallback, error)
- type Backend
- func (b *Backend) Close() error
- func (b *Backend) List(_ context.Context, t types.FileType, fn func(types.FileInfo) error) error
- func (b *Backend) Load(_ context.Context, t types.FileType, name string, offset, length int64) (io.ReadCloser, error)
- func (b *Backend) Location() string
- func (b *Backend) Remove(_ context.Context, t types.FileType, name string) error
- func (b *Backend) Save(_ context.Context, t types.FileType, name string, rd io.Reader) error
- func (b *Backend) Stat(_ context.Context, t types.FileType, name string) (types.FileInfo, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HostKeyFile ¶
func HostKeyFile(file string) (ssh.HostKeyCallback, error)
HostKeyFile returns a host key callback that validates against a known_hosts file.
func HostKeyFingerprint ¶
func HostKeyFingerprint(fingerprint string) (ssh.HostKeyCallback, error)
HostKeyFingerprint returns a host key callback that validates against a pinned SHA256 fingerprint (e.g. "SHA256:abc123...").
Types ¶
type Backend ¶
type Backend struct {
// contains filtered or unexported fields
}
Backend stores repository data on a remote SFTP server.
func New ¶
func New(host, port, user, basePath, keyFile, password, sshKey string, hostKeyCallback ssh.HostKeyCallback) (*Backend, error)
New connects to the SFTP server and returns a Backend rooted at basePath.
Authentication is attempted in order: inline SSH key (sshKey), SSH agent, public key file, password. At least one must be available.
hostKeyCallback can be obtained from HostKeyFingerprint() or HostKeyFile().
The basePath is the remote directory that serves as the repository root. The directory structure is created if it doesn't already exist.
func NewFromClients ¶
func NewFromClients(sshClient *ssh.Client, sftpClient *sftp.Client, host, port, user, basePath string) (*Backend, error)
NewFromClients creates a Backend using pre-established SSH and SFTP clients. This is primarily useful for testing.