Skip to contentManaged Kafka is live: Apache Kafka on AWS for half the cost of MSK

Connection options

Connect through an SSH tunnel

Connect Artie to a database in a private network through an SSH tunnel host that you control. Artie connects to it with its own SSH key.

Artie opens an SSH connection to your tunnel host with its own key, then forwards traffic through the host to your database.

Private subnetPublic subnetSSH tunnelPrivate networkArtieBastion hostSecurity groupDatabaseSecurity group

Artie connects to the tunnel host on the SSH port you set, 22 by default. The tunnel host forwards traffic to your database on the database’s port.

Prerequisites

  • A tunnel host, such as an EC2 instance or Azure VM, that can open a TCP connection to your database’s host and port. An existing bastion host works.
  • The tunnel host’s security group (network security group on Azure) allows inbound SSH from Artie’s IP addresses on the SSH port.
  • sshd on the tunnel host allows TCP forwarding for the SSH user. Check that AllowTcpForwarding isn’t set to no.
  • An Artie role that can edit. View-only members can’t create SSH tunnels.
  • A connector that supports SSH tunnels.

These connectors support SSH tunnels:

  • CockroachDB
  • DocumentDB
  • Microsoft SQL Server
  • MySQL
  • Oracle
  • PostgreSQL
  • Redis
  • Redshift

For any other connector, pipeline setup has no Network access step.

Create the tunnel in Artie

Create the tunnel while you set up a pipeline, or in Settings for a pipeline that already exists. A workspace holds at most 100 SSH tunnels.

Create it during pipeline setup

  1. On the Network access step for your source or destination, select SSH tunnel, then select Continue.
  2. If the page shows Existing tunnel and New tunnel, select New tunnel.
  3. Enter a Name, and the tunnel host’s public IP address or hostname as SSH host.
  4. Enter the SSH port. It defaults to 22 and accepts 1 to 65535.
  5. Enter the SSH username. Use artie if you create the dedicated user in Add the public key to the tunnel host.
  6. Select Save and generate key.

Artie saves the tunnel, links it to the connector, and shows the key under Add the public key.

To reuse a saved tunnel, select Existing tunnel and choose it in the SSH tunnel dropdown. The dropdown lists the tunnels in the pipeline’s environment, and Artie links your choice right away.

Create it in Settings

  1. Go to Settings > SSH tunnels and select New SSH tunnel.
  2. Choose the Environment. Only connectors in the same environment can use the tunnel.
  3. Enter a Name, and the tunnel host’s public IP address or hostname as SSH host.
  4. Enter the SSH port (22 by default) and the SSH username.
  5. Select Save.

The dialog becomes SSH tunnel settings and shows the tunnel’s Public key.

Add the public key to the tunnel host

Saving a tunnel generates a 4096-bit RSA key pair. Artie stores the private key and shows you only the public key, which starts with ssh-rsa.

Copy the public key from Artie. Then SSH into your tunnel host and run these commands, which create a dedicated artie user and add the key to its ~/.ssh/authorized_keys:

Bash
sudo useradd -m -s /bin/bash artie
sudo su artie
mkdir -p ~/.ssh

# Paste the public key from Artie into authorized_keys
vi ~/.ssh/authorized_keys

chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys

The user in these commands must match the tunnel’s SSH username. To use a user that already exists, skip the first command and add the key as a new line, keeping the existing keys.

Verify the tunnel

In pipeline setup, select Verify tunnel. Artie shows Tunnel verified, and Continue moves to the next step.

In Settings, open the tunnel and select Test connection. Artie shows “Artie connected to your SSH host.”

Both checks open an SSH connection from Artie’s data plane to the tunnel host, using the tunnel’s host, port, username and key. Artie checks the database connection later, when you connect the source or destination.

When the connection times out or is refused, Artie shows this message:

Text
We couldn’t reach the bastion host. Check its host and port, or allow Artie’s IP addresses in its firewall.

For any other failure, check the SSH username and that the public key is on the tunnel host.

If the tunnel host becomes unreachable while a pipeline is running, the pipeline can’t reach your database. Artie keeps retrying the SSH connection, with a 500 millisecond pause between attempts, until the tunnel host accepts it.

Use the tunnel on an existing pipeline

  1. On the pipeline settings page, open the tab that starts with Source or Destination.
  2. In the connection method control, select SSH tunnel.
  3. Choose the tunnel in the SSH tunnel (optional) dropdown. For DocumentDB, the label is SSH tunnel.
  4. Deploy the pipeline.

The dropdown lists the tunnels in the connector’s environment. New SSH tunnel, next to the dropdown, creates a tunnel without leaving the page.

A connector uses one connection method. Selecting an SSH tunnel removes the connector’s PrivateLink connection.

Manage SSH tunnels

Edit, rotate and delete tunnels in Settings > SSH tunnels.

Edit a tunnel

Select Edit SSH tunnel on the tunnel’s row, change the Name, SSH host, SSH port or SSH username, and select Save. Artie marks every pipeline that uses the tunnel as having undeployed changes. Deploy those pipelines to apply the change.

Rotate the SSH key

Editing a tunnel keeps its key pair, so rotating the key means replacing the tunnel.

  1. Create a new SSH tunnel with the same environment, host, port and username as the old one.
  2. Add the new public key to ~/.ssh/authorized_keys on your tunnel host.
  3. Switch each connector to the new tunnel.
  4. Deploy the pipelines that use those connectors. Pipelines keep the old key until you deploy them.
  5. Remove the old public key from the tunnel host.
  6. Delete the old tunnel.

Delete a tunnel

Select Delete SSH tunnel on the tunnel’s row. Artie blocks the delete while a connector uses the tunnel, so switch those connectors to another tunnel or connection method first.

Was this page helpful?