////How Do I Tunnel Into A Remote Database Using SSH?
How Do I Tunnel Into A Remote Database Using SSH? 2018-09-17T18:59:32+00:00

How Do I Tunnel Into a Remote Database Using SSH?

A common question is “How do I connect to a database running on Amazon (or Azure) from my local laptop?” The answer often is:

  • Create an SSH tunnel that will allow you to treat the remote database as if it was local.


We have an instance of MySQL running on an Amazon EC2 instance and want to access it from our local network. Technically what we want to do is:

  • Pretend that there is a MySQL instance listening on port 3307 on our local network.
  • Have magic forward all communication on localhost port 3307 to a MySQL instance living on Amazon EC2.

The secret sauce requires setting up a forwarding port using ssh. Example:

ssh -L 3307: ec2_user@capstormlabs.com

This statement will open a terminal prompt on capstormlabs.com and a tunnel listening on that forwards traffic on local port 3307 to port 3306 (e.g. MySQL) on capstormlabs.com. With any CopyStorm product the remote MySQL instance can be reference with a connection string like:


If you are hungry for more information then see this article for all the details.


Product Questions: info@capstorm.com
Technical Support: support@capstorm.com
Phone: +1 314.403.2143