Reputation: 9476
Firewalled MS SQL server wants to supply data to Ubuntu server on the internet.
So I establish an SSH tunnel from the MS SQL server to Ubuntu server, asking Ubuntu to send its port 1433
traffic to MS SQL's port 1433
.
According to this Stack Overflow answer, I think I should be doing this on the MS SQL server:
ssh -R 1433:localhost:1433 ubuntu.example.com
It's a Windows machine, so I did this in PuTTY:
In the local network, I've tested using PHP to connect to the SQL server and it works.
$server = '192.168.0.12';
$user = 'buttle';
$pass = '1234';
mssql_connect($server,$user,$pass);
Now I want to try connecting the same two machines using an SSH tunnel instead of "direct" connection. So I change $server to this:
$server = 'localhost,1433';
And then I connect an SSH tunnel from the SQL Server machine to the Ubuntu machine with PuTTy. And perhaps this is where I'm going wrong, because I don't know what I'm doing.
I'm getting this PHP error on the Ubuntu machine:
Warning: mssql_connect(): Unable to connect to server: localhost,1433
EDIT:
Also tried this:
And this:
[![Remote IPv4 with IP address specified in MS SQL server][5]][5]
FINALLY, I have solved it. See my answer.
Upvotes: 1
Views: 1447
Reputation: 9476
All of the online tutorials for using PHP's mssql
functions assume you are running PHP in a Windows environment. Apparently, in Windows, IP and Port Number are separated by a comma, but in Linux by a colon.
// Linux running PHP
$server = 'localhost:1433';
// Windows running PHP
$server = 'localhost,1433';
As usual, hours of problems boil down to a single byte.
Upvotes: 2