winrm

package
v0.44.1 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2022 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrCannotReachHost   = errWinRM.Code("cannot_reach_host").ErrorPref("Cannot reach the Client host: %s")
	ErrNoPeerCertificate = errWinRM.Code("no_peer_cert").Error("Could not get the peer certificate")
	ErrCertNotTrusted    = errWinRM.Code("peer_not_trusted").Error("Peer certificate is not trusted")
	ErrExecutingCommand  = errWinRM.Code("executing_command").ErrorPref("An error occurred while executing the command : %s")

	ErrCertAuthNoClientKey  = errWinRM.Code("no_client_key_certificate_authentication").Error("No client key was supplied to use for certificate authentication")
	ErrCertAuthNoClientCert = errWinRM.Code("no_client_certificate_certificate_authentication").Error("No client certificate was supplied to use for certificate authentication")

	ErrBasicAuthNoUsername = errWinRM.Code("no_username_basic_authentication").Error("No username was supplied to use for basic authentication")
	ErrBasicAuthNoPassword = errWinRM.Code("no_password_basic_authentication").Error("No password was supplied to use for basic authentication")
)

Errors

Functions

This section is empty.

Types

type Client

type Client struct {
	*winrm.Client
	// contains filtered or unexported fields
}

Client contains all necessary data for a Client connection.

func NewBasicClient

func NewBasicClient(config *Config, username, password string) (*Client, error)

NewBasicClient returns a Client with basic authentication using username and password. This validates if a proper username and password is given. It uses a authBasic implementation for authMethod.

func NewCertClient

func NewCertClient(config *Config, clientCert, clientKey []byte) (*Client, error)

NewCertClient returns a Client with certificate authentication using client certificate and key. This validates if a clientKey and clientCert is given. It uses a authCert implementation for authMethod.

func (*Client) CopyFile

func (c *Client) CopyFile(file io.Reader, dest string, progress chan int) error

CopyFile copies the data from a io.Reader to a file at the destination path on the host. The progress (in amount of bytes transferred) of the copy is published on the progress channel.

func (*Client) GetServerCert

func (c *Client) GetServerCert(io ui.IO) error

GetServerCert retrieves the server TLS certificate of a Client-host. If the certificate is not trusted, the user is asked whether to trust the certificate fingerprint. If the user trusts the fingerprint, the server certificate is set as the Client CA certificate, so a following TLS connection will succeed.

func (*Client) RunCommand

func (c *Client) RunCommand(command string, out, stdErr *bytes.Buffer) error

RunCommand executes a command on the host. StdOut and StdErr of the command are written to the respective writers. If an ErrExecutingCommand is returned, then the stdErr should be checked.

type Config

type Config struct {
	Host string
	Port int

	HTTPS bool

	SkipVerifyCert bool
	CaCert         []byte
}

Config contains all configuration options for a WinRM client connection except for the authentication options

Jump to

Keyboard shortcuts

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