libsftp

package
v0.0.17 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeleteFile

func DeleteFile(sc *sftp.Client, remoteFile string, removeDir bool) (err error)

DeleteFile from SFTP server. A wrapper around sftp.Client.Remove and sftp.Client.RemoveDirectory. If removeDir is true but the directory is not empty, an error will be returned.

func DownloadFile

func DownloadFile(sc *sftp.Client, remoteFile, localFile string) (n int64, err error)

DownloadFile from SFTP server

func GetHostKey

func GetHostKey(host string) (ssh.PublicKey, error)

GetHostKey from local known hosts

func GetSSHconn

func GetSSHconn(creds Credentials) (*ssh.Client, error)

GetSSHconn tries to establish an SSH connection with given Credentials

func ListDirsFiles

func ListDirsFiles(sc *sftp.Client, remoteDir string) (fsinfo []fs.FileInfo, err error)

ListDirsFiles in a certain directory "remoteDir" on the SFTP server

func UploadFile

func UploadFile(sc *sftp.Client, localFile, remoteFile string) (n int64, err error)

UploadFile to SFTP server. The directory path on the remote must exist.

Types

type Credentials

type Credentials struct {
	Usr        string
	Host       string
	AgentSock  string
	Port       int
	SSHtimeout time.Duration
}

Credentials for SSH auth

func (*Credentials) String

func (c *Credentials) String() string

Jump to

Keyboard shortcuts

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