Field note / AWS Services
What is a Jumpbox, and How to Use it in AWS?
Learn what a jumpbox is and how to use one in AWS to back up RDS databases to S3.
What’s a Jumpbox?
A jumpbox (aka bastion host) is a secure server designed to act as a gateway for accessing resources in a private network. Think of it as your golden bridge—without it, you wouldn’t reach the other side.
Key Features of a Jumpbox:
- Enhanced Security: It limits SSH or RDP access to a single entry point, reducing your attack surface.
- Access Control: Only authorized users can connect, often via specific IP whitelisting or VPN.
- Auditing: All actions passing through the jumpbox can be logged for accountability.
In AWS, jumpboxes are typically EC2 instances with tight security group rules that allow inbound connections from your IP and outbound connections to resources like RDS instances.
If you’re starting fresh, look at AWS Systems Manager Session Manager first. It gives you a shell on a private instance with no open SSH port, no key pairs and every session logged. The steps below work the same once you’re on the box.
Setting Up and Using a Jumpbox
Here’s how to set up and use a jumpbox to back up a database running on RDS and securely upload it to S3.
1. Connect to Your Jumpbox
First, log into your AWS Management Console, and ensure the security group of your jumpbox allows SSH access from your IP. Open a terminal and connect:
ssh -i <YOUR_KEY_PAIR>.pem ec2-user@<JUMPBOX_IP>
Replace <YOUR_KEY_PAIR> with your PEM file and <JUMPBOX_IP> with the public IP of your jumpbox.
2. Back Up the RDS Database
Once connected, we’ll create a backup of the RDS database using mysqldump.
mysqldump --max_allowed_packet=10M \
-h <YOUR_CLUSTER_URL>.rds.amazonaws.com \
-u <YOUR_USER> \
-p <YOUR_DB> > <YOUR_DB>.sql
What’s Happening Here?
--max_allowed_packet=10M: Ensures larger data chunks can be dumped without errors.-h: Points to your RDS endpoint.-uand-p: Authenticate as your RDS user. A bare-pmakes mysqldump prompt for the password, which keeps it out of your shell history. (-p <password>with a space doesn’t work: mysqldump prompts anyway and treats the password as a database name.)<YOUR_DB>: The database to dump.> <YOUR_DB>.sql: Redirects the output to a local SQL file.
3. Compress the Backup
Next, compress the SQL file to save storage and upload time:
7za a -p <YOUR_DB>.7z <YOUR_DB>.sql -mx9 -mhe=on -t7z
-p: Prompts for a password and encrypts the archive with AES-256. Without it, nothing is encrypted.-mx9: Maximum compression.-mhe=on: Also encrypts the file names inside the archive.-t7z: Specifies the archive format.
4. Give the Jumpbox Access to S3
Don’t put access keys on the jumpbox. Attach an IAM instance profile to the EC2 instance with a policy that allows s3:PutObject on your backup bucket. The AWS CLI picks up those credentials automatically and rotates them for you, and nothing secret is left on the box.
5. Upload to S3
aws s3 cp <YOUR_DB>.7z s3://<YOUR_BUCKET>/database/<YOUR_DB>.7z
6. Clean Up
rm <YOUR_DB>.sql <YOUR_DB>.7z
Remove the .sql file too. It’s an unencrypted copy of your whole database.
Wrapping It Up
By now, you’ve:
- Connected to your jumpbox.
- Dumped your RDS database.
- Compressed and encrypted the backup.
- Uploaded it to S3.
- Cleaned up your jumpbox like a responsible admin.
Jumpboxes are not just security powerhouses; they’re indispensable tools for secure access and resource management in AWS. Whether you’re backing up databases or managing private instances, mastering the jumpbox is a skill that will keep your infrastructure lean, secure, and accessible.