The shell 'node -ssh' does not seem to provide an end function or a way to access the base ssh2 connection object. This leaves you with a couple of options:
Paste, write the end method and issue a request to migrate to the node -ssh shell so that future users can use the shell and terminate the connections. In addition, you can create an issue and wait for someone else to create this function if / when they consider it necessary.
Use the ssh2 core library instead . It provides you with many more features, including the end method, to close the connection, but uses callbacks instead of promises, which will require reorganization of your code.
In addition, you can add the following to your code, but it is very strongly not recommended , since it is messing with a prototype that you do not have, and can ruin compatibility with future versions of node -ssh:
driver.prototype.end = function() { this.Connection.end() this.Connected = false }
you can call ssh.end() to close the connection.
source share