UniDAC

Connecting to ASE Through SSH in Delphi

SSH is a protocol that enables secure communication between a client and a remote server over the internet. It establishes a cryptographically protected connection through mutual authentication and encrypted message exchange, using a combination of symmetric encryption, asymmetric encryption, and hashing.

You can use SSH to secure the network connection between a Delphi application and an ASE server. An SSH connection enables you to run shell commands as if you were physically operating the remote machine.

This page demonstrates how to use UniDAC to connect to an ASE server securely via an SSH tunnel.

To follow the steps on this page, you need an SSH client and an SSH server. You can create them using SecureBridge, a solution provided by Devart. It enables you to embed an SSH client 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.

Your ASE server must be configured to accept connections from the SSH tunnel.

Connect Using SecureBridge

You can establish a secure SSH tunnel using SecureBridge without the need for third-party applications. SecureBridge provides all the necessary components to create an SSH client within your Delphi application.

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

  3. Place the following components from the Palette on the form:
    • TDBGrid
    • TButton
    • TUniConnection
    • TScFileStorage
    • TScSSHClient
    • TASEUniProvider
    • TCRSSHIOHandler
    • TDataSource
    • TUniQuery
    These components are required to establish an SSH connection to an ASE server using UniDAC, execute a query, and display the retrieved data in a grid.
  4. Components added to the form for an SSH connection to ASE in Delphi.

  5. Select the TUniConnection component and set the IOHandler property to the instance of TCRSSHIOHandler (CRSSHIOHandler1).
  6. Double-click the TUniConnection component.
  7. On the Options tab, fill out the fields:
    • Provider – Select ASE.
    • Direct – Select True.

    UniConnection options for the Oracle provider in Delphi.

  8. On the Connect tab, fill out the fields:
  9. Click Connect to test the connection to the ASE server, then click OK to close the dialog.
  10. The TUniConnection component with the specified IOHandler property and ASE connection details.

  11. Select the TScFileStorage component and, in the Path property, specify the directory where the keys are stored.
  12. The TScFileStorage component with the specified Path.

  13. Select the TScSSHClient component and assign values to the following properties:
    • Hostname – Enter the host name or IP address of the SSH server.
    • Port – Specify the SSH port.
    • Authentication – Select the value depending on the authentication method applicable for your SSH server: atPassword or atPublicKey.
    • KeyStorage – Set the property to the instance of TScFileStorage (ScFileStorage1).
    • HostKeyName – Specify the name of the SSH server public key.
    • PrivateKeyName – For public key authentication, specify the name of the client private key.
    • User – Enter the username for the account on the SSH server.
    • Password – For password authentication, enter the password for the account on the SSH server.
  14. The TScSSHClient component with the specified properties in the Object Inspector.

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

  17. Select the TDBGrid component and, in the Object Inspector, set the DataSource property to the instance of TDataSource (DataSource1).
  18. The TDataSource component assigned to the DataSource property in the TDBGrid component in the Object Inspector.

  19. Select the TDataSource component and set the DataSet property to the instance of TUniQuery (UniQuery1).
  20. The TUniQuery component assigned to the DataSet property in the TDataSource component in the Object Inspector.

  21. Select the TUniQuery component and set the Connection property to the instance of TUniConnection (UniConnection1).
  22. Then, double-click the TUniQuery component, enter a SQL query to be run against the ASE 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 UniQuery1 object to activate the dataset when the button is clicked.
  25. UniQuery1.Open;

    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 OpenSSH or Any Other Third-Party SSH Tunneling Tools

Using SecureBridge and its components is not obligatory—you can use any other server that implements the SSH protocol.

The following steps describe a simple case of using OpenSSH for Windows. For a detailed description of each command, see the OpenSSH documentation.

  1. Download OpenSSH for Windows.
  2. Install an SSH server:
    1. Choose a machine that will be used as the SSH server. It does not have to be the same machine as the ASE server, but the communication channel between the SSH server and the ASE server must be protected.
    2. Using the Windows Control Panel, create a user (for example, SSH_user) and set a password for the user.
    3. Install OpenSSH. It is enough to install only the server components.
    4. Open the OpenSSH/bin folder.
    5. Add SSH_user to the list of allowed users.

      mkpasswd -l -u SSH_user >> ..\etc\passwd

    6. Use mkgroup to create a group permissions file.

      mkgroup -l >> ..\etc\group

    7. Run the OpenSSH service.

      net start opensshd

  3. Install an SSH client:
    1. Choose a machine that will be used as the SSH client. It does not have to be the same machine where the ASE client is running, but the communication channel between the SSH client and the ASE client must be protected.
    2. Install OpenSSH to the SSH client. You do not need to install the server components.
    3. Run the SSH client.

      ssh.exe -L <SSH_port>:<ASE_server>:<ASE_server_port> <SSH_user>@<SSH_server>

      <SSH_port> – The port number of the SSH client that will be redirected to the corresponding port of the ASE server.
      <ASE_server> – The name or IP address of the machine where the ASE server is installed.
      <ASE_server_port> – The number of the ASE server port, usually 3306.
      <SSH_user> – The name of the user created at step 2.
      <SSH_server> – The name or IP address of the machine where the SSH server was installed at step 2.

      For example, ssh.exe -L 3307:server:3306 [email protected].

      At first launch, you will be prompted to confirm the connection with the specified SSH server. Enter yes for confirmation.

      At each launch of SSH, you must enter the password set at step 2.

  4. Configure TUniConnection.

    UniConnection1.Server := <SSH_client>;
    UniConnection1.Port := <SSH_port>;

    If the SSH client was installed on the same machine as the ASE client, you can assign localhost to UniConnection1.Server.

Note that in the provided steps, Windows checks the SSH_user authentication. For information about the methods of higher protection (key authentication, etc.), see the OpenSSH documentation.

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