Category / Section
How to connect a database through SSH tunneling?
Published:
Access database behind the firewall – SSH tunneling
Follow the steps below to connect Bold BI to your database behind a firewall by setting up an SSH tunnel.This article uses an OpenSSH server and PuTTY client on a Windows machine to help you set up an SSH tunnel. Find the list of clients available for SSH that you can use to establish SSH tunneling, https://www.ssh.com/ssh/client.
‘Password’ authentication is used here for a simplified approach. To set up ‘Public Key’ authentication, refer to https://www.ssh.com/ssh/public-key-authentication.
Configure SSH server
- Download OpenSSH, https://github.com/PowerShell/Win32-OpenSSH/releases.
- Unzip the files to a directory on your machine. For instance, ‘C:\OpenSSH’
- Run the following command in command prompt or PowerShell with elevated permission.
- powershell.exe -ExecutionPolicy Bypass -File install-sshd.ps1
- After successful installation, the command prompt will display logs as shown below.
- Now, open services.msc using run dialog and start the OpenSSH SSH Server and OpenSSH Authentication Agent services as shown below
- Ensure the services are running. By default, the SSH server will be listening on port 22. Open resmon using the run command to check for listening ports.
NOTE: If you see the Firewall Status as Not Allowed/ Restricted, you need to additionally add a Firewall rule to allow connections through this port.
Configure SSH client
- Download and install PuTTY.
- In the Session category, fill in the Host Name and Port. The host name should be an IP or DNS name of the machine where the SSH server is configured.
- Navigate to Tunnels under the SSH category. Set up remote port forwarding.
- The Source port is the port forwarded to the server for tunneling. Ensure the port is allowed through the firewall.
- If the DB is in the same machine where the SSH server is and bound on localhost, set a remote forwarding with ‘localhost’. Else provide the host address where the DB is.
- Save the session if required. Click Open. This will open a connection to the server machine. Enter the credentials to establish a connection.
Connecting SSH Enabled Database in Bold BI
Follow the below steps to connect with Bold BI,- Open the “Bold BI” application
- Click the data source on the left panel of the Bold BI application as shown below:
- Click create data source on the top right corner as shown below:
- Select MongoDB connection on the connection panel to proceed to connect
- Enter the required credentials as instructed below:
- Under Server name, input the host/IP of the machine where the SSH client is configured.
- Under Port, enter the forwarded port used above in PuTTY.
Related links