Connecting via an SSH tunnel

Connecting Polytomic to databases through SSH

Polytomic supports connecting to some databases via an SSH tunnel. Integrations that support SSH connections include:

If your database server requires an SSH connection, we recommend you generate a new SSH key pair for Polytomic. The steps below describe how to do this for Ubuntu environments.

  1. Create a user account for Polytomic.
ubuntu@ip-10-0-5-194:~$ sudo adduser polytomic --disabled-password
Adding user `polytomic' ...
Adding new group `polytomic' (1001) ...
Adding new user `polytomic' (1001) with group `polytomic' ...
Creating home directory `/home/polytomic' ...
Copying files from `/etc/skel' ...
Changing the user information for polytomic
Enter the new value, or press ENTER for the default
	Full Name []:
	Room Number []:
	Work Phone []:
	Home Phone []:
	Other []:
Is the information correct? [Y/n]
  1. Switch to the Polytomic user and generate an SSH key pair.
ubuntu@ip-10-0-5-194:~$ sudo su polytomic
polytomic@ip-10-0-5-194:/home/ubuntu$ cd ~
polytomic@ip-10-0-5-194:~$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/polytomic/.ssh/id_rsa):
Created directory '/home/polytomic/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/polytomic/.ssh/id_rsa
Your public key has been saved in /home/polytomic/.ssh/id_rsa.pub
The key fingerprint is:
SHA256:ofESkNzrFipL3Dq39csjkHoFg3my2UDPuOEPVGO22IA polytomic@ip-10-0-5-194
The key's randomart image is:
+---[RSA 3072]----+
| . ..o           |
|E o B..          |
| . & oo..        |
|  X O o= .       |
| + @ *o.S        |
|  X * +.         |
| . B +.          |
|  = +..o.        |
|   +.. .+o       |
+----[SHA256]-----+

The file /home/polytomic/.ssh/id_rsa now contains the SSH private key Polytomic uses to connect.

📘

Supported key types

Polytomic supports RSA, ECDSA, and Ed25519 keys. This example creates an RSA key. If you create another key type, such as Ed25519 (id_ed25519), use its file names in place of id_rsa and id_rsa.pub in the steps below.

🚧

Leave the passphrase empty

Polytomic doesn't support passphrase-protected private keys. Press Enter at both passphrase prompts when you run ssh-keygen.

  1. Authorize the public key for the polytomic user.
polytomic@ip-10-0-5-194:~$ cd ~/.ssh/
polytomic@ip-10-0-5-194:~/.ssh$ cat id_rsa.pub >> authorized_keys
polytomic@ip-10-0-5-194:~/.ssh$ chmod 600 authorized_keys
  1. Create a new connection in Polytomic. Databases that support SSH connections display the option Connect over SSH tunnel. Select it to show the SSH configuration fields: SSH user, SSH host, SSH port (default 22), and Private key.
  1. Fill in the SSH configuration fields. Enter polytomic as the SSH user. Paste the contents of your private key file (/home/polytomic/.ssh/id_rsa in the example above) into the Private key field. For the database Hostname, enter the database address as the SSH host sees it.

  2. Click Save.

SSH bastion instance size

If you're on AWS, we recommend a t4g.medium instance size for your bastion.