@types/ssh2
- Version 1.15.1
- Published
- 85.6 kB
- 1 dependency
- MIT license
Install
npm i @types/ssh2
yarn add @types/ssh2
pnpm add @types/ssh2
Overview
TypeScript definitions for ssh2
Index
Functions
Classes
Interfaces
SFTPWrapper
- appendFile()
- attrs()
- chmod()
- chown()
- close()
- createReadStream()
- createWriteStream()
- data()
- destroy()
- end()
- exists()
- ext_copy_data()
- ext_openssh_expandPath()
- ext_openssh_fstatvfs()
- ext_openssh_fsync()
- ext_openssh_hardlink()
- ext_openssh_lsetstat()
- ext_openssh_rename()
- ext_openssh_statvfs()
- fastGet()
- fastPut()
- fchmod()
- fchown()
- fsetstat()
- fstat()
- futimes()
- handle()
- lstat()
- mkdir()
- name()
- on()
- once()
- open()
- opendir()
- read()
- readdir()
- readFile()
- readlink()
- realpath()
- rename()
- rmdir()
- setstat()
- stat()
- status()
- symlink()
- unlink()
- utimes()
- write()
- writeFile()
TerminalModes
- CS7
- CS8
- ECHO
- ECHOCTL
- ECHOE
- ECHOK
- ECHOKE
- ECHONL
- ICANON
- ICRNL
- IEXTEN
- IGNCR
- IGNPAR
- IMAXBEL
- INLCR
- INPCK
- ISIG
- ISTRIP
- IUCLC
- IXANY
- IXOFF
- IXON
- NOFLSH
- OCRNL
- OLCUC
- ONLCR
- ONLRET
- ONOCR
- OPOST
- PARENB
- PARMRK
- PARODD
- PENDIN
- TOSTOP
- TTY_OP_ISPEED
- TTY_OP_OSPEED
- VDISCARD
- VDSUSP
- VEOF
- VEOL
- VEOL2
- VERASE
- VFLUSH
- VINTR
- VKILL
- VLNEXT
- VQUIT
- VREPRINT
- VSTART
- VSTATUS
- VSTOP
- VSUSP
- VSWTCH
- VWERASE
- XCASE
Type Aliases
- AcceptConnection
- AcceptSftpConnection
- AlgorithmList
- AnyAuthMethod
- AuthContext
- AuthenticationType
- AuthHandlerMiddleware
- Callback
- ChangePasswordCallback
- ChannelSubType
- ChannelType
- CipherAlgorithm
- ClientCallback
- ClientForwardCallback
- ClientSFTPCallback
- CompressionAlgorithm
- DebugFunction
- ErrorCallback
- GetStreamCallback
- HostFingerprintVerifier
- HostVerifier
- IdentityCallback
- KexAlgorithm
- KeyboardInteractiveCallback
- KeyType
- KnownPublicKeys
- MacAlgorithm
- NextAuthHandler
- OpenMode
- PrivateKeys
- RejectConnection
- ServerCallback
- ServerConnectionListener
- ServerHostKeyAlgorithm
- SessionAccept
- SessionAcceptReject
- SignCallback
- SyncHostFingerprintVerifier
- SyncHostVerifier
- VerifyCallback
Namespaces
Functions
function createAgent
createAgent: (socketPath: string | 'pageant') => BaseAgent;
Creates and returns a new agent instance using the same logic as the
Client
'sagent
configuration option: if the platform is Windows and it's the value "pageant", it creates aPageantAgent
, otherwise if it's not a path to a Windows pipe it creates aCygwinAgent
. In all other cases, it creates anOpenSSHAgent
.
Classes
class AgentProtocol
class AgentProtocol extends Duplex {}
constructor
constructor(isClient: boolean);
Creates and returns a new AgentProtocol instance.
isClient
determines whether the instance operates in client or server mode.
method failureReply
failureReply: (request: AgentInboundRequest) => void;
(Server mode only) Replies to the given
request
with a failure response.
method getIdentities
getIdentities: ( callback: (err: Error | undefined, publicKeys?: ParsedKey[]) => void) => void;
(Client mode only) Requests a list of public keys from the agent.
callback
is passed(err, keys)
wherekeys
is a possible array of public keys for authentication.
method getIdentitiesReply
getIdentitiesReply: (request: AgentInboundRequest, keys: ParsedKey[]) => void;
(Server mode only) Responds to a identities list
request
with the given array of keys inkeys
.
method on
on: { (event: 'identities', listener: (req: AgentInboundRequest) => void): this; ( event: 'sign', listener: ( req: AgentInboundRequest, pubKey: ParsedKey, data: Buffer, options: SigningRequestOptions ) => void ): this; (event: string | symbol, listener: Function): this;};
(Server mode only) The client has requested a list of public keys stored in the agent. Use
failureReply()
orgetIdentitiesReply()
to reply appropriately.(Server mode only) The client has requested
data
to be signed using the key identified bypubKey
. UsefailureReply()
orsignReply()
to reply appropriately.
method once
once: { (event: 'identities', listener: (req: AgentInboundRequest) => void): this; ( event: 'sign', listener: ( req: AgentInboundRequest, pubKey: ParsedKey, data: Buffer, options: SigningRequestOptions ) => void ): this; (event: string | symbol, listener: Function): this;};
(Server mode only) The client has requested a list of public keys stored in the agent. Use
failureReply()
orgetIdentitiesReply()
to reply appropriately.(Server mode only) The client has requested
data
to be signed using the key identified bypubKey
. UsefailureReply()
orsignReply()
to reply appropriately.
method sign
sign: { ( pubKey: ParsedKey | Buffer | string, data: Buffer, options?: SigningRequestOptions, callback?: SignCallback ): boolean; (pubKey: any, data: Buffer, callback?: SignCallback): boolean;};
(Client mode only) Signs the datawith the given public key, and calls back with its signature.
method signReply
signReply: (request: AgentInboundRequest, signature: Buffer) => void;
(Server mode only) Responds to a sign
request
with the given signature insignature
.
class BaseAgent
abstract class BaseAgent< TPublicKey extends string | Buffer | ParsedKey = string | Buffer | ParsedKey> {}
method getIdentities
abstract getIdentities: (cb: IdentityCallback<TPublicKey>) => void;
Retrieves user identities, where
keys
is a possible array of public keys for authentication.
method getStream
getStream: (cb: GetStreamCallback) => void;
Optional method that may be implemented to support agent forwarding. Callback should be invoked with a Duplex stream to be used to communicate with your agent/ You will probably want to utilize
AgentProtocol
as agent forwarding is an OpenSSH feature, so thestream
needs to be able to transmit/receive OpenSSH agent protocol packets.
method sign
abstract sign: { ( pubKey: TPublicKey, data: Buffer, options: SigningRequestOptions, cb?: SignCallback ): void; (pubKey: TPublicKey, data: Buffer, cb: SignCallback): void;};
Signs the datawith the given public key, and calls back with its signature. Note that, in the current implementation, "options" is always an empty object.
class Client
class Client extends EventEmitter {}
method connect
connect: (config: ConnectConfig) => this;
Attempts a connection to a server.
method destroy
destroy: () => this;
Destroys the socket.
method end
end: () => this;
Disconnects the socket.
method exec
exec: { (command: string, options: ExecOptions, callback: ClientCallback): this; (command: string, callback: ClientCallback): this;};
Executes a command on the server.
Parameter command
The command to execute.
Parameter options
Options for the command.
Parameter callback
The callback to execute when the command has completed.
Executes a command on the server.
Parameter command
The command to execute.
Parameter callback
The callback to execute when the command has completed.
method forwardIn
forwardIn: ( remoteAddr: string, remotePort: number, callback?: ClientForwardCallback) => this;
Bind to
remoteAddr
onremotePort
on the server and forward incoming TCP connections.Parameter remoteAddr
The remote address to bind on the server. The following lists several special values for
remoteAddr
and their respective bindings:| address | description |:--------------|:----------- |
''
| Listen on all protocol families supported by the server |'0.0.0.0'
| Listen on all IPv4 addresses |'::'
| Listen on all IPv6 addresses |'localhost'
| Listen on the loopback interface for all protocol families |'127.0.0.1'
| Listen on the loopback interfaces for IPv4 |'::1'
| Listen on the loopback interfaces for IPv6Parameter remotePort
The remote port to bind on the server. If this value is
0
, the actual bound port is provided tocallback
.Parameter callback
An optional callback that is invoked when the remote address is bound.
method forwardOut
forwardOut: ( srcIP: string, srcPort: number, dstIP: string, dstPort: number, callback?: ClientCallback) => this;
Open a connection with
srcIP
andsrcPort
as the originating address and port anddstIP
anddstPort
as the remote destination address and port.Parameter srcIP
The originating address.
Parameter srcPort
The originating port.
Parameter dstIP
The destination address.
Parameter dstPort
The destination port.
Parameter callback
The callback that is invoked when the address is bound.
method on
on: { (event: 'banner', listener: (message: string) => void): this; (event: 'ready', listener: () => void): this; ( event: 'tcp connection', listener: ( details: TcpConnectionDetails, accept: AcceptConnection<ClientChannel>, reject: RejectConnection ) => void ): this; ( event: 'x11', listener: ( details: X11Details, accept: AcceptConnection<ClientChannel>, reject: RejectConnection ) => void ): this; ( event: 'keyboard-interactive', listener: ( name: string, instructions: string, lang: string, prompts: Prompt[], finish: KeyboardInteractiveCallback ) => void ): this; ( event: 'change password', listener: (message: string, done: ChangePasswordCallback) => void ): this; ( event: 'error', listener: (err: Error & ClientErrorExtensions) => void ): this; (event: 'end', listener: () => void): this; (event: 'close', listener: () => void): this; (event: 'timeout', listener: () => void): this; (event: 'connect', listener: () => void): this; (event: 'greeting', listener: (greeting: string) => void): this; ( event: 'handshake', listener: (negotiated: NegotiatedAlgorithms) => void ): this; (event: 'hostkeys', listener: (keys: ParsedKey[]) => void): this; ( event: 'unix connection', listener: ( info: UNIXConnectionDetails, accept: AcceptConnection<Channel>, reject: RejectConnection ) => void ): this;};
Emitted when a notice was sent by the server upon connection.
Emitted when authentication was successful.
Emitted when an incoming forwarded TCP connection is being requested.
Calling
accept()
accepts the connection and returns aChannel
object. Callingreject()
rejects the connection and no further action is needed.Emitted when an incoming X11 connection is being requested.
Calling
accept()
accepts the connection and returns aChannel
object. Callingreject()
rejects the connection and no further action is needed.Emitted when the server is asking for replies to the given
prompts
for keyboard- interactive user authentication.*
name
is generally what you'd use as a window title (for GUI apps). *prompts
is an array ofPrompt
objects.The answers for all prompts must be provided as an array of strings and passed to
finish
when you are ready to continue.NOTE: It's possible for the server to come back and ask more questions.
Emitted when the server has requested that the user's password be changed, if using password-based user authentication.
Call
done
with the new password.Emitted when an error occurred.
Emitted when the socket was disconnected.
Emitted when the socket was closed.
Emitted when the socket has timed out.
Emitted when the socket has connected.
Emitted when the server responds with a greeting message.
Emitted when a handshake has completed (either initial or rekey).
Emitted when the server announces its available host keys.
An incoming forwarded UNIX socket connection is being requested.
method once
once: { (event: 'banner', listener: (message: string) => void): this; (event: 'ready', listener: () => void): this; ( event: 'tcp connection', listener: ( details: TcpConnectionDetails, accept: AcceptConnection<ClientChannel>, reject: RejectConnection ) => void ): this; ( event: 'x11', listener: ( details: X11Details, accept: AcceptConnection<ClientChannel>, reject: RejectConnection ) => void ): this; ( event: 'keyboard-interactive', listener: ( name: string, instructions: string, lang: string, prompts: Prompt[], finish: KeyboardInteractiveCallback ) => void ): this; ( event: 'change password', listener: (message: string, done: ChangePasswordCallback) => void ): this; ( event: 'error', listener: (err: Error & ClientErrorExtensions) => void ): this; (event: 'end', listener: () => void): this; (event: 'close', listener: () => void): this; (event: 'timeout', listener: () => void): this; (event: 'connect', listener: () => void): this; (event: 'greeting', listener: (greeting: string) => void): this; ( event: 'handshake', listener: (negotiated: NegotiatedAlgorithms) => void ): this; (event: 'hostkeys', listener: (keys: ParsedKey[]) => void): this; ( event: 'unix connection', listener: ( info: UNIXConnectionDetails, accept: AcceptConnection<Channel>, reject: RejectConnection ) => void ): this;};
Emitted when a notice was sent by the server upon connection.
Emitted when authentication was successful.
Emitted when an incoming forwarded TCP connection is being requested.
Calling
accept()
accepts the connection and returns aChannel
object. Callingreject()
rejects the connection and no further action is needed.Emitted when an incoming X11 connection is being requested.
Calling
accept()
accepts the connection and returns aChannel
object. Callingreject()
rejects the connection and no further action is needed.Emitted when the server is asking for replies to the given
prompts
for keyboard- interactive user authentication.*
name
is generally what you'd use as a window title (for GUI apps). *prompts
is an array ofPrompt
objects.The answers for all prompts must be provided as an array of strings and passed to
finish
when you are ready to continue.NOTE: It's possible for the server to come back and ask more questions.
Emitted when the server has requested that the user's password be changed, if using password-based user authentication.
Call
done
with the new password.Emitted when an error occurred.
Emitted when the socket was disconnected.
Emitted when the socket was closed.
Emitted when the socket has timed out.
Emitted when the socket has connected.
Emitted when the server responds with a greeting message.
Emitted when a handshake has completed (either initial or rekey).
Emitted when the server announces its available host keys.
An incoming forwarded UNIX socket connection is being requested.
method openssh_forwardInStreamLocal
openssh_forwardInStreamLocal: (socketPath: string, cb: Callback) => this;
OpenSSH extension that binds to a UNIX domain socket at
socketPath
on the server and forwards incoming connections.
method openssh_forwardOutStreamLocal
openssh_forwardOutStreamLocal: (socketPath: string, cb: ClientCallback) => this;
OpenSSH extension that opens a connection to a UNIX domain socket at
socketPath
on the server.
method openssh_noMoreSessions
openssh_noMoreSessions: (cb: Callback) => this;
OpenSSH extension that sends a request to reject any new sessions (e.g. exec, shell, sftp, subsys) for this connection.
method openssh_unforwardInStreamLocal
openssh_unforwardInStreamLocal: (socketPath: string, cb: Callback) => this;
OpenSSH extension that unbinds from a UNIX domain socket at
socketPath
on the server and stops forwarding incoming connections.
method sftp
sftp: (callback: ClientSFTPCallback) => this;
Starts an SFTP session.
Parameter callback
The callback that is invoked when the SFTP session has started.
method shell
shell: { ( window: PseudoTtyOptions | false, options: ShellOptions, callback: ClientCallback ): this; (window: false | PseudoTtyOptions, callback: ClientCallback): this; (options: ShellOptions, callback: ClientCallback): this; (callback: ClientCallback): this;};
Starts an interactive shell session on the server.
Parameter window
Either an object containing pseudo-tty settings,
false
to suppress creation of a pseudo-tty.Parameter options
Options for the command.
Parameter callback
The callback to execute when the channel has been created.
Starts an interactive shell session on the server.
Parameter window
Either an object containing pseudo-tty settings,
false
to suppress creation of a pseudo-tty.Parameter callback
The callback to execute when the channel has been created.
Starts an interactive shell session on the server.
Parameter options
Options for the command.
Parameter callback
The callback to execute when the channel has been created.
Starts an interactive shell session on the server.
Parameter callback
The callback to execute when the channel has been created.
method subsys
subsys: (subsystem: string, callback: ClientCallback) => this;
Invokes
subsystem
on the server.Parameter subsystem
The subsystem to start on the server.
Parameter callback
The callback that is invoked when the subsystem has started.
method unforwardIn
unforwardIn: ( remoteAddr: string, remotePort: number, callback?: Callback) => this;
Unbind from
remoteAddr
onremotePort
on the server and stop forwarding incoming TCP connections. Untilcallback
is called, more connections may still come in.Parameter remoteAddr
The remote address to unbind on the server.
Parameter remotePort
The remote port to unbind on the server.
Parameter callback
An optional callback that is invoked when the remote address is unbound.
class CygwinAgent
class CygwinAgent extends OpenSSHAgent {}
Communicates with an agent listening at
socketPath
in a Cygwin environment.
class HTTPAgent
class HTTPAgent extends BaseHTTPAgent {}
constructor
constructor(connectCfg: ConnectConfig, agentOptions: HTTPAgentOptions);
class HTTPSAgent
class HTTPSAgent extends BaseHTTPSAgent {}
constructor
constructor(connectCfg: ConnectConfig, agentOptions: HTTPAgentOptions);
class OpenSSHAgent
class OpenSSHAgent extends BaseAgent<ParsedKey> {}
Communicates with an OpenSSH agent listening on the UNIX socket at
socketPath
.
constructor
constructor(socketPath: string);
method getIdentities
getIdentities: (cb: IdentityCallback<ParsedKey>) => void;
method getStream
getStream: (cb: GetStreamCallback) => void;
method sign
sign: { ( pubKey: ParsedKey | Buffer | string, data: Buffer, options?: SigningRequestOptions, cb?: SignCallback ): boolean; (pubKey: any, data: Buffer, cb?: SignCallback): boolean;};
class PageantAgent
class PageantAgent extends OpenSSHAgent {}
Creates a new agent instance for communicating with a running Pageant agent process.
class Server
class Server extends NetServer {}
constructor
constructor(cfg: ServerConfig, listener?: ServerConnectionListener);
property KEEPALIVE_CLIENT_COUNT_MAX
static KEEPALIVE_CLIENT_COUNT_MAX: number;
property KEEPALIVE_CLIENT_INTERVAL
static KEEPALIVE_CLIENT_INTERVAL: number;
method injectSocket
injectSocket: (socket: Socket) => void;
method on
on: { (event: 'connection', listener: ServerConnectionListener): this; (event: string | symbol, listener: Function): this;};
method once
once: { (event: 'connection', listener: ServerConnectionListener): this; (event: string | symbol, listener: Function): this;};
Interfaces
interface AgentAuthMethod
interface AgentAuthMethod extends AuthMethod {}
Strategy returned from the ConnectConfig.authHandler to connect with an agent.
interface AgentInboundRequest
interface AgentInboundRequest {}
Interface representing an inbound agent request. This is defined as an "opaque type" in the ssh2 documentation, and should only be used for correlation, not introspected.
interface Algorithms
interface Algorithms {}
Overrides for the default transport layer algorithms used for the connection.
The order of the algorithms in the arrays are important, with the most favorable being first.
property cipher
cipher?: AlgorithmList<CipherAlgorithm>;
property compress
compress?: AlgorithmList<CompressionAlgorithm>;
property hmac
hmac?: AlgorithmList<MacAlgorithm>;
property kex
kex?: AlgorithmList<KexAlgorithm>;
property serverHostKey
serverHostKey?: AlgorithmList<ServerHostKeyAlgorithm>;
interface Attributes
interface Attributes {}
interface AuthContextBase
interface AuthContextBase extends EventEmitter {}
property method
method: AuthenticationType;
The method of authentication.
property service
service: string;
The service requesting authentication.
property username
username: string;
The client's username.
method accept
accept: () => void;
Accepts the authentication request.
method on
on: (event: 'abort', listener: () => void) => this;
Emitted when the client aborts the authentication request.
method once
once: (event: 'abort', listener: () => void) => this;
Emitted when the client aborts the authentication request.
method reject
reject: ( authMethodsLeft?: AuthenticationType[], isPartialSuccess?: boolean) => void;
Rejects the authentication request.
interface AuthMethod
interface AuthMethod {}
interface Channel
interface Channel extends Duplex {}
property incoming
incoming: unknown;
property outgoing
outgoing: unknown;
property server
server: boolean;
Indicates whether this is a server or client channel.
property stderr
stderr: Writable | Readable;
Standard error for the Channel.
property stdin
stdin: this;
Standard input for the Channel.
property stdout
stdout: this;
Standard output for the Channel.
property subtype
subtype?: ChannelSubType;
The channel subtype, usually "exec", "shell", or undefined.
property type
type: ChannelType;
The channel type, usually "session".
method close
close: (...args: any[]) => void;
Closes the channel on both sides.
method destroy
destroy: () => this;
Shuts down the channel on this side.
method eof
eof: () => void;
Sends EOF to the remote side.
method exit
exit: { (status: number): void; (signalName: string, coreDumped?: boolean, msg?: string): void;};
method on
on: { (event: 'close', listener: () => void): this; (event: 'eof', listener: () => void): this; (event: 'end', listener: () => void): this; (event: string | symbol, listener: Function): this;};
Emitted once the channel is completely closed on both the client and the server.
method once
once: { (event: 'close', listener: () => void): this; (event: 'eof', listener: () => void): this; (event: 'end', listener: () => void): this; (event: string | symbol, listener: Function): this;};
method setWindow
setWindow: (rows: number, cols: number, height: number, width: number) => void;
Session type-specific methods
method signal
signal: (signalName: string) => void;
interface ClientChannel
interface ClientChannel extends Channel {}
property server
server: false;
Indicates whether this is a server or client channel.
property stderr
stderr: Readable;
Standard error for the Channel.
method on
on: { (event: 'exit', listener: (code: number) => void): this; ( event: 'exit', listener: ( code: null, signal: string, dump: string, desc: string ) => void ): this; (event: string | symbol, listener: Function): this;};
An
exit
event *may* (the SSH2 spec says it is optional) be emitted when the process finishes. If the process finished normally, the process's return value is passed to theexit
callback.
method once
once: { (event: 'exit', listener: (code: number) => void): this; ( event: 'exit', listener: ( code: null, signal: string, dump: string, desc: string ) => void ): this; (event: string | symbol, listener: Function): this;};
interface ClientErrorExtensions
interface ClientErrorExtensions {}
property description
description?: string;
Additional detail for 'client-ssh' messages.
property level
level?: string;
Indicates 'client-socket' for socket-level errors and 'client-ssh' for SSH disconnection messages.
interface ClientInfo
interface ClientInfo {}
interface ConnectConfig
interface ConnectConfig {}
property agent
agent?: BaseAgent | string;
Path to ssh-agent's UNIX socket for ssh-agent-based user authentication (or 'pageant' when using Pagent on Windows).
property agentForward
agentForward?: boolean;
Set to
true
to use OpenSSH agent forwarding (auth-agent@openssh.com
) for the life of the connection.
property algorithms
algorithms?: Algorithms;
Explicit overrides for the default transport layer algorithms used for the connection.
property authHandler
authHandler?: AuthenticationType[] | AuthHandlerMiddleware | AuthMethod[];
Function with parameters (methodsLeft, partialSuccess, callback) where methodsLeft and partialSuccess are null on the first authentication attempt, otherwise are an array and boolean respectively. Return or call callback() with the name of the authentication method to try next (pass false to signal no more methods to try). Valid method names are: 'none', 'password', 'publickey', 'agent', 'keyboard-interactive', 'hostbased'. Default: function that follows a set method order: None -> Password -> Private Key -> Agent (-> keyboard-interactive if tryKeyboard is true) -> Hostbased.
property debug
debug?: DebugFunction;
A function that receives a single string argument to get detailed (local) debug information.
property forceIPv4
forceIPv4?: boolean;
Only connect via resolved IPv4 address for
host
.
property forceIPv6
forceIPv6?: boolean;
Only connect via resolved IPv6 address for
host
.
property host
host?: string;
Hostname or IP address of the server.
property hostHash
hostHash?: string;
The host's key is hashed using this method and passed to
hostVerifier
.
property hostVerifier
hostVerifier?: | HostVerifier | SyncHostVerifier | HostFingerprintVerifier | SyncHostFingerprintVerifier;
Verifies a hexadecimal hash of the host's key.
property ident
ident?: Buffer | string;
A custom server software name/version identifier. Default: 'ssh2js' + moduleVersion + 'srv'
property keepaliveCountMax
keepaliveCountMax?: number;
How many consecutive, unanswered SSH-level keepalive packets that can be sent to the server before disconnection.
property keepaliveInterval
keepaliveInterval?: number;
How often (in milliseconds) to send SSH-level keepalive packets to the server. Set to 0 to disable.
property localAddress
localAddress?: string;
IP address of the network interface to use to connect to the server. Default: (none -- determined by OS)
property localHostname
localHostname?: string;
Along with
localUsername
andprivateKey
, set this to a non-empty string for hostbased user authentication.
property localPort
localPort?: number;
The local port number to connect from. Default: (none -- determined by OS)
property localUsername
localUsername?: string;
Along with
localHostname
andprivateKey
, set this to a non-empty string for hostbased user authentication.
property passphrase
passphrase?: Buffer | string;
For an encrypted private key, this is the passphrase used to decrypt it.
property password
password?: string;
Password for password-based user authentication.
property port
port?: number;
Port number of the server.
property privateKey
privateKey?: Buffer | string;
Buffer or string that contains a private key for either key-based or hostbased user authentication (OpenSSH format).
property readyTimeout
readyTimeout?: number;
* How long (in milliseconds) to wait for the SSH handshake to complete.
property sock
sock?: Readable;
A
ReadableStream
to use for communicating with the server instead of creating and using a new TCP connection (useful for connection hopping).
property strictVendor
strictVendor?: boolean;
Performs a strict server vendor check before sending vendor-specific requests.
property timeout
timeout?: number;
The underlying socket timeout in ms. Default: none)
property tryKeyboard
tryKeyboard?: boolean;
Try keyboard-interactive user authentication if primary user authentication method fails.
property username
username?: string;
Username for authentication.
interface Connection
interface Connection extends EventEmitter {}
property authenticated
authenticated: boolean;
property noMoreSessions
noMoreSessions: boolean;
method end
end: () => this;
Closes the client connection.
method forwardOut
forwardOut: ( boundAddr: string, boundPort: number, remoteAddr: string, remotePort: number, callback: ServerCallback) => this;
Alert the client of an incoming TCP connection on
boundAddr
on portboundPort
fromremoteAddr
on portremotePort
.
method on
on: { (event: 'authentication', listener: (context: AuthContext) => void): this; (event: 'ready', listener: () => void): this; ( event: 'session', listener: ( accept: AcceptConnection<Session>, reject: RejectConnection ) => void ): this; ( event: 'tcpip', listener: ( accept: AcceptConnection<ServerChannel>, reject: RejectConnection, info: TcpipRequestInfo ) => void ): this; ( event: 'openssh.streamlocal', listener: ( accept: AcceptConnection<ServerChannel>, reject: RejectConnection, info: SocketRequestInfo ) => void ): this; ( event: 'request', listener: ( accept: (chosenPort?: number) => void, reject: () => void, name: 'tcpip-forward' | 'cancel-tcpip-forward', info: TcpipBindInfo ) => void ): this; ( event: 'request', listener: ( accept: () => void, reject: () => void, name: | 'streamlocal-forward@openssh.com' | 'cancel-streamlocal-forward@openssh.com', info: SocketBindInfo ) => void ): this; (event: 'rekey', listener: () => void): this; (event: 'error', listener: ErrorCallback): this; (event: 'end', listener: () => void): this; (event: 'close', listener: () => void): this; ( event: 'handshake', listener: (negotiated: NegotiatedAlgorithms) => void ): this; (event: 'greeting', listener: (greeting: string) => void): this;};
Emitted when the client has requested authentication.
Emitted when the client has been successfully authenticated.
Emitted when the client has requested a new session. Sessions are used to start interactive shells, execute commands, request X11 forwarding, etc.
Emitted when the client has requested an outbound (TCP) connection.
Emitted when the client has requested a connection to a UNIX domain socket.
Emitted when the client has sent a global request for name. If info.bindPort === 0, you should pass the chosen port to accept so that the client will know what port was bound.
Emitted when the client has sent a global request for name.
Emitted when the client has finished rekeying (either client or server initiated).
Emitted when an error occurrs.
Emitted when the socket has disconnected.
Emitted when the client socket was closed.
Emitted when the Alogrithms have been negotiated; emitted every time there is a rekey
Emitted if the server sends a greeting header
method once
once: { (event: 'authentication', listener: (context: AuthContext) => void): this; (event: 'ready', listener: () => void): this; ( event: 'session', listener: ( accept: AcceptConnection<Session>, reject: RejectConnection ) => void ): this; ( event: 'tcpip', listener: ( accept: AcceptConnection<ServerChannel>, reject: RejectConnection, info: TcpipRequestInfo ) => void ): this; ( event: 'openssh.streamlocal', listener: ( accept: AcceptConnection<ServerChannel>, reject: RejectConnection, info: SocketRequestInfo ) => void ): this; ( event: 'request', listener: ( accept: (chosenPort?: number) => void, reject: () => void, name: 'tcpip-forward' | 'cancel-tcpip-forward', info: TcpipBindInfo ) => void ): this; ( event: 'request', listener: ( accept: () => void, reject: () => void, name: | 'streamlocal-forward@openssh.com' | 'cancel-streamlocal-forward@openssh.com', info: SocketBindInfo ) => void ): this; (event: 'rekey', listener: () => void): this; (event: 'error', listener: ErrorCallback): this; (event: 'end', listener: () => void): this; (event: 'close', listener: () => void): this; ( event: 'handshake', listener: (negotiated: NegotiatedAlgorithms) => void ): this; (event: 'greeting', listener: (greeting: string) => void): this;};
Emitted when the client has requested authentication.
Emitted when the client has been successfully authenticated.
Emitted when the client has requested a new session. Sessions are used to start interactive shells, execute commands, request X11 forwarding, etc.
Emitted when the client has requested an outbound (TCP) connection.
Emitted when the client has requested a connection to a UNIX domain socket.
Emitted when the client has sent a global request for name. If info.bindPort === 0, you should pass the chosen port to accept so that the client will know what port was bound.
Emitted when the client has sent a global request for name.
Emitted when the client has finished rekeying (either client or server initiated).
Emitted when an error occurrs.
Emitted when the socket has disconnected.
Emitted when the client socket was closed.
Emitted when the Alogrithms have been negotiated; emitted every time there is a rekey
Emitted if the server sends a greeting header
method openssh_forwardOutStreamLocal
openssh_forwardOutStreamLocal: ( socketPath: string, callback: ServerCallback) => this;
Alert the client of an incoming UNIX domain socket connection on socketPath.
Returns
false
if you should wait for thecontinue
event before sending any more traffic.
method rekey
rekey: (callback?: () => void) => void;
Initiates a rekeying with the client.
Returns
false
if you should wait for thecontinue
event before sending any more traffic.Parameter callback
An optional callback added as a one-time handler for the
rekey
event.
method x11
x11: (originAddr: string, originPort: number, channel: ServerCallback) => this;
Alert the client of an incoming X11 client connection from
originAddr
on portoriginPort
.
interface EncryptedPrivateKey
interface EncryptedPrivateKey {}
property key
key: ParsedKey | Buffer | string;
A Buffer or string that contains a private key.
property passphrase
passphrase?: Buffer | string;
The passphrase to decrypt a private key.
interface ExecInfo
interface ExecInfo {}
property command
command: string;
The command line to be executed.
interface ExecOptions
interface ExecOptions {}
property allowHalfOpen
allowHalfOpen?: boolean;
property env
env?: NodeJS.ProcessEnv;
An environment to use for the execution of the command.
property pty
pty?: PseudoTtyOptions | boolean;
Set to
true
to allocate a pseudo-tty with defaults, or an object containing specific pseudo-tty settings.
property x11
x11?: X11Options | number | boolean;
Set either to
true
to use defaults, a number to specify a specific screen number, or an object containing x11 settings.
interface FileEntry
interface FileEntry {}
interface FileEntryWithStats
interface FileEntryWithStats extends Omit<FileEntry, 'attrs'> {}
property attrs
attrs: Stats;
interface Header
interface Header {}
property comments
comments: string;
Any text that comes after the software name/version.
property greeting
greeting?: string;
Any greeting sent by the server
property identRaw
identRaw: string;
The raw identification string sent by the remote party.
property versions
versions: Versions;
Contains various version information parsed from identRaw.
interface HostbasedAuthContext
interface HostbasedAuthContext extends AuthContextBase {}
property blob
blob: Buffer;
The data used to verify the key, or
undefined
if the client is only checking the validity of the key.
property key
key: PublicKey;
The public key sent by the client.
property localHostname
localHostname: string;
The local hostname of the client.
property localUsername
localUsername: string;
The local username of the client.
property method
method: 'hostbased';
The method of authentication.
property signature
signature: Buffer;
The signature to verify, or
undefined
if the client is only checking the validity of the key.
interface HostBasedAuthMethod
interface HostBasedAuthMethod extends AuthMethod {}
Strategy returned from the ConnectConfig.authHandler to connect with host-based authentication.
property key
key: ParsedKey | Buffer | string;
Can be a string, Buffer, or parsed key containing a private key
property localHostname
localHostname: string;
property localUsername
localUsername: string;
property passphrase
passphrase?: Buffer | string;
passphrase
only required for encrypted keys
property type
type: 'hostbased';
interface HTTPAgentOptions
interface HTTPAgentOptions extends AgentOptions {}
property srcIP
srcIP?: string;
interface InputAttributes
interface InputAttributes {}
interface KeyboardAuthContext
interface KeyboardAuthContext extends AuthContextBase {}
property method
method: 'keyboard-interactive';
The method of authentication.
property submethods
submethods: string[];
A list of preferred authentication "sub-methods" sent by the client.
method prompt
prompt: { ( prompts: string | Prompt | Array<string | Prompt>, callback: KeyboardInteractiveCallback ): void; ( prompts: string | Prompt | (string | Prompt)[], title: string, callback: KeyboardInteractiveCallback ): void; ( prompts: string | Prompt | (string | Prompt)[], title: string, instructions: string, callback: KeyboardInteractiveCallback ): void;};
Send prompts to the client.
Parameter prompts
The prompts to send to the client.
Parameter callback
A callback to call with the responses from the client.
Send prompts to the client.
Parameter prompts
The prompts to send to the client.
Parameter title
The title for the prompt.
Parameter callback
A callback to call with the responses from the client.
Send prompts to the client.
Parameter prompts
The prompts to send to the client.
Parameter title
The title for the prompt.
Parameter instructions
Instructions for the client.
Parameter callback
A callback to call with the responses from the client.
interface KeyboardInteractiveAuthMethod
interface KeyboardInteractiveAuthMethod extends AuthMethod {}
Strategy returned from the ConnectConfig.authHandler to connect with an agent.
interface NegotiatedAlgorithms
interface NegotiatedAlgorithms {}
property cs
cs: { cipher: CipherAlgorithm; mac: MacAlgorithm | ''; compress: CompressionAlgorithm; lang: string;};
property kex
kex: KexAlgorithm;
property sc
sc: { cipher: CipherAlgorithm; mac: MacAlgorithm | ''; compress: CompressionAlgorithm; lang: string;};
property serverHostKey
serverHostKey: ServerHostKeyAlgorithm;
interface NoAuthMethod
interface NoAuthMethod extends AuthMethod {}
Strategy returned from the ConnectConfig.authHandler to connect without authentication.
property type
type: 'none';
interface NoneAuthContext
interface NoneAuthContext extends AuthContextBase {}
property method
method: 'none';
The method of authentication.
interface ParsedKey
interface ParsedKey {}
property comment
comment: string;
property type
type: KeyType;
method equals
equals: (key: Buffer | string | ParsedKey) => boolean;
method getPrivatePEM
getPrivatePEM: () => string;
method getPublicPEM
getPublicPEM: () => string;
method getPublicSSH
getPublicSSH: () => Buffer;
method isPrivateKey
isPrivateKey: () => boolean;
method sign
sign: (data: Buffer | string, algo?: string) => Buffer;
method verify
verify: (data: Buffer | string, signature: Buffer, algo?: string) => boolean;
interface PasswordAuthContext
interface PasswordAuthContext extends AuthContextBase {}
property method
method: 'password';
The method of authentication.
property password
password: string;
The password sent by the client.
method requestChange
requestChange: (prompt: string, cb: ChangePasswordCallback) => void;
interface PasswordAuthMethod
interface PasswordAuthMethod extends AuthMethod {}
Strategy returned from the ConnectConfig.authHandler to connect with a password.
interface PseudoTtyInfo
interface PseudoTtyInfo {}
property cols
cols: number;
The number of columns for the pseudo-TTY.
property height
height: number;
The height of the pseudo-TTY in pixels.
property modes
modes: TerminalModes;
Contains the requested terminal modes of the pseudo-TTY.
property rows
rows: number;
The number of rows for the pseudo-TTY.
property width
width: number;
The width of the pseudo-TTY in pixels.
interface PseudoTtyOptions
interface PseudoTtyOptions {}
property cols
cols?: number;
The number of columns (default:
80
).
property height
height?: number;
The height in pixels (default:
480
).
property modes
modes?: TerminalModes;
An object containing Terminal Modes as keys, with each value set to each mode argument. Default: null
property rows
rows?: number;
The number of rows (default:
24
).
property term
term?: string;
The value to use for $TERM (default:
'vt100'
)
property width
width?: number;
The width in pixels (default:
640
).
interface PublicKey
interface PublicKey {}
interface PublicKeyAuthContext
interface PublicKeyAuthContext extends AuthContextBase {}
property blob
blob?: Buffer;
The data used to verify the key, or
undefined
if the client is only checking the validity of the key.
property key
key: PublicKey;
The public key sent by the client.
property method
method: 'publickey';
The method of authentication.
property signature
signature?: Buffer;
The signature to verify, or
undefined
if the client is only checking the validity of the key.
interface PublicKeyAuthMethod
interface PublicKeyAuthMethod extends AuthMethod {}
Strategy returned from the ConnectConfig.authHandler to connect with a public key.
property key
key: ParsedKey | Buffer | string;
property passphrase
passphrase?: Buffer | string;
property type
type: 'publickey';
interface PublicKeyEntry
interface PublicKeyEntry {}
property pubKey
pubKey: | ParsedKey | { pubKey: ParsedKey | Buffer | string; comment?: string; };
interface ReadFileOptions
interface ReadFileOptions {}
interface ReadStream
interface ReadStream extends Readable {}
property pending
pending: boolean;
method close
close: (cb: Callback) => void;
method on
on: { (eventName: 'ready', listener: () => void): this; (eventName: 'open', listener: (handle: Buffer) => void): this; (event: string | symbol, listener: Function): this;};
method once
once: { (eventName: 'ready', listener: () => void): this; (eventName: 'open', listener: (handle: Buffer) => void): this; (event: string | symbol, listener: Function): this;};
method open
open: () => void;
interface ReadStreamOptions
interface ReadStreamOptions extends ReadableOptions {}
interface ServerChannel
interface ServerChannel extends Channel {}
interface ServerConfig
interface ServerConfig {}
property algorithms
algorithms?: Algorithms;
Explicit overrides for the default transport layer algorithms used for the connection.
property banner
banner?: string;
A message that is sent to clients once, right before authentication begins.
property debug
debug?: DebugFunction;
A function that receives a single string argument to get detailed (local) debug information.
property greeting
greeting?: string;
A message that is sent to clients immediately upon connection, before handshaking begins.
property highWaterMark
highWaterMark?: number;
This is the highWaterMark to use for the parser stream (default:
32 * 1024
).
property hostKeys
hostKeys: PrivateKeys;
An array of host private keys.
property ident
ident?: string;
A custom server software name/version identifier.
property keepaliveCountMax
keepaliveCountMax?: number;
The most allowed failed keep alive attempts before closing a connection
property keepaliveInterval
keepaliveInterval?: number;
The keep alive interval for this server
interface Session
interface Session extends ServerChannel {}
method on
on: { ( event: 'pty', listener: ( accept: SessionAccept, reject: RejectConnection, info: PseudoTtyInfo ) => void ): this; ( event: 'window-change', listener: ( accept: SessionAccept, reject: RejectConnection, info: WindowChangeInfo ) => void ): this; ( event: 'x11', listener: ( accept: SessionAccept, reject: RejectConnection, info: X11Info ) => void ): this; ( event: 'env', listener: ( accept: SessionAccept, reject: RejectConnection, info: SetEnvInfo ) => void ): this; ( event: 'signal', listener: ( accept: SessionAccept, reject: RejectConnection, info: SignalInfo ) => void ): this; ( event: 'auth-agent', listener: (accept: SessionAccept, reject: RejectConnection) => void ): this; ( event: 'shell', listener: ( accept: AcceptConnection<ServerChannel>, reject: RejectConnection ) => void ): this; ( event: 'exec', listener: ( accept: AcceptConnection<ServerChannel>, reject: RejectConnection, info: ExecInfo ) => void ): this; ( event: 'sftp', listener: ( accept: AcceptSftpConnection, reject: RejectConnection ) => void ): this; ( event: 'subsystem', listener: ( accept: AcceptConnection<ServerChannel>, reject: RejectConnection, info: SubsystemInfo ) => void ): this; (event: string | symbol, listener: Function): this;};
Emitted when the client requested allocation of a pseudo-TTY for this session.
Emitted when the client reported a change in window dimensions during this session.
Emitted when the client requested X11 forwarding.
Emitted when the client requested an environment variable to be set for this session.
Emitted when the client has sent a POSIX signal.
Emitted when the client has requested incoming ssh-agent requests be forwarded to them.
Emitted when the client has requested an interactive shell.
Emitted when the client has requested execution of a command string.
Emitted when the client has requested the SFTP subsystem.
Emitted when the client has requested an arbitrary subsystem.
method once
once: { ( event: 'pty', listener: ( accept: SessionAccept, reject: RejectConnection, info: PseudoTtyInfo ) => void ): this; ( event: 'window-change', listener: ( accept: SessionAccept, reject: RejectConnection, info: WindowChangeInfo ) => void ): this; ( event: 'x11', listener: ( accept: SessionAccept, reject: RejectConnection, info: X11Info ) => void ): this; ( event: 'env', listener: ( accept: SessionAccept, reject: RejectConnection, info: SetEnvInfo ) => void ): this; ( event: 'signal', listener: ( accept: SessionAccept, reject: RejectConnection, info: SignalInfo ) => void ): this; ( event: 'auth-agent', listener: (accept: SessionAccept, reject: RejectConnection) => void ): this; ( event: 'shell', listener: ( accept: AcceptConnection<ServerChannel>, reject: RejectConnection ) => void ): this; ( event: 'exec', listener: ( accept: AcceptConnection<ServerChannel>, reject: RejectConnection, info: ExecInfo ) => void ): this; ( event: 'sftp', listener: ( accept: AcceptSftpConnection, reject: RejectConnection ) => void ): this; ( event: 'subsystem', listener: ( accept: AcceptConnection<ServerChannel>, reject: RejectConnection, info: SubsystemInfo ) => void ): this; (event: string | symbol, listener: Function): this;};
Emitted when the client requested allocation of a pseudo-TTY for this session.
Emitted when the client reported a change in window dimensions during this session.
Emitted when the client requested X11 forwarding.
Emitted when the client requested an environment variable to be set for this session.
Emitted when the client has sent a POSIX signal.
Emitted when the client has requested incoming ssh-agent requests be forwarded to them.
Emitted when the client has requested an interactive shell.
Emitted when the client has requested execution of a command string.
Emitted when the client has requested the SFTP subsystem.
Emitted when the client has requested an arbitrary subsystem.
interface SetEnvInfo
interface SetEnvInfo {}
interface SFTPWrapper
interface SFTPWrapper extends EventEmitter {}
method appendFile
appendFile: { ( remotePath: string, data: string | Buffer, options: WriteFileOptions, callback?: Callback ): void; (remotePath: string, data: any, callback?: Callback): void;};
(Client-only) Appends data to a file
method attrs
attrs: (reqId: number, attrs: Attributes) => void;
Sends an attrs response for the request identified by id.
method chmod
chmod: (path: string, mode: number | string, callback: Callback) => void;
(Client-only) Sets the mode for
path
.
method chown
chown: (path: string, uid: number, gid: number, callback: Callback) => void;
(Client-only) Sets the owner for
path
.
method close
close: (handle: Buffer, callback: Callback) => void;
(Client-only) Closes the resource associated with
handle
given byopen()
oropendir()
.
method createReadStream
createReadStream: (path: string, options?: ReadStreamOptions) => ReadStream;
(Client-only) Returns a new readable stream for
path
.
method createWriteStream
createWriteStream: (path: string, options?: WriteStreamOptions) => WriteStream;
(Client-only) Returns a new writable stream for
path
.
method data
data: (reqId: number, data: Buffer | string, encoding?: BufferEncoding) => void;
Sends a data response for the request identified by id. data can be a Buffer or string. If data is a string, encoding is the encoding of data.
method destroy
destroy: () => void;
Closes the channel.
method end
end: () => void;
Closes the channel.
method exists
exists: (path: string, callback: (hasError: boolean) => void) => void;
(Client-only)
path
exists.
method ext_copy_data
ext_copy_data: ( handle: Buffer, srcOffset: number, len: number, dstHandle: Buffer, dstOffset: number, callback: Callback) => void;
(Client-only) Performs a remote file copy. If length is 0, then the server will read from srcHandle until EOF is reached.
method ext_openssh_expandPath
ext_openssh_expandPath: ( path: string, callback: (err: Error | undefined, absPath: string) => void) => void;
(Client-only, OpenSSH extension) Similar to realpath(), but supports tilde-expansion, i.e. "~", "~/..." and "~user/...". These paths are expanded using shell-like rules.
method ext_openssh_fstatvfs
ext_openssh_fstatvfs: ( handle: Buffer, callback: (err: Error | undefined, fsInfo: any) => void) => void;
(Client-only, OpenSSH extension) Performs POSIX fstatvfs(2) on open handle
handle
.
method ext_openssh_fsync
ext_openssh_fsync: ( handle: Buffer, callback: (err: Error | undefined, fsInfo: any) => void) => void;
(Client-only, OpenSSH extension) Performs POSIX fsync(3) on the open handle
handle
.
method ext_openssh_hardlink
ext_openssh_hardlink: ( targetPath: string, linkPath: string, callback: Callback) => void;
(Client-only, OpenSSH extension) Performs POSIX link(2) to create a hard link to
targetPath
atlinkPath
.
method ext_openssh_lsetstat
ext_openssh_lsetstat: { (path: string, attrs: InputAttributes, callback: Callback): void; (path: string, callback: Callback): void;};
(Client-only, OpenSSH extension) Similar to setstat(), but instead sets attributes on symlinks.
method ext_openssh_rename
ext_openssh_rename: ( srcPath: string, destPath: string, callback: Callback) => void;
(Client-only, OpenSSH extension) Performs POSIX rename(3) from
srcPath
todestPath
.
method ext_openssh_statvfs
ext_openssh_statvfs: ( path: string, callback: (err: Error | undefined, fsInfo: any) => void) => void;
(Client-only, OpenSSH extension) Performs POSIX statvfs(2) on
path
.
method fastGet
fastGet: { ( remotePath: string, localPath: string, options: TransferOptions, callback: Callback ): void; (remotePath: string, localPath: string, callback: Callback): void;};
(Client-only) Downloads a file at
remotePath
tolocalPath
using parallel reads for faster throughput.
method fastPut
fastPut: { ( localPath: string, remotePath: string, options: TransferOptions, callback: Callback ): void; (localPath: string, remotePath: string, callback: Callback): void;};
(Client-only) Uploads a file from
localPath
toremotePath
using parallel reads for faster throughput.
method fchmod
fchmod: (handle: Buffer, mode: number | string, callback: Callback) => void;
(Client-only) Sets the mode for the resource associated with
handle
.
method fchown
fchown: (handle: Buffer, uid: number, gid: number, callback: Callback) => void;
(Client-only) Sets the owner for the resource associated with
handle
.
method fsetstat
fsetstat: ( handle: Buffer, attributes: InputAttributes, callback: Callback) => void;
(Client-only) Sets the attributes defined in
attributes
for the resource associated withhandle
.
method fstat
fstat: ( handle: Buffer, callback: (err: Error | undefined, stats: Stats) => void) => void;
(Client-only) Retrieves attributes for the resource associated with
handle
.
method futimes
futimes: ( handle: Buffer, atime: number | Date, mtime: number | Date, callback: Callback) => void;
(Client-only) Sets the access time and modified time for the resource associated with
handle
.
method handle
handle: (reqId: number, handle: Buffer) => void;
Sends a handle response for the request identified by id. handle must be less than 256 bytes and is an opaque value that could merely contain the value of a backing file descriptor or some other unique, custom value.
method lstat
lstat: ( path: string, callback: (err: Error | undefined, stats: Stats) => void) => void;
(Client-only) Retrieves attributes for
path
. Ifpath
is a symlink, the link itself is stat'ed instead of the resource it refers to.
method mkdir
mkdir: { (path: string, attributes: InputAttributes, callback: Callback): void; (path: string, callback: Callback): void;};
(Client-only) Creates a new directory
path
.
method name
name: (reqId: number, names: FileEntry[]) => void;
Sends a name response for the request identified by id.
method on
on: { (event: 'ready', listener: () => void): this; ( event: 'OPEN', listener: ( reqId: number, filename: string, flags: number, attrs: Attributes ) => void ): this; ( event: 'READ', listener: ( reqId: number, handle: Buffer, offset: number, len: number ) => void ): this; ( event: 'WRITE', listener: ( reqId: number, handle: Buffer, offset: number, data: Buffer ) => void ): this; (event: 'FSTAT', listener: (reqId: number, handle: Buffer) => void): this; ( event: 'FSETSTAT', listener: (reqId: number, handle: Buffer, attrs: Attributes) => void ): this; (event: 'CLOSE', listener: (reqId: number, handle: Buffer) => void): this; (event: 'OPENDIR', listener: (reqId: number, path: string) => void): this; (event: 'READDIR', listener: (reqId: number, handle: Buffer) => void): this; (event: 'LSTAT', listener: (reqId: number, path: string) => void): this; (event: 'STAT', listener: (reqId: number, path: string) => void): this; (event: 'REMOVE', listener: (reqId: number, path: string) => void): this; (event: 'RMDIR', listener: (reqId: number, path: string) => void): this; (event: 'REALPATH', listener: (reqId: number, path: string) => void): this; (event: 'READLINK', listener: (reqId: number, path: string) => void): this; ( event: 'SETSTAT', listener: (reqId: number, path: string, attrs: Attributes) => void ): this; ( event: 'MKDIR', listener: (reqId: number, path: string, attrs: Attributes) => void ): this; ( event: 'RENAME', listener: (reqId: number, oldPath: string, newPath: string) => void ): this; ( event: 'SYMLINK', listener: (reqId: number, targetPath: string, linkPath: string) => void ): this; ( event: 'EXTENDED', listener: (reqId: number, extName: string, extData: Buffer) => void ): this; (event: string | symbol, listener: Function): this;};
Emitted after initial protocol version check has passed
method once
once: { (event: 'ready', listener: () => void): this; ( event: 'OPEN', listener: ( reqId: number, filename: string, flags: number, attrs: Attributes ) => void ): this; ( event: 'READ', listener: ( reqId: number, handle: Buffer, offset: number, len: number ) => void ): this; ( event: 'WRITE', listener: ( reqId: number, handle: Buffer, offset: number, data: Buffer ) => void ): this; (event: 'FSTAT', listener: (reqId: number, handle: Buffer) => void): this; ( event: 'FSETSTAT', listener: (reqId: number, handle: Buffer, attrs: Attributes) => void ): this; (event: 'CLOSE', listener: (reqId: number, handle: Buffer) => void): this; (event: 'OPENDIR', listener: (reqId: number, path: string) => void): this; (event: 'READDIR', listener: (reqId: number, handle: Buffer) => void): this; (event: 'LSTAT', listener: (reqId: number, path: string) => void): this; (event: 'STAT', listener: (reqId: number, path: string) => void): this; (event: 'REMOVE', listener: (reqId: number, path: string) => void): this; (event: 'RMDIR', listener: (reqId: number, path: string) => void): this; (event: 'REALPATH', listener: (reqId: number, path: string) => void): this; (event: 'READLINK', listener: (reqId: number, path: string) => void): this; ( event: 'SETSTAT', listener: (reqId: number, path: string, attrs: Attributes) => void ): this; ( event: 'MKDIR', listener: (reqId: number, path: string, attrs: Attributes) => void ): this; ( event: 'RENAME', listener: (reqId: number, oldPath: string, newPath: string) => void ): this; ( event: 'SYMLINK', listener: (reqId: number, targetPath: string, linkPath: string) => void ): this; ( event: 'EXTENDED', listener: (reqId: number, extName: string, extData: Buffer) => void ): this; (event: string | symbol, listener: Function): this;};
Emitted after initial protocol version check has passed
method open
open: { ( filename: string, mode: number | OpenMode, attributes: InputAttributes, callback: (err: Error | undefined, handle: Buffer) => void ): void; ( filename: string, mode: number | OpenMode, attributes: string | number, callback: (err: Error, handle: Buffer) => void ): void; ( filename: string, mode: number | OpenMode, callback: (err: Error, handle: Buffer) => void ): void;};
(Client-only) Opens a file
filename
formode
with optionalattributes
.(Client-only) Opens a file
filename
formode
.
method opendir
opendir: ( path: string, callback: (err: Error | undefined, handle: Buffer) => void) => void;
(Client-only) Opens a directory
path
.
method read
read: ( handle: Buffer, buffer: Buffer, offset: number, length: number, position: number, callback: ( err: Error | undefined, bytesRead: number, buffer: Buffer, position: number ) => void) => void;
(Client-only) Reads
length
bytes from the resource associated withhandle
starting atposition
and stores the bytes inbuffer
starting atoffset
.
method readdir
readdir: ( location: string | Buffer, callback: (err: Error | undefined, list: FileEntryWithStats[]) => void) => void;
(Client-only) Retrieves a directory listing.
method readFile
readFile: { ( remotePath: string, options: ReadFileOptions, callback: (err: Error | undefined, handle: Buffer) => void ): void; ( remotePath: string, encoding: BufferEncoding, callback: (err: Error, handle: Buffer) => void ): void; (remotePath: string, callback: (err: Error, handle: Buffer) => void): void;};
(Client-only) Reads a file in memory and returns its contents
method readlink
readlink: ( path: string, callback: (err: Error | undefined, target: string) => void) => void;
(Client-only) Retrieves the target for a symlink at
path
.
method realpath
realpath: ( path: string, callback: (err: Error | undefined, absPath: string) => void) => void;
(Client-only) Resolves
path
to an absolute path.
method rename
rename: (srcPath: string, destPath: string, callback: Callback) => void;
(Client-only) Renames/moves
srcPath
todestPath
.
method rmdir
rmdir: (path: string, callback: Callback) => void;
(Client-only) Removes the directory at
path
.
method setstat
setstat: (path: string, attributes: InputAttributes, callback: Callback) => void;
(Client-only) Sets the attributes defined in
attributes
forpath
.
method stat
stat: ( path: string, callback: (err: Error | undefined, stats: Stats) => void) => void;
(Client-only) Retrieves attributes for
path
.
method status
status: (reqId: number, code: number, message?: string) => void;
Sends a status response for the request identified by id.
method symlink
symlink: (targetPath: string, linkPath: string, callback: Callback) => void;
(Client-only) Creates a symlink at
linkPath
totargetPath
.
method unlink
unlink: (path: string, callback: Callback) => void;
(Client-only) Removes the file/symlink at
path
.
method utimes
utimes: ( path: string, atime: number | Date, mtime: number | Date, callback: Callback) => void;
(Client-only) Sets the access time and modified time for
path
.
method write
write: ( handle: Buffer, buffer: Buffer, offset: number, length: number, position: number, callback: Callback) => void;
(Client-only)
method writeFile
writeFile: { ( remotePath: string, data: string | Buffer, options: WriteFileOptions, callback?: Callback ): void; (remotePath: string, data: any, encoding: string, callback?: Callback): void; (remotePath: string, data: any, callback?: Callback): void;};
(Client-only) Writes data to a file
interface ShellOptions
interface ShellOptions {}
interface SignalInfo
interface SignalInfo {}
property name
name: string;
The signal name (e.g. SIGUSR1).
interface SigningRequestOptions
interface SigningRequestOptions {}
property hash
hash?: 'sha1' | 'sha256' | 'sha512';
interface SocketBindInfo
interface SocketBindInfo {}
property socketPath
socketPath: string;
The socket path to start/stop binding to.
interface SocketRequestInfo
interface SocketRequestInfo {}
property socketPath
socketPath: string;
Destination socket path of outgoing connection.
interface Stats
interface Stats extends Attributes {}
method isBlockDevice
isBlockDevice: () => boolean;
method isCharacterDevice
isCharacterDevice: () => boolean;
method isDirectory
isDirectory: () => boolean;
method isFIFO
isFIFO: () => boolean;
method isFile
isFile: () => boolean;
method isSocket
isSocket: () => boolean;
method isSymbolicLink
isSymbolicLink: () => boolean;
interface SubsystemInfo
interface SubsystemInfo {}
property name
name: string;
The name of the subsystem.
interface TcpConnectionDetails
interface TcpConnectionDetails {}
property destIP
destIP: string;
The remote IP the connection was received on (given in earlier call to
forwardIn()
).
property destPort
destPort: number;
The remote port the connection was received on (given in earlier call to
forwardIn()
).
property srcIP
srcIP: string;
The originating IP of the connection.
property srcPort
srcPort: number;
The originating port of the connection.
interface TcpipBindInfo
interface TcpipBindInfo {}
interface TcpipRequestInfo
interface TcpipRequestInfo {}
interface TerminalModes
interface TerminalModes {}
property CS7
CS7?: 0 | 1 | undefined;
7 bit mode.
property CS8
CS8?: 0 | 1 | undefined;
8 bit mode.
property ECHO
ECHO?: 0 | 1 | undefined;
Enable echoing.
property ECHOCTL
ECHOCTL?: 0 | 1 | undefined;
Echo control characters as ^(Char).
property ECHOE
ECHOE?: 0 | 1 | undefined;
Visually erase chars.
property ECHOK
ECHOK?: 0 | 1 | undefined;
Kill character discards current line.
property ECHOKE
ECHOKE?: 0 | 1 | undefined;
Visual erase for line kill.
property ECHONL
ECHONL?: 0 | 1 | undefined;
Echo NL even if ECHO is off.
property ICANON
ICANON?: 0 | 1 | undefined;
Canonicalize input lines.
property ICRNL
ICRNL?: 0 | 1 | undefined;
Map CR to NL on input.
property IEXTEN
IEXTEN?: 0 | 1 | undefined;
Enable extensions.
property IGNCR
IGNCR?: 0 | 1 | undefined;
Ignore CR on input.
property IGNPAR
IGNPAR?: 0 | 1 | undefined;
The ignore parity flag. The parameter SHOULD be
0
if this flag is FALSE, and1
if it is TRUE.
property IMAXBEL
IMAXBEL?: 0 | 1 | undefined;
Ring bell on input queue full.
property INLCR
INLCR?: 0 | 1 | undefined;
Map NL into CR on input.
property INPCK
INPCK?: 0 | 1 | undefined;
Enable checking of parity errors.
property ISIG
ISIG?: 0 | 1 | undefined;
Enable signals INTR, QUIT, [D]SUSP.
property ISTRIP
ISTRIP?: 0 | 1 | undefined;
Strip 8th bit off characters.
property IUCLC
IUCLC?: 0 | 1 | undefined;
Translate uppercase characters to lowercase.
property IXANY
IXANY?: 0 | 1 | undefined;
Any char will restart after stop.
property IXOFF
IXOFF?: 0 | 1 | undefined;
Enable input flow control.
property IXON
IXON?: 0 | 1 | undefined;
Enable output flow control.
property NOFLSH
NOFLSH?: 0 | 1 | undefined;
Don't flush after interrupt.
property OCRNL
OCRNL?: 0 | 1 | undefined;
Translate carriage return to newline (output).
property OLCUC
OLCUC?: 0 | 1 | undefined;
Convert lowercase to uppercase.
property ONLCR
ONLCR?: 0 | 1 | undefined;
Map NL to CR-NL.
property ONLRET
ONLRET?: 0 | 1 | undefined;
Newline performs a carriage return (output).
property ONOCR
ONOCR?: 0 | 1 | undefined;
Translate newline to carriage return-newline (output).
property OPOST
OPOST?: 0 | 1 | undefined;
Enable output processing.
property PARENB
PARENB?: 0 | 1 | undefined;
Parity enable.
property PARMRK
PARMRK?: 0 | 1 | undefined;
Mark parity and framing errors.
property PARODD
PARODD?: 0 | 1 | undefined;
Odd parity, else even.
property PENDIN
PENDIN?: 0 | 1 | undefined;
Retype pending input.
property TOSTOP
TOSTOP?: 0 | 1 | undefined;
Stop background jobs from output.
property TTY_OP_ISPEED
TTY_OP_ISPEED?: number | undefined;
Specifies the input baud rate in bits per second.
property TTY_OP_OSPEED
TTY_OP_OSPEED?: number | undefined;
Specifies the output baud rate in bits per second.
property VDISCARD
VDISCARD?: number | undefined;
Toggles the flushing of terminal output.
property VDSUSP
VDSUSP?: number | undefined;
Another suspend character.
property VEOF
VEOF?: number | undefined;
End-of-file character (sends
EOF
from the terminal).
property VEOL
VEOL?: number | undefined;
End-of-line character in addition to carriage return and/or linefeed.
property VEOL2
VEOL2?: number | undefined;
Additional end-of-line character.
property VERASE
VERASE?: number | undefined;
Erase the character to left of the cursor.
property VFLUSH
VFLUSH?: number | undefined;
Character to flush output.
property VINTR
VINTR?: number | undefined;
Interrupt character;
255
if none. Not all of these characters are supported on all systems.
property VKILL
VKILL?: number | undefined;
Kill the current input line.
property VLNEXT
VLNEXT?: number | undefined;
Enter the next character typed literally, even if it is a special character
property VQUIT
VQUIT?: number | undefined;
The quit character (sends
SIGQUIT
signal on POSIX systems).
property VREPRINT
VREPRINT?: number | undefined;
Reprints the current input line.
property VSTART
VSTART?: number | undefined;
Continues paused output (normally control-Q).
property VSTATUS
VSTATUS?: number | undefined;
Prints system status line (load, command, pid, etc).
property VSTOP
VSTOP?: number | undefined;
Pauses output (normally control-S).
property VSUSP
VSUSP?: number | undefined;
Suspends the current program.
property VSWTCH
VSWTCH?: number | undefined;
Switch to a different shell layer.
property VWERASE
VWERASE?: number | undefined;
Erases a word left of cursor.
property XCASE
XCASE?: 0 | 1 | undefined;
Enable input and output of uppercase characters by preceding their lowercase equivalents with
\
.
interface TransferOptions
interface TransferOptions {}