mysql-ssh2 v1.0.1 provides a MySQL connection established through an SSH tunnel, extending the original mysql-ssh package. Unlike its predecessor, it allows specifying a remote database host in the connection config rather than forcing localhost, thus avoiding MySQL access denial issues. The package is minimal, depending only on mysql2 and ssh2, and is suitable for reaching databases that are only accessible via an SSH gateway. It uses Promises and requires manual closing of the tunnel. Release cadence is unknown; the package appears to be in maintenance mode.
npm install mysql-ssh2No compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates establishing an SSH tunnel to a remote host and connecting to a MySQL database through that tunnel, running a query, and closing the connection.
Always call mysqlssh.close() in a finally block or after query completion.
Use CommonJS require() instead.
Set dbConfig.host to the remote database hostname or IP.
Consider alternatives like ssh-tunnel or direct SSH port forwarding with mysql2.
Run 'npm install mysql-ssh2' (note the package name is mysql-ssh2, not mysql-ssh) and use require('mysql-ssh2').Set dbConfig.host to the actual remote database hostname.
Ensure the private key file path is correct and the passphrase (if any) is provided in sshConfig.passphrase.