# Access a Private AWS RDS Instance via a Jumpbox

Accessing a private Amazon RDS instance is a common requirement in cloud-based architectures — but exposing your database directly to the internet introduces serious security risks.\
To mitigate this, a **jumpbox (bastion host)** is used as a controlled entry point to reach resources within a **private subnet**.

This guide walks you through **setting up and using an SSH tunnel via a jumpbox** to connect to your private RDS instance.\
By following these steps, you’ll be able to **securely manage your database** while keeping it **fully isolated and protected within your private network**.

## 1. Create an EC2 instance

1. **Log in** to your **AWS Management Console**.
2. **Navigate** to the **EC2 Dashboard**.
3. **Create a new EC2 instance** and configure it as follows:

**Configuration Details:**

* **Region:** Same region as your RDS instance.
* **Availability Zone:** Preferably the same AZ as your RDS to minimize latency.
* **Instance Type:** `t2.micro` (1 vCPU, 1 GiB memory) — approximately **$10.80/month**, which is sufficient since the jumpbox only handles **data tunneling**.

<figure><img src="https://2867423571-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfJjIdV9cuW6K8asJjTPJ%2Fuploads%2FLPBIAOeOQWx9KnbTLIwm%2Fimage.png?alt=media&#x26;token=19d88ca6-129a-4a8c-b572-a09bb63363d4" alt=""><figcaption></figcaption></figure>

## 2. Grant ssh access to your client service

**Connect to your instance via SSH:**

```bash
ssh <ssh_user>@<jumpbox_ip>
```

* Use **`ubuntu`** as the SSH user if the EC2 instance is running **Ubuntu**.
* Use **`ec2-user`** if the instance is running **Amazon Linux**.

## 3. Whitelist trusted IPs

The most effective security measure is to **whitelist only the IP addresses** that are allowed to connect to your Jumpbox.\
We recommend granting access **exclusively to the IPs that require it**.

You can do this by **creating a dedicated Security Group** under the **Network & Security** section and adding inbound rules for your trusted services or hosts.

<figure><img src="https://2867423571-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfJjIdV9cuW6K8asJjTPJ%2Fuploads%2FNlHXTnUNHqx68fbQJXlf%2Fimage.png?alt=media&#x26;token=d68feaee-8d2e-4c66-8d2c-f060786ac572" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2867423571-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfJjIdV9cuW6K8asJjTPJ%2Fuploads%2FScRzpdUMx5C3v15SXwgA%2Fimage.png?alt=media&#x26;token=6a6763e9-1bc8-4040-9ff9-a7258cacf1cc" alt=""><figcaption></figcaption></figure>

You can now **attach the newly created security group** to your **Jumpbox EC2 instance** to apply the updated access rules.

<figure><img src="https://2867423571-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfJjIdV9cuW6K8asJjTPJ%2Fuploads%2FEVrZpShcA5EKxE4s9SU1%2Fimage.png?alt=media&#x26;token=6b1fc908-7845-4687-9cd3-4e4389e62952" alt=""><figcaption></figcaption></figure>

You can verify that **only your whitelisted client** can access the jumpbox by running:

```bash
telnet <jumpbox_ip> <ssh_port>
```

If the command **times out**, it confirms that **access from your current network is blocked**, and only the authorized client can connect.

## 4. Grant the jumpbox access to your DB

**Create a dedicated security group** for the Jumpbox to access the database, following the same process described in the previous step.\
Then, **update your database’s security group rules** to allow inbound connections **only from this new Jumpbox security group**.

<figure><img src="https://2867423571-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfJjIdV9cuW6K8asJjTPJ%2Fuploads%2F8690eS6RVEu9OEfzGnig%2Fimage.png?alt=media&#x26;token=e9f84d13-d363-4fbd-bf37-7899dbbdae09" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2867423571-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfJjIdV9cuW6K8asJjTPJ%2Fuploads%2F19ux0pvqGp3mB6IqutN5%2Fimage.png?alt=media&#x26;token=59bf140d-2672-4a81-8f1e-cfda7823ea49" alt=""><figcaption></figcaption></figure>

#### ✅ Test Your Setup

You can verify your configuration by running the following commands **from the service or machine you whitelisted**:

```bash
# Create the SSH tunnel
ssh -L 5432:<db_ip>:5432 -N -f <jumpbox_user>@<jumpbox_ip>

# Connect to the database through the tunnel
psql -h localhost -p 5432 -U <DB_USER> -d <DB_NAME>
```

If the connection succeeds — congratulations 🎉\
You can now securely access your **private database** through an **SSH tunnel** that routes traffic via your **jumpbox**.

#### 🔒 (Optional) Additional Security Measures

To further strengthen your setup beyond the steps in this tutorial, consider implementing the following best practices:

* **Use an SSL certificate** to secure all encrypted connections.
* **Configure a firewall** (e.g., AWS Security Groups or ufw) to strictly control inbound and outbound traffic on the jumpbox.
* **Create a dedicated system user** instead of using default accounts such as `ubuntu` or `ec2-user`.
* **Limit privileges:** disable `sudo` access for the SSH user and grant only the minimum permissions required.
* **Change the default SSH port** (22) to a custom port to reduce exposure to automated attacks.
* **Install Fail2Ban** to automatically block IPs that trigger repeated failed login attempts.
* **Deploy auditd** to monitor and log all system-level events for auditing and anomaly detection.

If you have any questions, feel free to ping us at <hello@stacksync.com> we'll be happy to help!
