Stratus Guides - SSH Tunnels

To use a local MySQL manager or other application to connect to a database on Webscale STRATUS, an SSH tunnel is preferred. SSH tunnels are possible with a variety of clients. Putty and OpenSSH are used in the following examples.

Before you can connect, you need several pieces of information:

  • A working SSH login to your Webscale STRATUS environment.
  • The IP address that will connect to the Webscale STRATUS MySQL (i.e., the same IP allowed for SSH access)
  • Your database credentials. In your Webscale STRATUS management panel, expand the MySQL section and click Info to see your database username and password

If you have the above, you can proceed.

Creating a Tunnel with PuTTY

  1. Open PuTTy on your computer.

putty-92

  1. Enter the SSH Host address shown SSH > Info.

  2. From the left-hand tree in PuTTY, go to Connection > SSH > Tunnels.

  • Source PortEnter “3306”. If MySQL is locally using this port, enter another port number (e.g. “3307”).
  • DestinationEnter myqsl with a port of “3306” (mysql:3306) This is the mysql hostname and port used by your Stratus environment.
  • Click Add.

putty tunnel-42

  1. Click Open. Accept the SSH if requested.
  2. Log in with the STRATUS SSH User credentials.

The SSH tunnel to the remote database is now open. Connect locally using a MySQL client application. Use an IP of 127.0.0.1 and port number of 3306.

Creating a Tunnel with OpenSSH

A secure tunnel to the Webscale STRATUS database can be created using one command line:

ssh -p <SSHport> -L <localport>:mysql:3306 <SSHuser>@<SSHhost>
  • SSHport — Use the SSH Port found in your SSH Info panel.
  • localport — Normally “3306”, the local port used to access MySQL. If an instance of MySQL is already running locally, an alternative port may be used, such as “3307”.
  • SSHuser — STRATUS SSH Username.
  • SSHhost — Found in the STRATUS SSH Info panel.

Using this format, a typical OpenSSH tunnel might be created using:

ssh -p 21937 -L 3306:mysql:3306 developer_joe@ssh.5uiwe1x3ngdgg75c.mojostratus.io

After entering this into the terminal window, enter the STRATUS SSH user password.

putty tunnel-42

While this tunnel connection is open, open a new terminal window and connect to the Webscale STRATUS MySQL database as if it were local.

SSH tunnels between Webscale STRATUS environments

SSH tunnels have become common between Webscale STRATUS environments for the purpose of Magento1->Magento2 data migrations. A tunnel between environments is very similar to creating a tunnel with OpenSSH, except for the following:

  • Instead of SSH hostname, you must use the external IP address of the SSH host instead. For example, in the example above, for ssh.5uiwe1x3ngdgg75c.mojostratus.io, you would use the IP 3.231.50.120 instead.

putty tunnel-42

You can obtain the outgoing/SSH IP of the environment you are on via ssh with the command _curl http://ipcheck.com/_

Below is a full example of the steps needed to create an SSH tunnel between 2 environments (M1 and M2)

  • Create a new SSH user on the M1 environment, allow the public SSH key & white-list the IP from the M2 environment. (curl http://ipcheck.com/)

  • Create a screen on the M2 environment: screen -S tunnel

  • Run the following in the screen to open the tunnel to the M1 environment:

ssh -p <PORT> -L 3307:mysql:3306 <USER>@<IP OF M1>

Example:

ssh -p 22000 -L 3307:mysql:3306 transfer@34.236.255.11
  • Hit Ctrl-A-D on PC to disconnect from the screen without exiting the tunnel

You can now access both databases on the M2 environment:

Example:

Local m2 database: mysql -u user_abcdefghijk -p db_abcdefghijk
Remote m1 database: mysql -u user_zyxwvutsrq -p -P 3307 db_zyxwvutsrq

If the M2 environment is rebooted, you will need to recreate the tunnel starting at step 2 above.


Last modified January 1, 0001