gosftp

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: May 24, 2022 License: GPL-3.0 Imports: 14 Imported by: 0

README

Go sftp

SFTP Client implementation for go, compatible with Encryption Algorithm DSA key length 2048, 3072, 4096

When to use this repo

By default, this repo is not aiming to replace the built in implementation available in go with the package crypto. This package is intended to add the simple compatibility of the DSA key kength of 2048,3072 and 4096 which the golang crypto package doesn't support by default. This PR https://github.com/golang/crypto/pull/204 should solve the problem eventually when finally merged.

PLEASE avoid using this repo as implementation as SFTP connection. This is only a workaround to add the key length compatibility.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is the sftp client

func NewClient

func NewClient(config ClientConfig) (c *Client, err error)

func (*Client) Close

func (c *Client) Close()

Close close the sftp client and connection

func (*Client) DownloadFile

func (c *Client) DownloadFile(remoteFile string, localFile string) (err error)

Download file from sftp server

func (Client) ListFiles

func (c Client) ListFiles(remoteDir string) ([]File, error)

ListFiles List files in the given path

func (*Client) ReadFile

func (c *Client) ReadFile(remoteFile string) (io.Reader, error)

ReadFile read file from sftp server

func (*Client) UploadFile

func (c *Client) UploadFile(localFile, remoteFile string) (err error)

UploadFile Upload file to sftp server

type ClientConfig

type ClientConfig struct {
	User     string // User name
	Password string // Password

	Host string // Hostname or IP address
	Port int    // Default SFTP port, 22 if not provided

	IgnoreHostKeyValidation bool // If false, host key validation is enabled. It should be false for production use.
}

ClientConfig is the configuration for the sftp client

type File

type File struct {
	Name    string
	Size    int64
	ModTime time.Time
	IsDir   bool
}

Jump to

Keyboard shortcuts

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