When using the node-mysql npm package, is it possible to connect to the MySQL server using a SSH key instead of a password?
解决方案
I got this exact system working today and it should have taken 10 minutes but I wasted 5 hours on a dumb bug I wrote (which was a direct result of me trying too hard to do it in 5 minutes).
You can do the SSH tunnel component completely independently, and then point node-mysql (or any other sql client...) to your DB by using TCP tunneled over SSH.
Just set up your SSH tunnel like this
ssh -N -p 22 sqluser@remoteserverrunningmysql.your.net -L 33306:localhost:3306
Leave that going in the background (see articles like this for more in depth info).
Then just send any MySQL client to port 33306 on localhost. It will actually connect as though you are on your remote server and using port 3306.