Knowledge Base
How to back up a database through SSH tunneling (WebHostingBuzz example)
Overview
By the end of this article, you will have a MySQL database on a shared hosting account connected to CodeGuard through an SSH tunnel and running its first backup. Secure Shell (SSH) tunneling is a method of routing the database connection through an encrypted SSH session, which lets CodeGuard reach a database on a host that blocks direct remote connections. The article covers five stages in order: gathering the credentials you will need; enabling and confirming SSH access on your hosting account; collecting your MySQL credentials; creating a MySQL user if you do not have one you can use; and adding the database in CodeGuard with the tunnel option selected. A verify section confirms the first backup completed, and a troubleshooting section covers the common connection failures.
WebHostingBuzz is used here as a worked example because it blocks remote database connections by default. The same approach applies to any host that offers SSH access; the control panel screens and the SSH port number will differ.
Before you begin
Collect the following before you start. You will gather most of it as you work through Steps 1 to 4.
| Item | Where it comes from |
|---|---|
| Control panel username and password | The welcome email from your hosting provider |
| Your domain name | Your hosting account |
| SSH username and password | Your hosting provider — often the same as the control panel login |
| SSH port number | Your hosting provider — may not be the default port 22 |
| Database hostname or IP address | Your control panel |
| Database name | Control panel, MySQL Databases page |
| MySQL username and password | Control panel, MySQL Databases page |
You will also need an active CodeGuard account with the website already added.
Figure 1: Checklist of connection details needed to add a database through an SSH tunnel
Step 1: Confirm SSH access is enabled on your account
Many shared hosting accounts have SSH access disabled by default, and some use a non-standard SSH port. Contact your hosting provider's support team and ask them to confirm three things:
- That SSH access is enabled for your account.
- Whether your SSH username and password are the same as your control panel login.
- Which port SSH uses, since it may not be the default port 22.
Record the SSH port number your provider gives you. You will need it in Step 5, and it is specific to your account — do not assume the value shown in any example.
Step 2: Verify SSH access in your control panel
- Sign in to cPanel. On most hosts this is your domain name followed by port 2083 — for example
yourdomain.com:2083. Your provider may use a different address.
Figure 2: cPanel sign-in page with username and password fields - In the left-hand search bar, search for Shell and select SSH/Shell Access.
Figure 3: Shell Access option - Confirm the SSH access section is present and available. If the page reports that SSH access is not enabled, return to Step 1 and confirm with your provider that it has been switched on.
Figure 4: Shell Access page confirming S… account
Step 3: Find your MySQL database details
- Return to the main cPanel page, search for mysql, and select MySQL Databases.
Figure 5-7: cPanel search results showing the MySQL Databases option - Note the name of each database you want to back up and the MySQL user assigned to it.
Figure 6: MySQL Databases page listing current databases and their assigned users
If you already know the password for an existing MySQL user with access to those databases, skip Step 4 and continue at Step 5. If you do not, create a new user in Step 4 rather than guessing.
Step 4: Create a MySQL user (if needed)
Create a dedicated user for CodeGuard so the connection can be managed and revoked independently of your other database accounts.
- Scroll to the Add New User section of the MySQL Databases page. Enter a username and a strong password, and record them.
Figure 7: Add New User section of the MySQL Databases page with username and password fields - Grant the user all privileges. CodeGuard requires full privileges to back up and restore the database.
Figure 8: Manage User Privileges page with the All Privileges option selected - Select the new user and the target database from the dropdown menus, then select Add. Repeat for each database you plan to back up.
Figure 9: Add User To Database section with user and database dropdown menus
Note that your host may add an account prefix to the username automatically. Use the full prefixed name when connecting from CodeGuard.
Step 5: Add the database in CodeGuard
- Sign in to CodeGuard, open the website you want to add the database to, and select Add Database at the bottom of the page.
Figure 10: CodeGuard website page with the Add Database option - On the connection screen, enter your database hostname or IP address and select Test Connection. If your host blocks remote connections — as WebHostingBuzz does by default — this test will not succeed. If you have added databases to this site before, select Skip This Step to continue to the credentials page.
Figure 11: Add Database connection screen with hostname field, Test Connection button, and Skip - On the credentials page, select Tunnel over SSH and enter your SSH username, SSH password, and the SSH port number your provider gave you in Step 1. Then enter your MySQL username and password.
Figure 12: Database credentials page with Tunnel over SSH selected and SSH connection fields - When the connection succeeds, select the databases you want to back up and confirm.
Figure 13: Database selection list with checkboxes for each available database
Step 6: Verify the first backup
The initial backup starts as soon as the database is added.
- A progress tracker shows each stage. You do not need to stay on the page — CodeGuard sends an email when the backup finishes.
Figure 14: Database activation progress tracker showing the current backup stage - When the backup completes, the first version appears against the database in your dashboard.
The database is connected correctly when all three of the following are true: the database is listed in your CodeGuard dashboard, the initial backup completed without a connection error, and a first backup version is available.
Troubleshooting
The SSH connection is refused. The port number is the most common cause. Confirm with your hosting provider which port SSH uses on your account, and enter that value rather than the default port 22.
SSH credentials are rejected. On some hosts the SSH login differs from the control panel login. Confirm with your provider which credentials apply, and test them by opening an SSH session to the server directly.
The database does not appear in the selection list. The MySQL user has not been assigned to that database, or does not have full privileges. Return to Steps 3 and 4.
The connection test fails on the hostname screen. This is expected on hosts that block remote database connections. Continue past this screen and use the SSH tunnel option on the credentials page.
If the problem persists, contact Sectigo support.
Similar questions
- How do I back up a database that blocks remote connections?
- What is SSH tunneling and why does CodeGuard need it?
- Which SSH port should I use when adding a database to CodeGuard?
- How do I connect a WebHostingBuzz database to CodeGuard?
Need assistance?
Contact our team for help with your purchase or issuing your certificate.