sshclient

package
v0.0.0-...-abd195e Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DownloadDir

func DownloadDir(sftpClient *sftp.Client, remoteDir, localDir string) (int, int64, error)

DownloadDir recursively downloads a remote directory to a local path, preserving permissions.

func DownloadFile

func DownloadFile(sftpClient *sftp.Client, remotePath, localPath string) (int64, error)

DownloadFile downloads a remote file to a local path, preserving permissions.

func ExpandRemotePath

func ExpandRemotePath(sftpClient *sftp.Client, remotePath string) string

ExpandRemotePath expands ~ and resolves relative paths on the remote server using RealPath.

func NewSFTPClient

func NewSFTPClient(client *ssh.Client) (*sftp.Client, error)

NewSFTPClient creates a new SFTP client from an SSH client.

func ReadFile

func ReadFile(sftpClient *sftp.Client, remotePath string, maxSize ...int64) ([]byte, error)

ReadFile reads a remote file and returns its contents. If maxSize > 0, the file size is checked first and reading is capped with io.LimitReader.

func UploadDir

func UploadDir(sftpClient *sftp.Client, localDir, remoteDir string) (int, int64, error)

UploadDir recursively uploads a local directory to a remote path, preserving permissions.

func UploadFile

func UploadFile(sftpClient *sftp.Client, localPath, remotePath string, perms *fs.FileMode) (int64, error)

UploadFile uploads a local file to a remote path, preserving permissions.

func WriteFile

func WriteFile(sftpClient *sftp.Client, remotePath string, data []byte, perms fs.FileMode) (int64, error)

WriteFile writes data to a remote file with given permissions. Parent directories are created automatically if they don't exist.

Types

This section is empty.

Jump to

Keyboard shortcuts

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