2

I'm creating a server application that clients will connect to. The server application is running on an Ubuntu Server 14.04.1 VPS. The server needs to be able to connect to a MySQL database hosted on a web server. This should be easy to do normally, but my web host, Namecheap, requires an SSH tunnel instead of directly connecting to a database externally.

If the server was running on Windows, I'm able to set up a simple tunnel with PuTTY to the webserver, but I am unsure on how to do this on a linux system.

It's hard to find information on this, because whatever I look up assumes I'm trying to create a tunnel from a personal Windows computer to a Linux VPS. How can I create a tunnel to a database as described in this link on Ubuntu Server rather than Windows, which has GUI tools like PuTTY that make it easier? (I'm very new to the Linux world)

The tunnel I created in PuTTY (When testing on Windows) looks like: L3306 127.0.0.1:3306

1 Answer 1

1

I realized the solution was much simpler than I expected, simply create an SSH tunnel like so:

ssh -f -p port username@ip -L 3306:ip:3306 -N

Where port is the port of the web server, and ip is the IP address of it.

I'm working on using AutoSSH to keep a persistent connection.

1
  • This will likely work but seems like a giant kludge. You might want to look at setting up an actual VPN.
    – slm
    Commented Oct 5, 2014 at 1:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .