[CentOS] ssh port forwarding

Thu Jul 12 18:22:47 UTC 2012
m.roth at 5-cent.us <m.roth at 5-cent.us>

Ski Dawg wrote:
> On Thu, Jul 12, 2012 at 11:30 AM, We Are Here <support at wearehere.net>
> wrote:
>> At 18:20 12/07/2012, you wrote:
>
>> >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 at hostB
>> >from hostA: ssh -L 22222:localhost:3306 user at hostB
>> >from hostA: ssh -L 22222:hostB:3306 user at localhost
>> On HostA run the following within a screen session;
>>
>> ssh user at hostB -L 22222:127.0.0.1:3306
>
> 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.
<snip>
Ah! What's your iptables look like? Is that opened to come in?

        mark