Runtime Labs
Home Products Store Downloads Support Blog About Us

Support

Using an SSH Tunnel to connect to a 3rd Party Database

This document describes how to set up an SSH tunnel to use with MacSQL. This resolves an issue with users failing to connect to 3rd party database hosts that do not allow remote connections to their database server.

Complete the following steps to connect to a database server via an SSH tunnel:

  1. Open the Terminal application (located in /Applications/Utilities).
  2. At the command line enter the following:

    $ ssh -L port1:127.0.0.1:port2 username@remotehost.com

    Where port1 is the port you wish to open on your machine (any number between 1025 and 64000) and port2 is the port on the remote server for the database. For example MySQL's default port is 3306. If you are not running a database server on your local machine you can use the same number for both ports.
  3. If prompted, enter the password associated with the username you used to connect to the ssh server.
  4. Leave this Terminal window open until you are finished with the database connection you will open below.
  5. Open MacSQL and select "New..." from the File menu. Choose the database type you wish to connect to.
  6. In the Host box, enter: 127.0.0.1
  7. In the Port box, enter the port number you entered for port1.
  8. Enter the database userid and password.
  9. Press the Connect button.

This will open a connection to the remote server via the ssh tunnel you have open in Terminal. Your service provider will see you connected to the database via their ssh server as if you were using a command-line tool.


©2007 Runtime Labs, Inc.    Contact us | Privacy Policy | Refund Policy | PGP Key
Home