Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

412
Visualizações
Connect to remote MSSQL server with PHP through SSH tunnel

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:enter image description here

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.

PuTTY Tunnels configuration

I'm getting this PHP error on the Ubuntu machine:

Warning: mssql_connect(): Unable to connect to server: localhost,1433 

EDIT:

Also tried this:

enter image description here

And this:

[![Remote IPv4 with IP address specified in MS SQL server][5]][5]

FINALLY, I have solved it. See my answer.

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

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.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda