3

I'm using SSH tunneling for the first time, so I'm trying to understand how to configure it.

I've got a remote Linux server that hosts a MySQL database that I'm trying to connect to. In order to access the MySQL database directly through a software that only recognizes local databases, I suppose SSH tunneling would be the right way to set up the access, correct?

Now, I'm trying to set up the tunneling on my 'home' computer which is running the software that's trying to access the MySQL database. My first question is whether this is reverse tunneling or normal tunneling? Secondly, is it local tunneling or remote tunneling?

Finally, from what I understand, my code is supposed to look something like

ssh -L 8080:mylinuxserver.mycompany.com:22 myuser@mylinuxserver.mycompany.com

Is this correct? Is my source port '22' since I'm using SSH and is my destination port 8080 (or is there something more appropriate)?

When I try to use the above code, I am able to login using my passphrase (since my key is already in the MyLinuxServer) but when I ping localhost:8080, it cannot find the host.

What am I doing wrong?

Dezzie
  • 934
  • 3
  • 18
  • 35

2 Answers2

8

I've got a remote Linux server that hosts a MySQL database that I'm trying to connect to

The command should be:

ssh -L 8080:localhost:3306 myuser@mylinuxserver.mycompany.com

Where:

  1. 8080: is hte local port on your workstation
  2. localhost: is corresponding to mylinuxserver.mycompany.com
  3. 3306: the MySQL port on above localhost.

then connect (from your workstation) to MySQL as:

mysql -h 127.0.0.1 --port=8080 

Besides, ping localhost:8080 is wrong. Ping cannot work that way.

slayedbylucifer
  • 22,878
  • 16
  • 94
  • 123
-2

Try this:

ssh -f ssh_user@mylinuxserver.mycompany.com -L 3307:mysql1.example.com:3306 -N

Next, to access the mysql your trying to connect to:

mysql -h 127.0.0.1 -P 3307
Garrett Hyde
  • 5,409
  • 8
  • 49
  • 55
martinezjc
  • 3,415
  • 3
  • 21
  • 29
  • It executed correctly but I still can't successfully ping it because it can't find the host. Same issue as I had with the code I've put in my question. – Dezzie Mar 25 '14 at 15:48
  • When I try to run the mysql command, it shows that the command was not found. – Dezzie Mar 25 '14 at 15:56