winrm

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2026 License: AGPL-3.0 Imports: 15 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package winrm is komando's own WinRM client: it runs one command on a Windows server through WS-Management (the Windows Remote Shell protocol, MS-WSMV), over HTTPS or HTTP, with NTLM or Basic login. It is what Ansible's winrm connection speaks. It only runs commands: WinRM has no file transfer or tunnels (komando sends files through the command's input and output, see docs/design/windows.md).

Index

Constants

This section is empty.

Variables

View Source
var ErrAuth = errors.New("the WinRM server refused the login (HTTP 401): check the user and password, and that the server allows this login method")

ErrAuth is a refused login (HTTP 401).

Functions

This section is empty.

Types

type Client

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

Client runs commands on one server. It is safe for one command at a time.

func New

func New(cfg Config) *Client

New makes a client; nothing is sent until Run.

func (*Client) Close

func (c *Client) Close() error

Close lets go of the client's connections.

func (*Client) Run

func (c *Client) Run(ctx context.Context, command string, stdin io.Reader, stdout, stderr io.Writer) (int, error)

Run runs command (as cmd.exe would read it) with stdin as its input and copies its output to stdout and stderr. It returns the exit code. When ctx ends, the command is stopped and the shell is closed.

type Config

type Config struct {
	// Endpoint is the server's WS-Management URL, e.g.
	// https://10.0.0.9:5986/wsman.
	Endpoint       string
	User, Password string
	// Basic logs in with HTTP Basic (local accounts only, and only
	// over HTTPS); otherwise NTLM, which never sends the password.
	Basic bool
	// TLS checks the server's certificate for an https Endpoint.
	TLS *tls.Config
	// Dial opens the TCP connection: directly, through a VPN or through
	// an SSH bastion. nil: net.Dialer.
	Dial func(ctx context.Context, network, addr string) (net.Conn, error)
	// OperationTimeout is how long the server waits for output before
	// it answers a Receive with nothing (komando then asks again).
	OperationTimeout time.Duration
}

Config says where the server is and how to log in.

type Error

type Error struct {
	Code    string // the WS-Management fault code, e.g. 2150858793
	Message string
}

Error is a SOAP fault the server answered with.

func (*Error) Error

func (e *Error) Error() string

Jump to

Keyboard shortcuts

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