Reputation: 11268
I am getting this error while trying to open a tunnel with ssh2 in a nodeJS app.
Error: Cannot parse privateKey: Unsupported key format
I followed the steps from this thread and I've converted my existing key from openSSH to the RSA format and confirmed in the key headers that has indeed been converted. However, when I try opening my connection I still get the error.
This is my code
function SSHConnection() {
return new Promise((resolve, reject) => {
sshClient.on('ready', () => {
sshClient.forwardOut(
forwardConfig.srcHost,
forwardConfig.srcPort,
forwardConfig.dstHost,
forwardConfig.dstPort,
(err, stream) => {
if (err) reject(err);
// create a new DB server object including stream
const updatedDbServer = {
...dbServer,
stream
};
// connect to mysql
const connection = mysql.createConnection(updatedDbServer);
// check for successful connection
// resolve or reject the Promise accordingly
connection.connect((error) => {
if (error) {
reject(error);
}
resolve(connection);
});
});
}).connect(tunnelConfig);
});
}
Upvotes: 0
Views: 133