Re: ssh port forwarding

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



On Thu, Jul 12, 2012 at 11:30 AM, We Are Here <support@xxxxxxxxxxxxx> wrote:

> At 18:20 12/07/2012, you wrote:
>
> Hi Doug,
>
> >I am having a problem with setting up port forwarding from one of our
> local
> >CentOS machines to an AWS EC2 instance. We are wanting to make mysql
> >connections over an ssh tunnel.
> >
> >In this case, lets say that hostA is our local machine, and hostB is the
> >Amazon EC2 instance. I have tried several different variations (that I
> have
> >found from google searching), including:
> >from hostA: ssh -L 22222:hostB:3306 user@hostB
> >from hostA: ssh -L 22222:localhost:3306 user@hostB
> >from hostA: ssh -L 22222:hostB:3306 user@localhost
> On HostA run the following within a screen session;
>
> ssh user@hostB -L 22222:127.0.0.1:3306


Thanks for the feedback Tim.

Using your string, I can now telnet to port 22222 on localhost (hostA) and
I get the mysql connection string (from hostB), but it is not able to make
a mysql connection (using mysql -u user -p -h localhost --port=22222 from
hostA), with a test user that I set up to allow connections from anywhere.
The error that I am getting is:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket
'/var/lib/mysql/mysql.sock' (2)

I did test and the mysql test user that I created is able to connect from
hostB.

Why I can telnet to the port and get to mysql on hostB, but I can't create
the mysql connection to that port?

Also, when I do this, it still opens up an ssh session, logging me into the
remote machine, thus making it so I can't use this terminal.

The eventual goal is to do this in a script, that will open the connection,
use it for the duration of the script, and then close it when the script
finishes, but it looks like that won't work, since it is logging me into
the remote machine. I guess I could get around that by always leaving the
screen session going with the connection, but I would prefer only creating
the connection when I need it.

Any ideas how to do this without leaving the connection open all the time?
--
Doug

Registered Linux User #285548 (http://counter.li.org)
----------------------------------------
Never trust a computer you can't throw out a window.
 -- Steve Wozniak
_______________________________________________
CentOS mailing list
CentOS@xxxxxxxxxx
http://lists.centos.org/mailman/listinfo/centos


[Index of Archives]     [CentOS]     [CentOS Announce]     [CentOS Development]     [CentOS ARM Devel]     [CentOS Docs]     [CentOS Virtualization]     [Carrier Grade Linux]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Linux USB]
  Powered by Linux