Connect to a database with SSH
This topic gives you examples of how you can connect to databases running in isolated networks through an SSH tunnel and a jump host.
For more information about how to use SSH in RubyMine, refer to the SSH and SSL topic.
Cloud database
Let us consider the following example. MySQL database is running remotely in a cloud, the connection has to be established through a jump host. You need to authenticate using your encrypted private key file. To create a data source and run a test connection to your database, do the following:
In the Database tool window, click
New on the toolbar and navigate to .
Click the SSH/SSL tab and select the Use SSH tunnel checkbox.
Click
Add SSH configuration.
In the SSH Configurations dialog, add a new configuration by doing the following:
Click the Add button.
In the Host and Port fields, specify the connection details of your jump host. For example,
my-jump-host.amazonaws.com
,22
.Enter your username in the Username field.
In this tutorial, we use encrypted private key file and public key file to authenticate. From the Authentication type list, select Key pair.
To provide your private key file, click
Browse in the Private key file field and select the file.
Specify your passphrase in the Passphrase field.
Click Test Connection to run a test connection to the jump host.
In the SSH Configurations dialog, click OK to confirm the new SSH configuration settings.
On the General tab of the Data Sources and Drivers dialog, specify your database connection details:
In the Host and Port fields, specify your database server address and port number. For example,
mysql-ssh.my-account.my-region.amazonaws.com
and3306
.From the Authentication dropdown, select User & Password.
In the User and Password fields, type your user credentials.
In the Database field, type the database name to which you want to connect. In our example,
testdb
.In the URL field, RubyMine generates the JDBC URL automatically using the values of other connection settings.
If you need to use a JDBC URL with certain additional settings, paste it in the URL field.
For example,
jdbc:mysql://my-endpoint.amazonaws.com:3306/testdb
.
Click the Test Connection link at the bottom of the connection details area to initiate a test connection to your database.
Click OK to create the data source.
![Connection settings of the MySQL [Cloud, SSH] data source Connection settings of the MySQL [Cloud, SSH] data source](https://resources.jetbrains.com/help/img/idea/2025.1/db_ssh_connection_example_data_source_cloud.png)
Database in a Docker container
In this example, PostgreSQL database is running in a Docker container, and it is not directly accessible. The connection has to be established through a jump host running in another Docker container. You need to authenticate using your encrypted private key file. To create a data source and run a test connection to your database, do the following:
In the Database tool window, click
New on the toolbar and navigate to .
Click the SSH/SSL tab and select the Use SSH tunnel checkbox.
Click
Add SSH configuration.
In the SSH Configurations dialog, add a new configuration by doing the following:
Click the Add button.
In the Host and Port fields, specify the connection details of your jump host running in Docker container. For example,
localhost
and2222
.Enter your username in the Username field.
In this tutorial, we use encrypted private key file and public key file to authenticate. From the Authentication type list, select Key pair.
To provide your private key file, click
Browse in the Private key file field and select the file.
Specify your passphrase in the Passphrase field.
Click Test Connection to run a test connection to the jump host.
In the SSH Configurations dialog, click OK to confirm the new SSH configuration settings.
On the General tab of the Data Sources and Drivers dialog, specify your database connection details:
In the Host and Port fields, specify your database server address and port number. For example,
172.19.0.3
and5432
.From the Authentication dropdown, select User & Password.
In the User and Password fields, type your user credentials.
In the Database field, type the database name to which you want to connect. In our example,
guest
.In the URL field, RubyMine generates the JDBC URL automatically using the values of other connection settings.
If you need to use a JDBC URL with certain additional settings, paste it in the URL field.
For example,
jdbc:postgresql://172.19.0.3:5432/guest
.
Click the Test Connection link at the bottom of the connection details area to initiate a test connection to your database.
Click OK to create the data source.
![Connection settings of the MySQL [Cloud, SSH] data source Connection settings of the MySQL [Cloud, SSH] data source](https://resources.jetbrains.com/help/img/idea/2025.1/db_ssh_connection_example_data_source_docker.png)