Stratus Guides - SSH Tunnels
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
- Open PuTTy on your computer.
Enter the SSH Host address shown SSH > Info.
From the left-hand tree in PuTTY, go to Connection > SSH > Tunnels.
- Source Port — Enter “3306”. If MySQL is locally using this port, enter another port number (e.g. “3307”).
- Destination — Enter myqsl with a port of “3306” (mysql:3306) This is the mysql hostname and port used by your Stratus environment.
- Click Add.
- Click Open. Accept the SSH if requested.
- 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 email@example.com
After entering this into the terminal window, enter the STRATUS SSH user password.
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 188.8.131.52 instead.
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>
ssh -p 22000 -L 3307:mysql:3306 firstname.lastname@example.org
- 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:
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.
Was this page helpful?
Glad to hear it! Have any more feedback? Please share it here.
Sorry to hear that. Have any more feedback? Please share it here.