SQL Server under SSH Tunnel With PuTTY
1 min read

SQL Server under SSH Tunnel With PuTTY

You just prepared your Linux VPS at Digital Ocean or anywhere, installed your SQLServer on Linux ... Everything is beautiful ... What now? You will open the door 1433 to the world (after all, you want to manage your databases in SSMS), right? Do not do it! Never!
SQL Server under SSH Tunnel With PuTTY

First of all, I assume you're already familiar with SSH and use PuTTy to open SSH connections from Windows. If you haven't come across Putty yet, then take a look at https://www.putty.org/

Right now, I supose you have a putty connection configured and you can connect to your server over SSH with a private key with no problems...

Port Forwarding on PuTTY

On my developer station (local IP 192.168.0.53), I just have a SqlServer installed and have been using the port 1433. So, I'll use another port (I'll be using 1434 below as an example). Now, we need to configure PuTTY to forward traffic from the local port  1434  to port 1433 on the database server.

Navigate to Connection -> SSH -> Tunnels and enter the settings:

  • Source: 1433
  • Destination port: 192.168.0.53:1434 (your internal IP Address)
  • Type: Local
  • And click "Add"

Save your session and leave it open. Now, configure your connection string application, use a Management Studio, Azure Data Studio or whichever database you wish...

PS: If you are using a not Default SQLServer port, use this example 👆(ip comma port) and be happy.