To connect your PostgreSQL database to Commerce Intelligence via an
SSH tunnel, you must do a few things:
public key is used to authorize the Commerce Intelligence Linux user. Now, you will create the user and import the key.
PostgreSQL credentials page opens, set the
Encrypted toggle to
Yes. This displays the
SSH setup form.
public key is located underneath this form.
Leave this page open throughout the tutorial - you will need it in the next section and at the end.
Below demonstrates how to navigate through Commerce Intelligence to retrieve the key:
For the connection to be successful, you must configure your firewall to allow access from your IP address. It is
126.96.36.199/32, but it is also on the
PostgreSQL credentials page. See the blue box in the GIF above.
This can be a production or secondary machine, as long as it contains real-time (or frequently updated) data. You may restrict this user any way you like, as long as it retains the right to connect to the PostgreSQL server.
adduser rjmetric -p<password>
public key you retrieved in the first section? To ensure that the user has access to the database, you need to import the key into
Copy the entire key into the
authorized\_keys file as follows:
"<PASTE KEY HERE>" >> /home/rjmetric/.ssh/authorized_keys
/home/rjmetric directory to allow access via
chown -R rjmetric:rjmetric /home/rjmetric
chmod -R 700 /home/rjmetric/.ssh
sshd\_config file associated with the server is not set to the default option, only certain users have server access - this prevents a successful connection to Commerce Intelligence. In these cases, it is necessary to run a command like
AllowUsers to allow the rjmetric user access to the server.
Your organization may require a different process, but the simplest way to create this user is to execute the following query when logged into Postgres as a user with the right to grant privileges. The user should also own the schema that Commerce Intelligence is being granted access to.
GRANT CONNECT ON DATABASE <database name> TO rjmetric WITH PASSWORD <secure password>;GRANT USAGE ON SCHEMA <schema name> TO rjmetric;GRANT SELECT ON ALL TABLES IN SCHEMA <schema name> TO rjmetric;ALTER DEFAULT PRIVILEGES IN SCHEMA <schema name> GRANT SELECT ON TABLES TO rjmetric;
secure password with your own secure password, which can be different from the SSH password. Also, make sure you replace
database name and
schema name with the appropriate names in your database.
If you want to connect multiple databases or schemas, repeat this process as necessary.
To wrap things up, you need to enter the connection and user info into Commerce Intelligence. Did you leave the PostgreSQL credentials page open? If not, go to Manage Data > Connections and click Add a Data Source, then the PostgreSQL icon. Do not forget to set the
Encrypted toggle to
Enter the following info into this page, starting with the
Database Connection section:
Username: The RJMetrics Postgres username (should be rjmetric)
Password: The RJMetrics Postgres password
Port: PostgreSQL port on your server (5432 by default)
Remote Address: The IP address or hostname of the server you will SSH into
Username: Your SSH login name (should be rjmetric)
SSH Port: SSH port on your server (22 by default)
When you are finished, click Save & Test to complete the setup.