ODAC

Connecting via SSH

Connecting to Oracle Database Through SSH

This section dicusses how to connect a client application to Oracle Database through SSH. SSH is a network protocol for secure remote login to another system over the Internet by connecting the SSH client to the 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.

It is possible to use SSH an an encryption method to secure the connection between a Delphi application and an Oracle server. You can embed the SSH client functionality into your application and install the SSH server on a remote machine where your Oracle server resides. The SSH client connects to the SSH server, which sends all commands to Oracle Database.

SSH key-based authentication is done by public and private keys that a client uses to authenticate itself when logging into an SSH server. The server key is used is used by the client to authenticate the SSH server and is specified in the TScSSHClient.HostKeyName property. The client key is used by the SSH server to authenticate the client and is specified in the TScSSHClient.PrivateKeyName property. Note that the private key contains the public key. See SecureBridge tutorial on configuring the SSH server.

The SSH server is required to replicate the steps in this tutorial and encrypt the network connection between the client application and Oracle Database. You can build the SSH server demo project, which is distributed with SecureBridge ("Documents\Devart\ODAC for RAD Studio\Demos\TechnologySpecific\SecureBridge\Demo\SSH") and run the executable file.

To establish a connection to a remote SSH server, you must compile and install the TCRSSHIOHandler component, which is distributed with SecureBridge and is required to bind ODAC with SecureBridge. The installation instructions for the component are provided in the Readme.html file, which is located by default in "My Documents\Devart\ODAC for RAD Studio XX\Demos\TechnologySpecific\SecureBridge".

Sample Application That Connects to Oracle Database Through SSH

  1. Place the following components on the form: TOraSession, TOraQuery, TOraDataSource, TDBGrid, TButton, TCRSSHIOHandler, TScSSHClient, and TScFileStorage.
  2. Delphi SSH Components

  3. Select the TDBGrid component and set the DataSource property to an instance TOraDataSource.
  4. Select the TOraDataSource component and set the DataSet property to an instance of TOraQuery.
  5. Select the TOraQuery component and set the Session property to an instance of TOraSession. Double-click TOraQuery and specify a SQL query to execute against Oracle Database.
  6. Select the TButton component and create an OnClick event. Add the code to call the Open method of TOraQuery when the button is clicked.
  7. Delphi TButton

  8. Select the TCRSSHIOHandler component and set the Client property to TScSSHClient.
  9. Select the TScFileStorage component and specify the directory for storing information about keys and users in the Path property. Follow the instructions to generate a pair of keys for authenticating the server by the client.
  10. Select the TScSSHClient component and specify the server public key in the HostKeyName property and the client private key in the PrivateKeyName property. Specify the address of the SSH server in the HostName property and the port, user, and password in corresponding properties. Set the KeyStorage property to an instance of TScFileStorage.
    If you are connecting to Oracle Cloud, leave the Password and HostKeyName properties empty — only specify PrivateKeyName and User (the default username is opc). See the Oracle documentation for information on generating SSH keys.
  11. Delphi TScSSHClient

  12. Select the TOraSession component and set the IOHandler property to an instance of TCRSSHIOHandler. Double-click TOraSession and specify the server address, port, service name, and user credentials.
  13. Delphi TOraSession

  14. Compile and run the application.
  15. Delphi Connection to Oracle through SSH

It is not mandatory to use the TScSSHServer component as the SSH server — you can use any other server that implements the SSH protocol.

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