SSH Tunneling

You can connect Postgres, MySQL, MSSQL, MongoDB, and other databases that are hosted under a private network via SSH tunnels.

Follow the instruction below to configure SSH tunneling in UI Bakery:

  1. Start by navigating to the data source connection window - choose your data source and select the Enable SSH tunnel checkbox.

  1. Now, you need to configure your bastion host to allow UI Bakery to establish an SSH tunnel:

    1. Create a UI Bakery user (UI Bakery will connect to your bastion as this user):

      # Use this command if you use Amazon Linux
      sudo adduser uibakery --password NP
      
      # Use this command if you use any other Linux/Mac
      sudo adduser uibakery --disabled-password
    2. Next, create the required authorized_keys file and configure its permissions:

      # Login as root user
      sudo su
      
      # Create the authorized_keys file if it does not exist
      mkdir -p /home/uibakery/.ssh 
      touch /home/uibakery/.ssh/authorized_keys 
      
      # Set required permissions and make uibakery user an owner of this file
      chmod 644 /home/uibakery/.ssh/authorized_keys
      chown uibakery:uibakery /home/uibakery/.ssh/authorized_keys
    3. Now, go back to the data source connection window, copy the SSH public key, and paste it to the authorized_keys file:

      # Use any text editor and insert previously copied ssh public key in authorized_keys file
      vim /home/uibakery/.ssh/authorized_keys

The same steps apply for on-premise deployments as well.

  1. Once connected, return to UI Bakery and specify your bastion host and port number under the Enable SSH tunnel checkbox.

Usually, bastion host is either the domain or IP address of the virtual machine and port number is the SSH port (22) of the server that holds the database.

  1. Next, specify the Bastion user you created in Step 2 (a).

  1. Finally, scroll up to the Connection settings section and specify all the required fields.

ℹ️ Please note that in the Host field you either need to specify:

  • localhost (if the bastion and database are on the same virtual machine) or

  • your private network IP address (if bastion and database are on different virtual machines with mutual access and the 3306 port is open)

  1. Click Test connection to check whether the data source can be connected, and then click Connect Datasource.

Last updated

Was this helpful?