Knowledgebase Home | Glossary | Favorites Knowledgebase Home | Glossary | Favorites
SSH Tunneling
Article Details

Last Updated
11th of August, 2010

User Opinions (0 votes)
No users have voted.

How would you rate this answer?
Helpful
Not helpful
SSH tunneling is a method of securely tunneling TCP ports through SSH. On Stackable, SSH tunneling can be used between a workstation and a container to provide a secure connection to services such as MySQL.

Table of Contents


Basics of SSH Tunneling

An SSH tunnel works by forwarding a TCP port on a workstation to another TCP port on a server. When forwarding, some information is needed when performing a basic SSH tunnel:
  • local port: the local port that will be forwarded (this can be any open port but it should be one that is not used by something else)
  • host server: the server that you are connecting to remotely and securely
  • host port: the port where the desired service is running on the host server (for example, MySQL runs by default on port 3306)
  • SSH server: the SSH server that will facilitate the tunnel
  • SSH server credentials: the credentials required to connect to the SSH server that will facilitate the tunnel

A Simple Tunnel

Once this information is obtained the following command can be used to create a tunnel:
ssh user@ssh.server -L local_port:host.server:host_port
With actual information:
$ ssh demo@199.104.126.75 -L 3307:db1.slc1.stackable.com:3306
This command forwards port 3307 on the local machine to db1.slc1.stackable.com using port 3306 using the remote SSH server at 199.104.126.75


Using With MySQL

A common use for SSH tunneling is creating a secure connection to a MySQL server. Since Stackable containers and database servers are on a secure internal network, an SSH tunnel can be used on any workstation to create a secure connection to the database server:

First create the tunnel:
$ ssh demo@199.104.126.75 -L 3307:db1.slc1.stackable.com:3306
Now we use MySQL from the command line as usual except we need to tell it to use port 3307 and IP address localhost for the host:
$ mysql -h localhost -P 3307 -u db_9uq0ks0 -p 
These commands connect to the MySQL server db1.slc1.stackable.com from the container located at 199.104.126.75 and then tunnel that connection to the workstation on port 3307.
Visitor Comments
  1. Comment #1 (Posted by Stone)
    Hey, that's the greteast! So with ll this brain power AWHFY?
Post Comment for "SSH Tunneling"
To post a comment for this article, simply complete the form below. Fields marked with an asterisk are required.
   Your Name:
* Your Comment:
* Enter the code below:
 
Related Articles
No related articles were found.
Attachments
No attachments were found.

Continue