Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- Stephan Carydakis
February 25, 2007, 4:26 pm
rate this thread
I am experiencing differing results using "ssh -R 3306:shiraz:3306
127.0.0.1" and " ssh -R 3306:shiraz:3306 localhost". If I use the IP in
port forwading, I can successfully connect to the destination MySql server
by using "localhost" or 127.0.0.1 in my connection. If I establish the port
forward using "localhost", I can only connect by using the IP address (this
is no good to me for reasons I will explain!). I've tried both the command
line mysql client and an PHP and both behave the same.
I really need to be able to use "localhost" in my connection because I have
inherited some code for a small extranet that happens to have a connection
string in about 45 different PHP files and each connection specifies
"localhost". I am trying to establish a development environment for this
extranet. I am running PHP on a Debian box but do not have a local MySql
server. I have a MySql server on Win2k machine and this is the way it must
stay. My idea is to forward local port 3306 to my Win2k's port 3306.
I do plan to fix the code so the connection string is located in just 1
file, making changes back and forth a non-issue. For now, I have to play the
hand I've been dealt. Besides, I like the idea of being able to have a
permanent forward from my Linux box to my MySql server on the Win2k machine.
I've checked that localhost resolves to 127.0.0.1. When adding the forward
using "localhost", netstat shows 127.0.0.1:3306 as listening. So is this an
SSH issue, or OS related. If it's not an SSH problem, I apologise.
Re: Port forwarding - different results between using "127.0.0.1" and "localhost"
I use 127.0.0.1 because some time in the past I experienced this same
problem where localhost was not reliable. I haven't seen the issue
resurface ever since.
Search and replace in 45 files, no problem:
cp *.php /tmp/foo
perl -pi -w -e 's/localhost/127\.0\.0\.1/g;' *.php
I didn't rigorously test this, so be sure you're working in the tmp
directory with a copy of your php code. :-)
- Stephan Carydakis
February 26, 2007, 4:28 pm
- » ssh on command line: force using a group size (prime size) of 1024 (and no...
- — Newest thread in » Secure Shell Forum