UniDAC

Connecting to Oracle Through SSH in Delphi

Secure Shell (SSH) is a network protocol for secure remote login to another system over the internet by connecting an SSH client to an SSH server. SSH provides a mechanism for establishing a secure connection between the client and the remote server, which authenticate each other and exchange messages. It employs different forms of symmetrical encryption, asymmetrical encryption, and hashing. The SSH client initiates a connection and uses public key cryptography to verify the identity of the SSH server.

This page demonstrates how to connect a Delphi application to Oracle with UniDAC using SSH as the encryption method.

You need an SSH client and an SSH server to replicate the steps on this page. You can create them using SecureBridge, a solution provided by Devart. It enables you to embed the SSH client functionality into your Delphi application and, if needed, configure an SSH server. For more information, see the SecureBridge tutorial on configuring an SSH server.

You can also build the SSHServer demo project, which is distributed with SecureBridge.

Connect Using SecureBridge

Prerequisites:
  1. In RAD Studio, select File > New > Windows VCL Application - Delphi.
  2. The extended File menu and New submenu in Delphi.

  3. Place the following components from the Palette on the form:
    • TDBGrid
    • TButton
    • TCRSSHIOHandler
    • TOracleUniProvider
    • TUniConnection
    • TUniDataSource
    • TUniQuery
    • TScFileStorage
    • TScSSHClient

    Components added to the form for an SSH connection to Oracle in Delphi.

  4. Select the TCRSSHIOHandler component and set the Client property to the instance of TScSSHClient (ScSSHClient1).
  5. The TScSSHClient component assigned to the Client property in the TCRSSHIOHandler component.

  6. Select the TDBGrid component and, in the Object Inspector, set the DataSource property to the instance of TUniDataSource (UniDataSource1).
  7. The TUniDataSource component assigned to the DataSource property in the TDBGrid component in the Object Inspector.

  8. Select the TUniDataSource component and set the DataSet property to the instance of TUniQuery (UniQuery1).
  9. The TUniQuery component assigned to the DataSet property in the TUniDataSource component in the Object Inspector.

  10. Select the TScFileStorage component and, in the Path property, specify the directory where information about keys and users is stored.
  11. The TScFileStorage component with the specified Path.

  12. Select the TScSSHClient component and assign values to the following properties:
    • Authentication – Select the value depending on the authentication method applicable for your SSH server: atPassword or atPublicKey.
    • HostKeyName – For public key authentication, specify the filename of the SSH server public key.
    • Hostname – Enter the host name or IP address of the SSH server.
    • KeyStorage – Set the property to the instance of TScFileStorage (ScFileStorage1).
    • Password – For password authentication, enter the password for the account on the SSH server.
    • Port – Specify the SSH port.
    • PrivateKeyName – For public key authentication, specify the filename of the client private key.
    • User – Enter the username for the account on the SSH server.
  13. If you are connecting to Oracle Cloud, leave the Password and HostKeyName properties empty—only specify PrivateKeyName and User (the default username is opc).

    The TScSSHClient component with the specified properties in the Object Inspector.

  14. Select the TUniConnection component and set the IOHandler property to the instance of TCRSSHIOHandler (CRSSHIOHandler1).
  15. The TUniConnection component with the specified IOHandler property and MyCQL connection details.

  16. Double-click the TUniConnection component.
  17. On the Options tab, fill out the fields:
    • Provider – Select Oracle.
    • Direct – Select True.

    UniConnection options for the Oracle provider in Delphi.

  18. On the Connect tab, fill out the fields:
  19. Click Connect to test the connection to the Oracle server, then click OK to close the dialog.
  20. Connection to Oracle in Delphi.

  21. Select the TUniQuery component and set the Connection property to the instance of TUniConnection (UniConnection1).
  22. Double-click the TUniQuery component, enter a SQL query to be run against the Oracle database, and click OK.
  23. The TUniConnection component assigned to the Connection property and a SQL query in the TUniQuery component.

  24. Double-click the TButton component and add code to call the Open method on the TUniQuery component instance to activate the dataset when the button is clicked.
  25. The UniQuery1.Open method call added to the TButton component.

  26. Press F9 to compile and run the application.
  27. In the form that appears, click Button1 to run the query. Data appears in the grid.
  28. A form with a grid filled with data and a button.

Connect Using Any Third-Party SSH Tunnel

It is not mandatory to use SecureBridge and its components—you can use any other server that implements the SSH protocol.

© 1997-2026 Devart. All Rights Reserved. Request Support DAC Forum Provide Feedback