utils: github.com/juju/utils/winrm Index | Files

package winrm

import "github.com/juju/utils/winrm"

Index

Package Files

winrm.go x509.go

Variables

var (
    // ErrAuth returned if the post request is droped due to invalid credentials
    ErrAuth = fmt.Errorf("Unauthorized request")
    // ErrPing returned if the ping fails
    ErrPing = fmt.Errorf("Ping failed, can't recive any response form target")
)

func TTYGetPasswd Uses

func TTYGetPasswd() (string, error)

TTYGetPasswd will be valid if it's used from a valid TTY input, This can be passed in ClientConfig

type Client Uses

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

Client type retains information about the winrm connection

func NewClient Uses

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

NewClient creates a new secure winrm client for initiating connections with the winrm listener

func (Client) Password Uses

func (c Client) Password() string

Password returns the winrm connection password

func (*Client) Ping Uses

func (c *Client) Ping() error

Ping executes a simple echo command on the remote, if the server dosen't respond to this echo command it will return ErrPing. If the payload is executed and the server response accordingly we return nil

func (*Client) Run Uses

func (c *Client) Run(command string, stdout io.Writer, stderr io.Writer) error

Run powershell command and direct output to stdout and errors to stderr If the Run successfully executes it returns nil

func (Client) Secure Uses

func (c Client) Secure() bool

Secure returns true if the client is using a secure connection or false if it's just a normal http

type ClientConfig Uses

type ClientConfig struct {
    // User of the client connection
    // If you want the default user Administrator, leave this empty
    User string
    // Host where we want to connect
    Host string
    // Key Private RSA key
    Key []byte
    // Cert https client x509 cert
    Cert []byte
    // CACert of the host we wish to connect
    // This can be nil if Insecure is false
    CACert []byte
    // Timeout on how long we should wait until a connection is made.
    // If empty this will use the 60*time.Seconds winrm default value
    Timeout time.Duration
    // Insecure flag for checking the CACert or not. If this is true there should
    // be a valid CACert passed also.
    Insecure bool
    // Password callback for returning a password in different ways
    Password GetPasswd
    // Secure flag for specifying if the user wants https or http
    Secure bool
}

ClientConfig used for setting up a secure https client connection

func (ClientConfig) Validate Uses

func (c ClientConfig) Validate() error

Validate checks all config options if they are invalid

type GetPasswd Uses

type GetPasswd func() (string, error)

GetPasswd callback for different semantics that a client could use for secure authentication

type X509 Uses

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

X509 type that defines windows remote manager credentials for client-server secure communication

func NewX509 Uses

func NewX509() *X509

NewX509 returns a new to an empty X509

func (*X509) CACert Uses

func (x *X509) CACert() []byte

CACert returns the internal credential client ca cert

func (*X509) ClientCert Uses

func (x *X509) ClientCert() []byte

ClientCert returns the internal credential client x509 cert

func (*X509) ClientKey Uses

func (x *X509) ClientKey() []byte

ClientKey returns the internal credential client x509 private key

func (*X509) LoadCACert Uses

func (x *X509) LoadCACert(path string) error

LoadCACert reads ca cert into memory

func (*X509) LoadClientCert Uses

func (x *X509) LoadClientCert(certFile, keyFile string) error

LoadClientCert generates client cert for x509 authentication if the directory files are not already there , if they are already there it will load them into memory

func (*X509) Reset Uses

func (x *X509) Reset()

Reset fills up the internal state with nil values

Package winrm imports 16 packages (graph) and is imported by 27 packages. Updated 2020-01-21. Refresh now. Tools for package owners.