diff --git a/pkg/sshx/client.go b/pkg/sshx/client.go index ad828e8..4f8d936 100644 --- a/pkg/sshx/client.go +++ b/pkg/sshx/client.go @@ -77,8 +77,11 @@ func NewClient(config *Config, options ...Option) (*Client, error) { } } - if client.SFTP, err = sftp.NewClient(client.SSH); err != nil { - return nil, err + // Prevent issues with SSH servers that do not permit SFTP. + if !client.STFPDisabled { + if client.SFTP, err = sftp.NewClient(client.SSH); err != nil { + return nil, err + } } return client, nil diff --git a/pkg/sshx/options.go b/pkg/sshx/options.go index 5ce5b76..ff2116d 100644 --- a/pkg/sshx/options.go +++ b/pkg/sshx/options.go @@ -8,9 +8,10 @@ import ( // Options contains the configuration for an operation. type Options struct { - Logger *zerolog.Logger - Proxy *Client - Timeout time.Duration + Logger *zerolog.Logger + Proxy *Client + Timeout time.Duration + STFPDisabled bool } // Option applies a configuration option @@ -33,9 +34,10 @@ func GetDefaultOptions() *Options { logger := zerolog.Nop() return &Options{ - Proxy: nil, - Timeout: time.Second * 5, - Logger: &logger, + Proxy: nil, + Timeout: time.Second * 5, + Logger: &logger, + STFPDisabled: false, } } @@ -63,3 +65,11 @@ func WithTimeout(timeout time.Duration) Option { return nil } } + +// WithSTFPDisabled allows to disable the SFTP client. +func WithSTFPDisabled() Option { + return func(options *Options) error { + options.STFPDisabled = true + return nil + } +}