sftpfiles

package
v0.2.16 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2023 License: LGPL-3.0 Imports: 13 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IgnoreHostKeys

func IgnoreHostKeys(state bool) files.Option

IgnoreHostKeys specifies whether the ssh.Dial should ignore host keys during connection. Using this is insecure!

Setting this to true will override any existing WithHostKey option, unless it is later turned off.

func WithAuth

func WithAuth(auth ssh.AuthMethod) files.Option

WithAuth includes an arbitrary ssh.AuthMethod to be used for authentication during the ssh.Dial.

func WithHostKey

func WithHostKey(hostkey []byte) files.Option

WithHostKey defines an expected host key from the authorized key format specified in the sshd(8) man page.

i.e. ssh-keytype BASE64BLOB string-comment

If the IgnoreHostKeys option has been set, then this option will be ignored.

Types

type Agent

type Agent struct {
	agent.Agent
	// contains filtered or unexported fields
}

Agent defines a connection to an ssh-agent through net.Conn.

func GetAgent

func GetAgent() (*Agent, error)

GetAgent looks up the SSH_AUTH_SOCK environment variable, and creates a connection to it.

If SSH_AUTH_SOCK is not set, then this returns both a nil Agent, and a nil error, as this is not an error condition.

If SSH_AUTH_SOCK is set, any error attempting to connect to it will return an error, and a nil Agent.

func (*Agent) Close

func (a *Agent) Close() error

Close implements io.Closer

type Host

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

Host defines a set of connection settings to a specific host/user combination, and manages a common SFTP connection to that host with those credentials.

func NewHost

func NewHost(uri *url.URL) *Host

NewHost returns a Host defined for a specific host/user based on a given URL. No connection is made, and no authentication or hostkey validation is defined.

func (*Host) AddAuth

func (h *Host) AddAuth(auth ssh.AuthMethod) []ssh.AuthMethod

AddAuth adds the given ssh.AuthMethod to the authorization methods for the Host, and return the previous value.

func (*Host) Close

func (h *Host) Close() error

Close closes and invalidates the Host's current connection.

func (*Host) Connect

func (h *Host) Connect() (*sftp.Client, error)

Connect either returns the currently connected Client, or makes a new connection based on Host.

func (*Host) GetClient

func (h *Host) GetClient() *sftp.Client

GetClient returns the currently connected Client connected to by the Host. It returns nil if the Host is not currently connected.

func (*Host) IgnoreHostKeys

func (h *Host) IgnoreHostKeys(state bool) bool

IgnoreHostKeys sets a flag that Host should ignore Host keys when connecting. THIS IS INSECURE.

func (*Host) Name

func (h *Host) Name() string

Name returns an identifying name of the Host composed of the authority section of the URL: //user[:pass]@hostname:port

func (*Host) SetAuths

func (h *Host) SetAuths(auths []ssh.AuthMethod) []ssh.AuthMethod

SetAuths sets the slice of ssh.AuthMethod on the Host, and returns the previous value.

func (*Host) SetHostKeyCallback

func (h *Host) SetHostKeyCallback(cb ssh.HostKeyCallback, algos []string) (ssh.HostKeyCallback, []string)

SetHostKeyCallback sets the current hostkey callback for the Host, and returns the previous value.

Jump to

Keyboard shortcuts

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