Skip to content

Interface: ConnectOptions ​

Options for connect: every ssh2 connect option plus the ones node-scp adds.

Extends ​

  • ConnectConfig

Properties ​

PropertyTypeDescriptionInherited from
agent?| string | BaseAgent<string | Buffer<ArrayBufferLike> | ParsedKey>Path to ssh-agent's UNIX socket for ssh-agent-based user authentication (or 'pageant' when using Pagent on Windows).ConnectConfig.agent
agentForward?booleanSet to true to use OpenSSH agent forwarding (auth-agent@openssh.com) for the life of the connection.ConnectConfig.agentForward
algorithms?AlgorithmsExplicit overrides for the default transport layer algorithms used for the connection.ConnectConfig.algorithms
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.ConnectConfig.authHandler
beforeConnect?(ssh) => voidCalled with the underlying ssh2 client before connecting. Use it to attach listeners that must exist before authentication, for example keyboard-interactive or banner.-
debug?DebugFunctionA function that receives a single string argument to get detailed (local) debug information.ConnectConfig.debug
forceIPv4?booleanOnly connect via resolved IPv4 address for host.ConnectConfig.forceIPv4
forceIPv6?booleanOnly connect via resolved IPv6 address for host.ConnectConfig.forceIPv6
host?stringHostname or IP address of the server.ConnectConfig.host
hostHash?stringThe host's key is hashed using this method and passed to hostVerifier.ConnectConfig.hostHash
hostVerifier?| HostVerifier | SyncHostVerifier | HostFingerprintVerifier | SyncHostFingerprintVerifierVerifies a hexadecimal hash of the host's key.ConnectConfig.hostVerifier
ident?string | Buffer<ArrayBufferLike>A custom server software name/version identifier. Default: 'ssh2js' + moduleVersion + 'srv'ConnectConfig.ident
keepaliveCountMax?numberHow many consecutive, unanswered SSH-level keepalive packets that can be sent to the server before disconnection.ConnectConfig.keepaliveCountMax
keepaliveInterval?numberHow often (in milliseconds) to send SSH-level keepalive packets to the server. Set to 0 to disable.ConnectConfig.keepaliveInterval
localAddress?stringIP address of the network interface to use to connect to the server. Default: (none -- determined by OS)ConnectConfig.localAddress
localHostname?stringAlong with localUsername and privateKey, set this to a non-empty string for hostbased user authentication.ConnectConfig.localHostname
localPort?numberThe local port number to connect from. Default: (none -- determined by OS)ConnectConfig.localPort
localUsername?stringAlong with localHostname and privateKey, set this to a non-empty string for hostbased user authentication.ConnectConfig.localUsername
noDelay?booleanDisables Nagle's algorithm on the TCP socket. SCP and SFTP wait for a reply after small messages, so leaving Nagle on makes many small files up to 25 times slower. Defaults to true.-
passphrase?string | Buffer<ArrayBufferLike>For an encrypted private key, this is the passphrase used to decrypt it.ConnectConfig.passphrase
password?stringPassword for password-based user authentication.ConnectConfig.password
port?numberPort number of the server.ConnectConfig.port
privateKey?string | Buffer<ArrayBufferLike>Buffer or string that contains a private key for either key-based or hostbased user authentication (OpenSSH format).ConnectConfig.privateKey
protocol?ProtocolTransfer protocol. Defaults to auto.-
readyTimeout?number* How long (in milliseconds) to wait for the SSH handshake to complete.ConnectConfig.readyTimeout
remoteOs?RemoteOsPath flavour and shell quoting rules of the remote host. Defaults to posix.-
scpCommand?stringRemote command used for SCP transfers. Defaults to scp.-
signal?AbortSignalAborts the connection attempt.-
sock?ReadableA ReadableStream to use for communicating with the server instead of creating and using a new TCP connection (useful for connection hopping).ConnectConfig.sock
strictVendor?booleanPerforms a strict server vendor check before sending vendor-specific requests.ConnectConfig.strictVendor
timeout?numberThe underlying socket timeout in ms. Default: none)ConnectConfig.timeout
tryKeyboard?booleanTry keyboard-interactive user authentication if primary user authentication method fails.ConnectConfig.tryKeyboard
username?stringUsername for authentication.ConnectConfig.username

Released under the MIT License.