DataGrip 2024.3 Help

Configure SSH and SSL

To make a connection to a database more secure, some services require SSH or SSL usage.

SSL

The following procedure describes the SSL configuration that suits most databases. For some databases, you need to use another approach for a successful connection. See the Tutorials section that includes configuration examples for Apache Cassandra, Heroku Postgres, and MySQL 5.1.

Connect to a database with SSL

  1. Open data source properties. You can open data source properties by using one of the following options:

    • Navigate to File | Data Sources....

    • Press Ctrl+Alt+Shift+S.

    • In the Database Explorer ⌘ 1 ( View | Tool Windows | Database Explorer), click the Data Source Properties icon (The Data Source Properties icon).

    Add new data source
  2. On the Data Sources tab, select a data source that you want to modify.

  3. Click the SSH/SSL tab and select the Use SSL checkbox.

  4. In the CA file field, navigate to the CA certificate file (for example, mssql.pem).

  5. You can leave the certificate file fields empty and use a truststore to obtain a required certificate from the certificates that it contains. To do that, tick the Use truststore checkbox and select the truststore that you want to use.

    • IDE: Use the certificates that are accepted by the IDE. You can add new accepted certificates in Tools | Server Certificates.

    • JAVA: Use JAVA truststore certificates.

    • System: Use System truststore certificates.

  6. In the Client certificate file field, navigate to the client certificate file (for example, client-cert.pem).

  7. In the Client key file field, navigate to the client key file (for example, client-key.pem).

  8. From the Mode list, select the verification mode:

    Require

    Verifies that the server recognizes the client certificate, if the certificate is provided.

    Verify CA

    • Verifies that the server recognizes the client certificate, if the certificate is provided.

    • Verifies the server by checking the certificate chain up to the root certificate that is stored on the client.

    Full Verification

    • Verifies that the server recognizes the client certificate, if the certificate is provided.

    • Verifies the server by checking the certificate chain up to the root certificate that is stored on the client.

    • Verifies the server host to ensure that it matches the name stored in the server certificate.

    The SSL connection fails if either one of the certificates cannot be verified.

  9. To ensure that the connection to the data source is successful, click Test Connection.

    Connect to a database with SSL

Disable SSL connection to a database

  1. Open data source properties. You can open data source properties by using one of the following options:

    • Navigate to File | Data Sources....

    • Press Ctrl+Alt+Shift+S.

    • In the Database Explorer ⌘ 1 ( View | Tool Windows | Database Explorer), click the Data Source Properties icon (The Data Source Properties icon).

    Add new data source
  2. On the Data Sources tab, select a data source that you want to modify.

  3. Click the SSH/SSL tab and clear the Use SSL checkbox.

  4. Click Apply.

Copy SSL settings from other data sources

If you configured SSL settings for one data source, you can copy them for another data source.

  1. Open data source properties. You can open data source properties by using one of the following options:

    • Navigate to File | Data Sources....

    • Press Ctrl+Alt+Shift+S.

    • In the Database Explorer ⌘ 1 ( View | Tool Windows | Database Explorer), click the Data Source Properties icon (The Data Source Properties icon).

    Add new data source
  2. On the Data Sources tab, select a data source that you want to modify.

  3. Click the SSH/SSL tab and select the Use SSL checkbox.

  4. Click the Copy from link and select the configuration that you want to copy.

    Copy SSL settings

SSH

Secure Shell or SSH is a network protocol that is used to encrypt a connection between a client and a server.

In DataGrip, you can create an SSH connection one of the following ways:

DataGrip SSH tunnel

DataGrip can create an SSH tunnel based on the SSH configuration that you set. To access the SSH configuration settings, press Ctrl+Alt+S to open settings and select Tools | SSH Configuration.

To use an SSH tunnel for the data source, select the Use SSH tunnel checkbox in the SSH/SSL tab of Data Sources and Drivers dialog (Ctrl+Alt+Shift+S) .

Sharing of SSH connection settings

All created SSH connections are shared between all the data sources that you have in a project. If you do not want to share a connection between projects, select the Visible only for this project checkbox in the SSH connection settings.

Connect to a database with SSH

  1. Open data source properties. You can open data source properties by using one of the following options:

    • Navigate to File | Data Sources....

    • Press Ctrl+Alt+Shift+S.

    • In the Database Explorer ⌘ 1 ( View | Tool Windows | Database Explorer), click the Data Source Properties icon (The Data Source Properties icon).

    Add new data source
  2. Select a data source profile where you want to change connection settings.

  3. Click the SSH/SSL tab and select the Use SSH tunnel checkbox.

  4. Click the Add SSH configuration button (the Add SSH configuration).

  5. In the SSH dialog, click the Add button.

  6. If you do not want to share the configuration between projects, select the Visible only for this project checkbox.

  7. In Host, Username, and Port fields, specify your connection details.

  8. From the Authentication type list, you can select an authentication method:

    • Password: Access the host with a password. To save the password in DataGrip, select the Save password checkbox.

    • Key pair (OpenSSH or PuTTY): Use SSH authentication with a key pair. To apply this authentication method, you must have a private key on the client machine and a public key on the remote server. DataGrip supports private keys that are generated with the OpenSSH utility.

      Specify the path to the file where your private key is stored and type the passphrase (if any) in the corresponding fields. To have DataGrip remember the passphrase, select the Save passphrase checkbox.

    • OpenSSH config and authentication agent: Use a credentials helper application that manages your SSH keys, such as ssh-agent.

  9. Click OK to confirm the new SSH configuration settings.

  10. In the Local port field of Data Sources and Drivers dialog, specify the local port number from which you want to forward the connection. Otherwise, DataGrip selects the port dynamically.

SSH settings of a data source

Disable SSH connection to a database

  1. Open data source properties. You can open data source properties by using one of the following options:

    • Navigate to File | Data Sources....

    • Press Ctrl+Alt+Shift+S.

    • In the Database Explorer ⌘ 1 ( View | Tool Windows | Database Explorer), click the Data Source Properties icon (The Data Source Properties icon).

    Add new data source
  2. Select a data source profile where you want to change connection settings.

  3. Click the SSH/SSL tab and clear the Use SSH tunnel checkbox.

  4. Click Apply.

Create SSH tunnel manually

Create the SSH tunnel with PuTTY (Windows)

  1. Download and run the latest version of the PuTTY SSH and Telnet client (download the client from https://www.putty.org/).

  2. In the PuTTY Configuration dialog, navigate to Connection | SSH | Auth.

  3. In the Private key file for authentication field, specify the path to your private key file and click Open.

  4. In the command line window, specify the username that you use for the SSH tunnel and press Enter. Do not close the command line window.

  5. In DataGrip, navigate to File | Data Sources Ctrl+Alt+Shift+S.

  6. Select a data source profile where you want to change connection settings.

  7. Click the SSH/SSL tab and select the Use SSH tunnel checkbox.

  8. From the Auth type list, select OpenSSH config and authentication agent.

  9. In Proxy host, Proxy user, and Port fields, specify connection details.

  10. To ensure that the connection to the data source is successful, click Test Connection.

Create the SSH tunnel with PuTTY (Windows)

Create the SSH tunnel with Pageant (Windows)

Pageant is an SSH authentication agent for PuTTY, PSCP, PSFTP, and Plink. Pageant stores your private key, and as long as it is running, it provides the unlocked private key to PuTTY or other tools like DataGrip. You can find the Pageant icon in the Windows taskbar.

  1. Download the latest version of Pageant (download the client from https://www.putty.org/).

  2. In the Windows taskbar, right-click the Pageant icon and select Add Key.

  3. In the Select Private Key File dialog, navigate to the private key file (the PPK file) and click Open.

  4. (Optional) Enter the private key passphrase and press Enter.

  5. In DataGrip, navigate to File | Data Sources Ctrl+Alt+Shift+S.

  6. Select a data source profile where you want to change connection settings.

  7. Click the SSH/SSL tab and select the Use SSH tunnel checkbox.

  8. From the Auth type list, select OpenSSH config and authentication agent.

  9. In Proxy host, Proxy user, and Port fields, specify connection details.

  10. To ensure that the connection to the data source is successful, click Test Connection.

Create the SSH tunnel with Pageant (Windows)

Create the SSH tunnel with the ssh-agent (macOS and Linux)

Run all commands for ssh-agent in the command line.

  1. Ensure that ssh-agent is running.

    ssh-agent
  2. Add your key to the agent (in the following example, the key path is ~/.ssh/id_rsa).

    ssh-add ~/.ssh/id_rsa
  3. (Optional) On macOS, you can add -K option to the ssh-add command to store passphrases in your keychain. On macOS Sierra and later, you need to create the config file in ~/.ssh/ with the following text:

    Host * UseKeychain yes AddKeysToAgent yes IdentityFile ~/.ssh/id_rsa

    If you have other private keys in the .ssh directory, add an IdentityFile line for each key. For example, if the second key has the id_ed25519 name, add IdentityFile ~/.ssh/id_ed25519 as an additional line for the second private key.

  4. List all added keys.

    ssh-add -L
  5. In DataGrip, navigate to File | Data Sources Ctrl+Alt+Shift+S.

  6. Select a data source profile where you want to change connection settings.

  7. Click the SSH/SSL tab and select the Use SSH tunnel checkbox.

  8. From the Auth type list, select OpenSSH config and authentication agent.

  9. In Proxy host, Proxy user, and Port fields, specify connection details.

  10. To ensure that the connection to the data source is successful, click Test Connection.

Create the SSH tunnel with the ssh-agent (macOS and Linux)
Last modified: 11 October 2024