{"modulePath":"github.com/wfernandes/cli","version":"v6.1.1+incompatible","isLatest":false,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package ssh\n\nPackage ssh implements an SSH client and server.\n\nSSH is a transport security protocol, an authentication protocol and a family of application protocols. The most typical application level protocol is a remote shell and this is specifically implemented.  However, the multiplexed nature of SSH is exposed to users that wish to support others.\n\nReferences:\n\n\t[PROTOCOL.certkeys]: http://www.openbsd.org/cgi-bin/cvsweb/src/usr.bin/ssh/PROTOCOL.certkeys\n\t[SSH-PARAMETERS]:    http://www.iana.org/assignments/ssh-parameters/ssh-parameters.xml#ssh-parameters-1\n\n## Constants\n\n```go\nconst (\n\tCertAlgoRSAv01      = \"ssh-rsa-cert-v01@openssh.com\"\n\tCertAlgoDSAv01      = \"ssh-dss-cert-v01@openssh.com\"\n\tCertAlgoECDSA256v01 = \"ecdsa-sha2-nistp256-cert-v01@openssh.com\"\n\tCertAlgoECDSA384v01 = \"ecdsa-sha2-nistp384-cert-v01@openssh.com\"\n\tCertAlgoECDSA521v01 = \"ecdsa-sha2-nistp521-cert-v01@openssh.com\"\n)\n```\nThese constants from \\[PROTOCOL.certkeys] represent the algorithm names for certificate types supported by this package.\n\n```go\nconst (\n\tUserCert = 1\n\tHostCert = 2\n)\n```\nCertificate types distinguish between host and user certificates. The values can be set in the CertType field of Certificate.\n\n```go\nconst (\n\tKeyAlgoRSA      = \"ssh-rsa\"\n\tKeyAlgoDSA      = \"ssh-dss\"\n\tKeyAlgoECDSA256 = \"ecdsa-sha2-nistp256\"\n\tKeyAlgoECDSA384 = \"ecdsa-sha2-nistp384\"\n\tKeyAlgoECDSA521 = \"ecdsa-sha2-nistp521\"\n)\n```\nThese constants represent the algorithm names for key types supported by this package.\n\n```go\nconst (\n\tVINTR         = 1\n\tVQUIT         = 2\n\tVERASE        = 3\n\tVKILL         = 4\n\tVEOF          = 5\n\tVEOL          = 6\n\tVEOL2         = 7\n\tVSTART        = 8\n\tVSTOP         = 9\n\tVSUSP         = 10\n\tVDSUSP        = 11\n\tVREPRINT      = 12\n\tVWERASE       = 13\n\tVLNEXT        = 14\n\tVFLUSH        = 15\n\tVSWTCH        = 16\n\tVSTATUS       = 17\n\tVDISCARD      = 18\n\tIGNPAR        = 30\n\tPARMRK        = 31\n\tINPCK         = 32\n\tISTRIP        = 33\n\tINLCR         = 34\n\tIGNCR         = 35\n\tICRNL         = 36\n\tIUCLC         = 37\n\tIXON          = 38\n\tIXANY         = 39\n\tIXOFF         = 40\n\tIMAXBEL       = 41\n\tISIG          = 50\n\tICANON        = 51\n\tXCASE         = 52\n\tECHO          = 53\n\tECHOE         = 54\n\tECHOK         = 55\n\tECHONL        = 56\n\tNOFLSH        = 57\n\tTOSTOP        = 58\n\tIEXTEN        = 59\n\tECHOCTL       = 60\n\tECHOKE        = 61\n\tPENDIN        = 62\n\tOPOST         = 70\n\tOLCUC         = 71\n\tONLCR         = 72\n\tOCRNL         = 73\n\tONOCR         = 74\n\tONLRET        = 75\n\tCS7           = 90\n\tCS8           = 91\n\tPARENB        = 92\n\tPARODD        = 93\n\tTTY_OP_ISPEED = 128\n\tTTY_OP_OSPEED = 129\n)\n```\nPOSIX terminal mode flags as listed in RFC 4254 Section 8.\n\n```go\nconst CertTimeInfinity = 1\u003c\u003c64 - 1\n```\nCertTimeInfinity can be used for OpenSSHCertV01.ValidBefore to indicate that a certificate does not expire.\n\n## Functions\n\n```go\nfunc DiscardRequests(in \u003c-chan *Request)\n```\nDiscardRequests consumes and rejects all requests from the passed-in channel.\n\n```go\nfunc Marshal(msg interface{}) []byte\n```\nMarshal serializes the message in msg to SSH wire format.  The msg argument should be a struct or pointer to struct. If the first member has the \"sshtype\" tag set to a number in decimal, that number is prepended to the result. If the last of member has the \"ssh\" tag set to \"rest\", its contents are appended to the output.\n\n```go\nfunc MarshalAuthorizedKey(key PublicKey) []byte\n```\nMarshalAuthorizedKey serializes key for inclusion in an OpenSSH authorized\\_keys file. The return value ends with newline.\n\n```go\nfunc ParseDSAPrivateKey(der []byte) (*dsa.PrivateKey, error)\n```\nParseDSAPrivateKey returns a DSA private key from its ASN.1 DER encoding, as specified by the OpenSSL DSA man page.\n\n```go\nfunc ParseRawPrivateKey(pemBytes []byte) (interface{}, error)\n```\nParseRawPrivateKey returns a private key from a PEM encoded private key. It supports RSA (PKCS#1), DSA (OpenSSL), and ECDSA private keys.\n\n```go\nfunc Unmarshal(data []byte, out interface{}) error\n```\nUnmarshal parses data in SSH wire format into a structure. The out argument should be a pointer to struct. If the first member of the struct has the \"sshtype\" tag set to a number in decimal, the packet must start that number.  In case of error, Unmarshal returns a ParseError or UnexpectedMessageError.\n\n## Types\n\n```go\ntype AuthMethod interface {\n\t// contains filtered or unexported methods\n}\n```\nAn AuthMethod represents an instance of an RFC 4252 authentication method.\n\n```go\nfunc KeyboardInteractive(challenge KeyboardInteractiveChallenge) AuthMethod\n```\nKeyboardInteractive returns a AuthMethod using a prompt/response sequence controlled by the server.\n\n```go\nfunc Password(secret string) AuthMethod\n```\nPassword returns an AuthMethod using the given password.\n\n```go\nfunc PasswordCallback(prompt func() (secret string, err error)) AuthMethod\n```\nPasswordCallback returns an AuthMethod that uses a callback for fetching a password.\n\n```go\nfunc PublicKeys(signers ...Signer) AuthMethod\n```\nPublicKeys returns an AuthMethod that uses the given key pairs.\n\n```go\nfunc PublicKeysCallback(getSigners func() (signers []Signer, err error)) AuthMethod\n```\nPublicKeysCallback returns an AuthMethod that runs the given function to obtain a list of key pairs.\n\n```go\ntype CertChecker struct {\n\t// SupportedCriticalOptions lists the CriticalOptions that the\n\t// server application layer understands. These are only used\n\t// for user certificates.\n\tSupportedCriticalOptions []string\n\n\t// IsAuthority should return true if the key is recognized as\n\t// an authority. This allows for certificates to be signed by other\n\t// certificates.\n\tIsAuthority func(auth PublicKey) bool\n\n\t// Clock is used for verifying time stamps. If nil, time.Now\n\t// is used.\n\tClock func() time.Time\n\n\t// UserKeyFallback is called when CertChecker.Authenticate encounters a\n\t// public key that is not a certificate. It must implement validation\n\t// of user keys or else, if nil, all such keys are rejected.\n\tUserKeyFallback func(conn ConnMetadata, key PublicKey) (*Permissions, error)\n\n\t// HostKeyFallback is called when CertChecker.CheckHostKey encounters a\n\t// public key that is not a certificate. It must implement host key\n\t// validation or else, if nil, all such keys are rejected.\n\tHostKeyFallback func(addr string, remote net.Addr, key PublicKey) error\n\n\t// IsRevoked is called for each certificate so that revocation checking\n\t// can be implemented. It should return true if the given certificate\n\t// is revoked and false otherwise. If nil, no certificates are\n\t// considered to have been revoked.\n\tIsRevoked func(cert *Certificate) bool\n}\n```\nCertChecker does the work of verifying a certificate. Its methods can be plugged into ClientConfig.HostKeyCallback and ServerConfig.PublicKeyCallback. For the CertChecker to work, minimally, the IsAuthority callback should be set.\n\n```go\nfunc (c *CertChecker) Authenticate(conn ConnMetadata, pubKey PublicKey) (*Permissions, error)\n```\nAuthenticate checks a user certificate. Authenticate can be used as a value for ServerConfig.PublicKeyCallback.\n\n```go\nfunc (c *CertChecker) CheckCert(principal string, cert *Certificate) error\n```\nCheckCert checks CriticalOptions, ValidPrincipals, revocation, timestamp and the signature of the certificate.\n\n```go\nfunc (c *CertChecker) CheckHostKey(addr string, remote net.Addr, key PublicKey) error\n```\nCheckHostKey checks a host key certificate. This method can be plugged into ClientConfig.HostKeyCallback.\n\n```go\ntype Certificate struct {\n\tNonce           []byte\n\tKey             PublicKey\n\tSerial          uint64\n\tCertType        uint32\n\tKeyId           string\n\tValidPrincipals []string\n\tValidAfter      uint64\n\tValidBefore     uint64\n\tPermissions\n\tReserved     []byte\n\tSignatureKey PublicKey\n\tSignature    *Signature\n}\n```\nAn Certificate represents an OpenSSH certificate as defined in \\[PROTOCOL.certkeys]?rev=1.8.\n\n```go\nfunc (c *Certificate) Marshal() []byte\n```\nMarshal serializes c into OpenSSH's wire format. It is part of the PublicKey interface.\n\n```go\nfunc (c *Certificate) SignCert(rand io.Reader, authority Signer) error\n```\nSignCert sets c.SignatureKey to the authority's public key and stores a Signature, by authority, in the certificate.\n\n```go\nfunc (c *Certificate) Type() string\n```\nType returns the key name. It is part of the PublicKey interface.\n\n```go\nfunc (c *Certificate) Verify(data []byte, sig *Signature) error\n```\nVerify verifies a signature against the certificate's public key. It is part of the PublicKey interface.\n\n```go\ntype Channel interface {\n\t// Read reads up to len(data) bytes from the channel.\n\tRead(data []byte) (int, error)\n\n\t// Write writes len(data) bytes to the channel.\n\tWrite(data []byte) (int, error)\n\n\t// Close signals end of channel use. No data may be sent after this\n\t// call.\n\tClose() error\n\n\t// CloseWrite signals the end of sending in-band\n\t// data. Requests may still be sent, and the other side may\n\t// still send data\n\tCloseWrite() error\n\n\t// SendRequest sends a channel request.  If wantReply is true,\n\t// it will wait for a reply and return the result as a\n\t// boolean, otherwise the return value will be false. Channel\n\t// requests are out-of-band messages so they may be sent even\n\t// if the data stream is closed or blocked by flow control.\n\tSendRequest(name string, wantReply bool, payload []byte) (bool, error)\n\n\t// Stderr returns an io.ReadWriter that writes to this channel with the\n\t// extended data type set to stderr.\n\tStderr() io.ReadWriter\n}\n```\nA Channel is an ordered, reliable, flow-controlled, duplex stream that is multiplexed over an SSH connection.\n\n```go\ntype Client struct {\n\tConn\n\t// contains filtered or unexported fields\n}\n```\nClient implements a traditional SSH client that supports shells, subprocesses, port forwarding and tunneled dialing.\n\n```go\nfunc Dial(network, addr string, config *ClientConfig) (*Client, error)\n```\nDial starts a client connection to the given SSH server. It is a convenience function that connects to the given network address, initiates the SSH handshake, and then sets up a Client.  For access to incoming channels and requests, use net.Dial with NewClientConn instead.\n\n```go\nfunc NewClient(c Conn, chans \u003c-chan NewChannel, reqs \u003c-chan *Request) *Client\n```\nNewClient creates a Client on top of the given connection.\n\n```go\nfunc (c *Client) Dial(n, addr string) (net.Conn, error)\n```\nDial initiates a connection to the addr from the remote host. The resulting connection has a zero LocalAddr() and RemoteAddr().\n\n```go\nfunc (c *Client) DialTCP(n string, laddr, raddr *net.TCPAddr) (net.Conn, error)\n```\nDialTCP connects to the remote address raddr on the network net, which must be \"tcp\", \"tcp4\", or \"tcp6\".  If laddr is not nil, it is used as the local address for the connection.\n\n```go\nfunc (c *Client) HandleChannelOpen(channelType string) \u003c-chan NewChannel\n```\nHandleChannelOpen returns a channel on which NewChannel requests for the given type are sent. If the type already is being handled, nil is returned. The channel is closed when the connection is closed.\n\n```go\nfunc (c *Client) Listen(n, addr string) (net.Listener, error)\n```\nListen requests the remote peer open a listening socket on addr. Incoming connections will be available by calling Accept on the returned net.Listener. The listener must be serviced, or the SSH connection may hang.\n\n```go\nfunc (c *Client) ListenTCP(laddr *net.TCPAddr) (net.Listener, error)\n```\nListenTCP requests the remote peer open a listening socket on laddr. Incoming connections will be available by calling Accept on the returned net.Listener.\n\n```go\nfunc (c *Client) NewSession() (*Session, error)\n```\nNewSession opens a new Session for this client. (A session is a remote execution of a program.)\n\n```go\ntype ClientConfig struct {\n\t// Config contains configuration that is shared between clients and\n\t// servers.\n\tConfig\n\n\t// User contains the username to authenticate as.\n\tUser string\n\n\t// Auth contains possible authentication methods to use with the\n\t// server. Only the first instance of a particular RFC 4252 method will\n\t// be used during authentication.\n\tAuth []AuthMethod\n\n\t// HostKeyCallback, if not nil, is called during the cryptographic\n\t// handshake to validate the server's host key. A nil HostKeyCallback\n\t// implies that all host keys are accepted.\n\tHostKeyCallback func(hostname string, remote net.Addr, key PublicKey) error\n\n\t// ClientVersion contains the version identification string that will\n\t// be used for the connection. If empty, a reasonable default is used.\n\tClientVersion string\n}\n```\nA ClientConfig structure is used to configure a Client. It must not be modified after having been passed to an SSH function.\n\n```go\ntype Config struct {\n\t// Rand provides the source of entropy for cryptographic\n\t// primitives. If Rand is nil, the cryptographic random reader\n\t// in package crypto/rand will be used.\n\tRand io.Reader\n\n\t// The maximum number of bytes sent or received after which a\n\t// new key is negotiated. It must be at least 256. If\n\t// unspecified, 1 gigabyte is used.\n\tRekeyThreshold uint64\n\n\t// The allowed key exchanges algorithms. If unspecified then a\n\t// default set of algorithms is used.\n\tKeyExchanges []string\n\n\t// The allowed cipher algorithms. If unspecified then a sensible\n\t// default is used.\n\tCiphers []string\n\n\t// The allowed MAC algorithms. If unspecified then a sensible default\n\t// is used.\n\tMACs []string\n}\n```\nConfig contains configuration data common to both ServerConfig and ClientConfig.\n\n```go\nfunc (c *Config) SetDefaults()\n```\nSetDefaults sets sensible values for unset fields in config. This is exported for testing: Configs passed to SSH functions are copied and have default values set automatically.\n\n```go\ntype Conn interface {\n\tConnMetadata\n\n\t// SendRequest sends a global request, and returns the\n\t// reply. If wantReply is true, it returns the response status\n\t// and payload. See also RFC4254, section 4.\n\tSendRequest(name string, wantReply bool, payload []byte) (bool, []byte, error)\n\n\t// OpenChannel tries to open an channel. If the request is\n\t// rejected, it returns *OpenChannelError. On success it returns\n\t// the SSH Channel and a Go channel for incoming, out-of-band\n\t// requests. The Go channel must be serviced, or the\n\t// connection will hang.\n\tOpenChannel(name string, data []byte) (Channel, \u003c-chan *Request, error)\n\n\t// Close closes the underlying network connection\n\tClose() error\n\n\t// Wait blocks until the connection has shut down, and returns the\n\t// error causing the shutdown.\n\tWait() error\n}\n```\nConn represents an SSH connection for both server and client roles. Conn is the basis for implementing an application layer, such as ClientConn, which implements the traditional shell access for clients.\n\n```go\nfunc NewClientConn(c net.Conn, addr string, config *ClientConfig) (Conn, \u003c-chan NewChannel, \u003c-chan *Request, error)\n```\nNewClientConn establishes an authenticated SSH connection using c as the underlying transport.  The Request and NewChannel channels must be serviced or the connection will hang.\n\n```go\ntype ConnMetadata interface {\n\t// User returns the user ID for this connection.\n\t// It is empty if no authentication is used.\n\tUser() string\n\n\t// SessionID returns the sesson hash, also denoted by H.\n\tSessionID() []byte\n\n\t// ClientVersion returns the client's version string as hashed\n\t// into the session ID.\n\tClientVersion() []byte\n\n\t// ServerVersion returns the client's version string as hashed\n\t// into the session ID.\n\tServerVersion() []byte\n\n\t// RemoteAddr returns the remote address for this connection.\n\tRemoteAddr() net.Addr\n\n\t// LocalAddr returns the local address for this connection.\n\tLocalAddr() net.Addr\n}\n```\nConnMetadata holds metadata for the connection.\n\n```go\ntype ExitError struct {\n\tWaitmsg\n}\n```\nAn ExitError reports unsuccessful completion of a remote command.\n\n```go\nfunc (e *ExitError) Error() string\n```\n\n```go\ntype KeyboardInteractiveChallenge func(user, instruction string, questions []string, echos []bool) (answers []string, err error)\n```\nKeyboardInteractiveChallenge should print questions, optionally disabling echoing (e.g. for passwords), and return all the answers. Challenge may be called multiple times in a single session. After successful authentication, the server may send a challenge with no questions, for which the user and instruction messages should be printed.  RFC 4256 section 3.3 details how the UI should behave for both CLI and GUI environments.\n\n```go\ntype NewChannel interface {\n\t// Accept accepts the channel creation request. It returns the Channel\n\t// and a Go channel containing SSH requests. The Go channel must be\n\t// serviced otherwise the Channel will hang.\n\tAccept() (Channel, \u003c-chan *Request, error)\n\n\t// Reject rejects the channel creation request. After calling\n\t// this, no other methods on the Channel may be called.\n\tReject(reason RejectionReason, message string) error\n\n\t// ChannelType returns the type of the channel, as supplied by the\n\t// client.\n\tChannelType() string\n\n\t// ExtraData returns the arbitrary payload for this channel, as supplied\n\t// by the client. This data is specific to the channel type.\n\tExtraData() []byte\n}\n```\nNewChannel represents an incoming request to a channel. It must either be accepted for use by calling Accept, or rejected by calling Reject.\n\n```go\ntype OpenChannelError struct {\n\tReason  RejectionReason\n\tMessage string\n}\n```\nOpenChannelError is returned if the other side rejects an OpenChannel request.\n\n```go\nfunc (e *OpenChannelError) Error() string\n```\n\n```go\ntype Permissions struct {\n\t// Critical options restrict default permissions. Common\n\t// restrictions are \"source-address\" and \"force-command\". If\n\t// the server cannot enforce the restriction, or does not\n\t// recognize it, the user should not authenticate.\n\tCriticalOptions map[string]string\n\n\t// Extensions are extra functionality that the server may\n\t// offer on authenticated connections. Common extensions are\n\t// \"permit-agent-forwarding\", \"permit-X11-forwarding\". Lack of\n\t// support for an extension does not preclude authenticating a\n\t// user.\n\tExtensions map[string]string\n}\n```\nThe Permissions type holds fine-grained permissions that are specific to a user or a specific authentication method for a user. Permissions, except for \"source-address\", must be enforced in the server application layer, after successful authentication. The Permissions are passed on in ServerConn so a server implementation can honor them.\n\n```go\ntype PublicKey interface {\n\t// Type returns the key's type, e.g. \"ssh-rsa\".\n\tType() string\n\n\t// Marshal returns the serialized key data in SSH wire format,\n\t// with the name prefix.\n\tMarshal() []byte\n\n\t// Verify that sig is a signature on the given data using this\n\t// key. This function will hash the data appropriately first.\n\tVerify(data []byte, sig *Signature) error\n}\n```\nPublicKey is an abstraction of different types of public keys.\n\n```go\nfunc NewPublicKey(k interface{}) (PublicKey, error)\n```\nNewPublicKey takes a pointer to rsa, dsa or ecdsa PublicKey and returns a corresponding ssh PublicKey instance. EC keys should use P256, P384 or P521.\n\n```go\nfunc ParseAuthorizedKey(in []byte) (out PublicKey, comment string, options []string, rest []byte, err error)\n```\nParseAuthorizedKeys parses a public key from an authorized\\_keys file used in OpenSSH according to the sshd(8) manual page.\n\n```go\nfunc ParsePublicKey(in []byte) (out PublicKey, err error)\n```\nParsePublicKey parses an SSH public key formatted for use in the SSH wire protocol according to RFC 4253, section 6.6.\n\n```go\ntype RejectionReason uint32\n```\nRejectionReason is an enumeration used when rejecting channel creation requests. See RFC 4254, section 5.1.\n\n```go\nconst (\n\tProhibited RejectionReason = iota + 1\n\tConnectionFailed\n\tUnknownChannelType\n\tResourceShortage\n)\n```\n\n```go\nfunc (r RejectionReason) String() string\n```\nString converts the rejection reason to human readable form.\n\n```go\ntype Request struct {\n\tType      string\n\tWantReply bool\n\tPayload   []byte\n\t// contains filtered or unexported fields\n}\n```\nRequest is a request sent outside of the normal stream of data. Requests can either be specific to an SSH channel, or they can be global.\n\n```go\nfunc (r *Request) Reply(ok bool, payload []byte) error\n```\nReply sends a response to a request. It must be called for all requests where WantReply is true and is a no-op otherwise. The payload argument is ignored for replies to channel-specific requests.\n\n```go\ntype ServerConfig struct {\n\t// Config contains configuration shared between client and server.\n\tConfig\n\n\t// NoClientAuth is true if clients are allowed to connect without\n\t// authenticating.\n\tNoClientAuth bool\n\n\t// PasswordCallback, if non-nil, is called when a user\n\t// attempts to authenticate using a password.\n\tPasswordCallback func(conn ConnMetadata, password []byte) (*Permissions, error)\n\n\t// PublicKeyCallback, if non-nil, is called when a client attempts public\n\t// key authentication. It must return true if the given public key is\n\t// valid for the given user. For example, see CertChecker.Authenticate.\n\tPublicKeyCallback func(conn ConnMetadata, key PublicKey) (*Permissions, error)\n\n\t// KeyboardInteractiveCallback, if non-nil, is called when\n\t// keyboard-interactive authentication is selected (RFC\n\t// 4256). The client object's Challenge function should be\n\t// used to query the user. The callback may offer multiple\n\t// Challenge rounds. To avoid information leaks, the client\n\t// should be presented a challenge even if the user is\n\t// unknown.\n\tKeyboardInteractiveCallback func(conn ConnMetadata, client KeyboardInteractiveChallenge) (*Permissions, error)\n\n\t// AuthLogCallback, if non-nil, is called to log all authentication\n\t// attempts.\n\tAuthLogCallback func(conn ConnMetadata, method string, err error)\n\t// contains filtered or unexported fields\n}\n```\nServerConfig holds server specific configuration data.\n\n```go\nfunc (s *ServerConfig) AddHostKey(key Signer)\n```\nAddHostKey adds a private key as a host key. If an existing host key exists with the same algorithm, it is overwritten. Each server config must have at least one host key.\n\n```go\ntype ServerConn struct {\n\tConn\n\n\t// If the succeeding authentication callback returned a\n\t// non-nil Permissions pointer, it is stored here.\n\tPermissions *Permissions\n}\n```\nServerConn is an authenticated SSH connection, as seen from the server\n\n```go\nfunc NewServerConn(c net.Conn, config *ServerConfig) (*ServerConn, \u003c-chan NewChannel, \u003c-chan *Request, error)\n```\nNewServerConn starts a new SSH server with c as the underlying transport.  It starts with a handshake and, if the handshake is unsuccessful, it closes the connection and returns an error.  The Request and NewChannel channels must be serviced, or the connection will hang.\n\n```go\ntype Session struct {\n\t// Stdin specifies the remote process's standard input.\n\t// If Stdin is nil, the remote process reads from an empty\n\t// bytes.Buffer.\n\tStdin io.Reader\n\n\t// Stdout and Stderr specify the remote process's standard\n\t// output and error.\n\t//\n\t// If either is nil, Run connects the corresponding file\n\t// descriptor to an instance of ioutil.Discard. There is a\n\t// fixed amount of buffering that is shared for the two streams.\n\t// If either blocks it may eventually cause the remote\n\t// command to block.\n\tStdout io.Writer\n\tStderr io.Writer\n\t// contains filtered or unexported fields\n}\n```\nA Session represents a connection to a remote command or shell.\n\n```go\nfunc (s *Session) Close() error\n```\n\n```go\nfunc (s *Session) CombinedOutput(cmd string) ([]byte, error)\n```\nCombinedOutput runs cmd on the remote host and returns its combined standard output and standard error.\n\n```go\nfunc (s *Session) Output(cmd string) ([]byte, error)\n```\nOutput runs cmd on the remote host and returns its standard output.\n\n```go\nfunc (s *Session) RequestPty(term string, h, w int, termmodes TerminalModes) error\n```\nRequestPty requests the association of a pty with the session on the remote host.\n\n```go\nfunc (s *Session) RequestSubsystem(subsystem string) error\n```\nRequestSubsystem requests the association of a subsystem with the session on the remote host. A subsystem is a predefined command that runs in the background when the ssh session is initiated\n\n```go\nfunc (s *Session) Run(cmd string) error\n```\nRun runs cmd on the remote host. Typically, the remote server passes cmd to the shell for interpretation. A Session only accepts one call to Run, Start, Shell, Output, or CombinedOutput.\n\nThe returned error is nil if the command runs, has no problems copying stdin, stdout, and stderr, and exits with a zero exit status.\n\nIf the command fails to run or doesn't complete successfully, the error is of type \\*ExitError. Other error types may be returned for I/O problems.\n\n```go\nfunc (s *Session) SendRequest(name string, wantReply bool, payload []byte) (bool, error)\n```\nSendRequest sends an out-of-band channel request on the SSH channel underlying the session.\n\n```go\nfunc (s *Session) Setenv(name, value string) error\n```\nSetenv sets an environment variable that will be applied to any command executed by Shell or Run.\n\n```go\nfunc (s *Session) Shell() error\n```\nShell starts a login shell on the remote host. A Session only accepts one call to Run, Start, Shell, Output, or CombinedOutput.\n\n```go\nfunc (s *Session) Signal(sig Signal) error\n```\nSignal sends the given signal to the remote process. sig is one of the SIG\\* constants.\n\n```go\nfunc (s *Session) Start(cmd string) error\n```\nStart runs cmd on the remote host. Typically, the remote server passes cmd to the shell for interpretation. A Session only accepts one call to Run, Start or Shell.\n\n```go\nfunc (s *Session) StderrPipe() (io.Reader, error)\n```\nStderrPipe returns a pipe that will be connected to the remote command's standard error when the command starts. There is a fixed amount of buffering that is shared between stdout and stderr streams. If the StderrPipe reader is not serviced fast enough it may eventually cause the remote command to block.\n\n```go\nfunc (s *Session) StdinPipe() (io.WriteCloser, error)\n```\nStdinPipe returns a pipe that will be connected to the remote command's standard input when the command starts.\n\n```go\nfunc (s *Session) StdoutPipe() (io.Reader, error)\n```\nStdoutPipe returns a pipe that will be connected to the remote command's standard output when the command starts. There is a fixed amount of buffering that is shared between stdout and stderr streams. If the StdoutPipe reader is not serviced fast enough it may eventually cause the remote command to block.\n\n```go\nfunc (s *Session) Wait() error\n```\nWait waits for the remote command to exit.\n\nThe returned error is nil if the command runs, has no problems copying stdin, stdout, and stderr, and exits with a zero exit status.\n\nIf the command fails to run or doesn't complete successfully, the error is of type \\*ExitError. Other error types may be returned for I/O problems.\n\n```go\ntype Signal string\n```\n\n```go\nconst (\n\tSIGABRT Signal = \"ABRT\"\n\tSIGALRM Signal = \"ALRM\"\n\tSIGFPE  Signal = \"FPE\"\n\tSIGHUP  Signal = \"HUP\"\n\tSIGILL  Signal = \"ILL\"\n\tSIGINT  Signal = \"INT\"\n\tSIGKILL Signal = \"KILL\"\n\tSIGPIPE Signal = \"PIPE\"\n\tSIGQUIT Signal = \"QUIT\"\n\tSIGSEGV Signal = \"SEGV\"\n\tSIGTERM Signal = \"TERM\"\n\tSIGUSR1 Signal = \"USR1\"\n\tSIGUSR2 Signal = \"USR2\"\n)\n```\nPOSIX signals as listed in RFC 4254 Section 6.10.\n\n```go\ntype Signature struct {\n\tFormat string\n\tBlob   []byte\n}\n```\nSignature represents a cryptographic signature.\n\n```go\ntype Signer interface {\n\t// PublicKey returns an associated PublicKey instance.\n\tPublicKey() PublicKey\n\n\t// Sign returns raw signature for the given data. This method\n\t// will apply the hash specified for the keytype to the data.\n\tSign(rand io.Reader, data []byte) (*Signature, error)\n}\n```\nA Signer can create signatures that verify against a public key.\n\n```go\nfunc NewCertSigner(cert *Certificate, signer Signer) (Signer, error)\n```\nNewCertSigner returns a Signer that signs with the given Certificate, whose private key is held by signer. It returns an error if the public key in cert doesn't match the key used by signer.\n\n```go\nfunc NewSignerFromKey(k interface{}) (Signer, error)\n```\nNewSignerFromKey takes a pointer to rsa, dsa or ecdsa PrivateKey returns a corresponding Signer instance. EC keys should use P256, P384 or P521.\n\n```go\nfunc ParsePrivateKey(pemBytes []byte) (Signer, error)\n```\nParsePrivateKey returns a Signer from a PEM encoded private key. It supports the same keys as ParseRawPrivateKey.\n\n```go\ntype TerminalModes map[uint8]uint32\n```\n\n```go\ntype Waitmsg struct {\n\t// contains filtered or unexported fields\n}\n```\nWaitmsg stores the information about an exited remote command as reported by Wait.\n\n```go\nfunc (w Waitmsg) ExitStatus() int\n```\nExitStatus returns the exit status of the remote command.\n\n```go\nfunc (w Waitmsg) Lang() string\n```\nLang returns the language tag. See RFC 3066\n\n```go\nfunc (w Waitmsg) Msg() string\n```\nMsg returns the exit message given by the remote command\n\n```go\nfunc (w Waitmsg) Signal() string\n```\nSignal returns the exit signal of the remote command if it was terminated violently.\n\n```go\nfunc (w Waitmsg) String() string\n```\n\n","path":"github.com/wfernandes/cli/src/code.google.com/p/go.crypto/ssh","name":"ssh","synopsis":"Package ssh implements an SSH client and server.","isRedistributable":true}
