Documentation
¶
Index ¶
- func IgnoreHostKeys(state bool) files.Option
- func WithAuth(auth ssh.AuthMethod) files.Option
- func WithHostKey(hostkey []byte) files.Option
- type Agent
- type Host
- func (h *Host) AddAuth(auth ssh.AuthMethod) []ssh.AuthMethod
- func (h *Host) Close() error
- func (h *Host) Connect() (*sftp.Client, error)
- func (h *Host) GetClient() *sftp.Client
- func (h *Host) IgnoreHostKeys(state bool) bool
- func (h *Host) Name() string
- func (h *Host) SetAuths(auths []ssh.AuthMethod) []ssh.AuthMethod
- func (h *Host) SetHostKeyCallback(cb ssh.HostKeyCallback, algos []string) (ssh.HostKeyCallback, []string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IgnoreHostKeys ¶
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 ¶
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 ¶
Agent defines a connection to an ssh-agent through net.Conn.
func GetAgent ¶
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.
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 ¶
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) Connect ¶
Connect either returns the currently connected Client, or makes a new connection based on Host.
func (*Host) GetClient ¶
GetClient returns the currently connected Client connected to by the Host. It returns nil if the Host is not currently connected.
func (*Host) IgnoreHostKeys ¶
IgnoreHostKeys sets a flag that Host should ignore Host keys when connecting. THIS IS INSECURE.
func (*Host) Name ¶
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.