'Forward SQL Server ODBC over SSH via putty

I would like to access a Azure SQL database. It is accessible on port 1433. However, the firewall is blocking this request. Therefore, I wold like to tunnel my connection.

Setup
The client is running on Windows 10. I can connect to a remote linux server. This server runs at home and when I'm at home, I am able to access the SQL database. So I assume my linux server is also able to connect to the Azure database.

Tunnel request?
I want to access the database via an ODBC connection. So, I tried to tunnel the connection using putty:

  1. Putty connects to linux server and tunnels localhost:2433 to server-url:1433
  2. Client connects to localhost:2433
  3. Client has access to database

However, this is not working.

What goes wrong?
I am able to connect using putty to linux server. I have setup a tunnel inside putty at the Connection > SSH > Tunnels page:
Source port: 2433
Destination: server-url:1433
I have set the radio buttons to Local and auto.

What goes wrong here? I don't know how I can investigate this properly. Maybe there is a problem at my linux server, that it can't connect to Azure SQL. But I think my tunnel is not working correctly. Can you help?



Solution 1:[1]

I didn't get it to work with putty, but if you have access to a shell you can use

ssh -L <local_port>:localhost:<remote_port> user@server -i "path to your private key file if you need one for authentification"

So in your specific example it would be

ssh -L 2433:localhost:1433 user@server-url

I used this to create an ODBC connection from RStudio (you can use the built in terminal to establish the tunneling) to a postgres db running in a docker container on azure.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 chillwalker