Hello Everyone, 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 No matter which variation I have tried, in every case, it will actually create an ssh connection to the hostB, and log me into hostB, giving me its prompt. If I try the port (22222) for the localhost (hostA) in another terminal window, it doesn't allow the connection. netstat also doesn't show port 22222 to be opened on the local machine (hostA). I have turned on AllowTcpForwarding on both the remote machine and the local machine. I have also made sure that port 22222 is opened on both machine firewalls (including the EC2 security group). What am I doing incorrectly or missing? -- Doug Registered Linux User #285548 (http://counter.li.org) ---------------------------------------- Never trust a computer you can't throw out a window. -- Steve Wozniak
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 at hostB >from hostA: ssh -L 22222:localhost:3306 user at hostB >from hostA: ssh -L 22222:hostB:3306 user at localhostOn HostA run the following within a screen session; ssh user at hostB -L 22222:127.0.0.1:3306 Hope this helps. regards Tim Tim D'Cruz
________________________________ From: Ski Dawg <centos at skidawg.org> To: CentOS mailing list <centos at centos.org> Sent: Thursday, July 12, 2012 10:20 AM Subject: [CentOS] ssh port forwarding 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 -- Doug = Doug: ? Depending on how the mysql is bound on hostB, either variation 1 or 2 should work. Variation 3 doesn't look very useful, since it implies hostA can already access tcp/3306 on hostB. ? After you build the port forwards, and open another terminal on HostA, and do: $ telnet localhost 22222 What does it do? Also, just to verify, if you're on hostB and do: $ telnet localhost 3306 Does it 'connect' to a tcp port?
On Thu, Jul 12, 2012 at 12:20 PM, Reindl Harald <h.reindl at thelounge.net>wrote:> > > Am 12.07.2012 20:15, schrieb Ski Dawg: > > 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) > > learn mysql-basics! > > localhost is ALWAYS unix-socket > the error message is really clear! > > use 127.0.0.1 if you want to use TCP which is what happens > with port-forwarding! > >Thanks. This worked. I have not ever run across this issue before, so I didn't know that using localhost tied mysql to only a socket connection, but now I do.