<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Shalom Crownwell on Medium]]></title>
        <description><![CDATA[Stories by Shalom Crownwell on Medium]]></description>
        <link>https://medium.com/@cloudbyday?source=rss-26cf531617e2------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*PQ1ZOqtkYkZVnI9PoVT9kg.jpeg</url>
            <title>Stories by Shalom Crownwell on Medium</title>
            <link>https://medium.com/@cloudbyday?source=rss-26cf531617e2------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 11:28:58 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@cloudbyday/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[The Server That Could Back Up, But Couldn’t Delete: Building an Automated AWS Backup Pipeline]]></title>
            <link>https://cloudbyday.medium.com/the-server-that-could-back-up-but-couldnt-delete-building-an-automated-aws-backup-pipeline-583c7f245122?source=rss-26cf531617e2------2</link>
            <guid isPermaLink="false">https://medium.com/p/583c7f245122</guid>
            <category><![CDATA[cloud-engineering]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[pipeline]]></category>
            <category><![CDATA[aws-lambda]]></category>
            <category><![CDATA[aws-cloudwatch]]></category>
            <dc:creator><![CDATA[Shalom Crownwell]]></dc:creator>
            <pubDate>Thu, 19 Nov 2026 13:25:38 GMT</pubDate>
            <atom:updated>2026-11-19T13:26:49.674Z</atom:updated>
            <content:encoded><![CDATA[<p>I wanted to build a server that could create backups, upload them to Amazon S3, and do all of that automatically.</p><p>Simple enough, right?</p><p>Well, there was a catch. The server wasn’t allowed to delete the backups it created. It also wasn’t supposed to have a public IP address, and every new backup had to leave a record behind automatically.</p><p>So, this wasn’t just a case of writing a Bash script and scheduling it with cron. I had to think about how the server would access AWS services privately, what permissions it actually needed, and how I could make sure every upload was recorded without having to manually check S3 every time.</p><p>In this article, I’ll walk through how I put the pieces together, the decisions I made along the way, and a few things that didn’t work quite as planned. Also I’ll be using placeholders for some of the commands to avoid exposing sensitive information, so when doing this, you can easily substitute with yours. Thank you</p><h3>First, let’s look at what we’re building</h3><p>Before touching the backup script, I needed to get the architecture right.</p><p>The application server had to stay in a private subnet with no public IP address. I also needed a way to administer it, a secure way to send backups to S3, and a separate process for recording each upload.</p><p>Here’s the overall arrangement:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h8ly3_9eYN_bBAgbBHZAHw.png" /><figcaption><em>The architecture showing the bastion host, private application server, S3 Gateway VPC Endpoint, S3 bucket, Lambda function and DynamoDB audit table.</em></figcaption></figure><p>The idea is that I connect to the bastion host first, then use it to reach the private application server. The application server creates and uploads backups to S3 through a Gateway VPC Endpoint. Whenever a new object is uploaded, S3 triggers a Lambda function, which records the event in DynamoDB.</p><p>Each service has a specific job. More importantly, the application server doesn’t need to be exposed to the internet or given unrestricted permissions just to perform a backup.</p><h3>Setting up the network</h3><p>I started by creating a custom VPC named cloud-exam-vpc, with the CIDR block 10.0.0.0/16.</p><p>Inside it, I created two subnets:</p><ul><li>Public subnet: 10.0.1.0/24</li><li>Private subnet: 10.0.2.0/24</li></ul><p>The bastion host went into the public subnet, while the application server was placed in the private subnet.</p><p>Why two subnets? Because I didn’t want the application server to be directly reachable from the internet. The bastion host would serve as my controlled entry point for administration.</p><p>I also configured separate route tables. The public subnet needed a route to the Internet Gateway, while the private subnet needed to remain isolated from direct internet access.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eZPG0RtJ9tL-jcQiE5MeNQ.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2hpYTsOfYAmk7k80gQ_4rg.jpeg" /><figcaption>The VPC resource map showing the public and private subnets, Internet Gateway, route tables and network layout.</figcaption></figure><p>Next came the security groups.</p><p>For the bastion host, I allowed SSH traffic on port 22 from my own public IP address. For the application server, I allowed SSH only from the bastion host’s security group.</p><p>Notice the difference? I wasn’t allowing SSH from anywhere on the internet to reach my private application server. The security group reference ensured that the bastion was the approved entry point.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/677/1*C658eB5cKkPkc0vcwtPnuA.jpeg" /><figcaption><em>SSH access to the bastion host restricted to my own public IP address.</em></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OvPx6oqQqvaWoA7Vo2cQqg.jpeg" /><figcaption><em>The application server accepts SSH connections from the bastion security group only.</em></figcaption></figure><h3>Getting into a server that has no public IP</h3><p>Now came the part I was already familiar with from my previous bastion host experience: getting into a private EC2 instance without copying my private key onto the bastion.</p><p>I used SSH agent forwarding.</p><p>On my local machine, I started the SSH agent and added my private key:</p><pre>eval &quot;$(ssh-agent -s)&quot;<br>ssh-add ***.pem</pre><p>Then I connected to the bastion using the -A flag:</p><pre>ssh -A ubuntu@10.0.1.229</pre><p>Once inside the bastion, I connected to the application server using its private IP:</p><pre>ssh ubuntu@10.0.2.***</pre><p>The important part here is that my private key stayed on my local machine. Agent forwarding allowed the bastion to use the authentication agent on my computer for the second connection. I didn’t have to upload the .pem file to the bastion.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/699/1*7JnU2pMcv3zf38C_Srkp-Q.jpeg" /><figcaption><em>Terminal evidence showing the SSH connection from the local machine to the bastion and then to the private application server.</em></figcaption></figure><p>With network access sorted, I could finally work on the actual backup process.</p><h3>Giving the application server something to back up</h3><p>I needed some data that would keep changing so I could test whether the backup process was actually capturing new information.</p><p>I created a directory at /var/app/data and placed an application log file inside it. Then I configured a systemd service called data-generator to append a timestamp to the log every 30 seconds.</p><p>The service ran continuously in the background. This meant that whenever a backup was created, there would be fresh log entries to include.</p><p>I checked the service using:</p><pre>sudo systemctl status data-generator --no-pager</pre><p>And checked the generated data with:</p><pre>cat /var/app/data/app.log<br>OR<br>tail -n 8 /var/app/data/app.log</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*rXqYHnDgI_VNiUhLmOxIMA.jpeg" /><figcaption><em>The data-generator service running successfully</em></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/733/1*HC-cbcVQbe3yLztyI3QbVw.jpeg" /><figcaption><em>Timestamped entries being written to the application log</em></figcaption></figure><p>Writing the backup script</p><p>This was where the automation started to take shape.</p><p>I created a Bash script at:</p><p>/usr/local/bin/backup.sh</p><p>It’s job was to compress the application data directory, upload the resulting archive to S3, record the outcome in a local log, and remove the temporary archive after a successful upload.</p><p>Here’s the script:</p><pre>#!/bin/bash<br>set -euo pipefail</pre><pre>TIMESTAMP=$(date +%Y-%m-%d-%H%M)<br>BACKUP_FILE=&quot;/tmp/backup-${TIMESTAMP}.tar.gz&quot;<br>BUCKET=&quot;cloud-exam-backups-crown-2026&quot;<br>LOG_FILE=&quot;/var/log/backup.log&quot;</pre><pre>if tar -czf &quot;$BACKUP_FILE&quot; -C /var/app data; then<br>    if aws s3 cp &quot;$BACKUP_FILE&quot; &quot;s3://${BUCKET}/backups/&quot;; then<br>        echo &quot;$(date): Backup uploaded successfully: $(basename &quot;$BACKUP_FILE&quot;)&quot; &gt;&gt; &quot;$LOG_FILE&quot;<br>        rm -f &quot;$BACKUP_FILE&quot;<br>    else<br>        echo &quot;$(date): Backup upload failed: $(basename &quot;$BACKUP_FILE&quot;)&quot; &gt;&gt; &quot;$LOG_FILE&quot;<br>        exit 1<br>    fi<br>else<br>    echo &quot;$(date): Backup archive creation failed&quot; &gt;&gt; &quot;$LOG_FILE&quot;<br>    exit 1<br>fi</pre><p>A few things are worth pointing out.</p><p>First, tar -czf creates a compressed archive of the data directory. The timestamp in the filename helps distinguish one backup from another.</p><p>Second, aws s3 cp uploads the archive to the backups/ prefix in my S3 bucket.</p><p>I also used set -euo pipefail to make the script stricter about errors and unset variables. I didn&#39;t want a failed backup to quietly look like a successful one.</p><p>Finally, the script removes the temporary archive only after the upload succeeds. If the upload fails, it logs the failure and exits.</p><p>I made the script executable and tested it before scheduling it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/622/1*fsr2uEVYzXZ86518ixVVIw.jpeg" /><figcaption><em>The complete backup script showing archive creation, S3 upload, logging and local cleanup.</em></figcaption></figure><h3>Letting cron handle the repetition</h3><p>I didn’t want to log into the server every few minutes to start a backup manually. That’s what cron is for.</p><p>I added the following line to root’s crontab:</p><pre>*/10 * * * * /usr/local/bin/backup.sh</pre><p>This tells cron to run the script every ten minutes.</p><p>I checked the scheduled job using:</p><pre>sudo crontab -l</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/694/1*KtmXZZIahOrJIPbHfMyMBw.jpeg" /><figcaption><em>The root crontab showing the backup script scheduled to run every ten minutes.</em></figcaption></figure><p>At this point, the server could generate data, package it into an archive and attempt to upload it automatically.</p><p>But there was still an important security question: what exactly was the server allowed to do in S3?</p><h3>The server could upload, but it couldn’t delete</h3><p>I used an IAM role attached to the application EC2 instance rather than configuring permanent AWS access keys on the server.</p><p>Why an IAM role?</p><p>Because I didn’t want long-lived access keys sitting in files or scripts on the instance. With an EC2 instance role, AWS provides temporary credentials to the instance, and I can manage its permissions centrally through IAM.</p><p>I created the role cloud-exam-app-role and attached a policy named cloud-exam-backup-upload-policy.</p><p>The policy granted the server permission to perform s3:PutObject on objects under the bucket&#39;s backups/ prefix.</p><p>It did not grant s3:DeleteObject.</p><p>That distinction was deliberate. The application server needed to create backups, not remove them. Giving it deletion permissions would have defeated one of the main security requirements.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UHjSxtDqeLgP9OwpJ33psA.jpeg" /><figcaption><em>The EC2 IAM policy granting </em><em>s3:PutObject to the designated backup path without granting deletion permission</em></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UyEKvCYBTHzcku-qotcvLw.jpeg" /><figcaption><em>The </em><em>cloud-exam-app-role attached to the private application server.</em></figcaption></figure><p>I tested this by attempting to remove an existing backup through the AWS CLI:</p><pre>aws s3 rm s3://cloud-exam-backups-crown-2026/backups/backup-2026-11-13-0031.tar.gz</pre><p>Instead of deleting the object, AWS returned AccessDenied.</p><p>Perfect. That was exactly what I wanted to see.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q8DoXbVh4FSmY6zgUo44Tw.jpeg" /><figcaption><em>The application server’s attempt to delete an S3 backup denied by IAM permissions.</em></figcaption></figure><h3>Getting to S3 without keeping a NAT Gateway</h3><p>There was another issue I had to consider.</p><p>The application server was in a private subnet. It needed to reach S3, but I didn’t want to keep a NAT Gateway running just to support that one service connection.</p><p>During the setup process, I temporarily used a NAT Gateway to provide outbound internet access while installing the AWS CLI. However, a NAT Gateway comes with ongoing costs, and general internet access wasn’t something the backup process actually needed.</p><p>So I created an S3 Gateway VPC Endpoint and associated it with the private route table.</p><p>A VPC endpoint provides a private path to a supported AWS service. In this case, the Gateway Endpoint allowed the application server to communicate with S3 without routing the traffic through a NAT Gateway.</p><p>This was a better fit for the requirement. The server needed access to S3, not unrestricted access to the public internet.</p><p>After confirming that the endpoint was available and the uploads were working, I deleted the NAT Gateway and released its Elastic IP address.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/644/1*LZeTjdjY4Htaa3qhEN-YCw.jpeg" /><figcaption><em>The private route table containing the S3 prefix-list route through the Gateway VPC Endpoint.</em></figcaption></figure><h3>Making every upload leave a record</h3><p>Now, the backup files were reaching S3, and the application server couldn’t delete them. But how would I know that each new backup had been uploaded without manually checking the bucket?</p><p>This is where Lambda and DynamoDB came in.</p><p>I created a DynamoDB table named backup-log and a Lambda function named cloud-exam-backup-logger.</p><p>I then configured an S3 event notification to invoke the Lambda function whenever a new object was created under the backups/ prefix.</p><p>The Lambda function received the S3 event, extracted the bucket name, object key, event time and event type, and wrote those details into DynamoDB.</p><p>In other words, the upload itself triggered the audit record. I didn’t need to run a second script from the application server to tell DynamoDB that a backup had been created.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BnIkG5vIROhFQWqLuZE_hw.jpeg" /><figcaption><em>The S3 event notification configured to invoke the backup logger when objects are created under the </em><em>backups/ prefix.</em></figcaption></figure><p>There was a small permissions problem here, though.</p><p>My Lambda function was being invoked, but the DynamoDB write was failing with an AccessDenied error. Initially, the function was using an automatically generated execution role that didn&#39;t have the required permission to write to my table.</p><p>I traced the problem to the Lambda execution role. The S3 trigger was not the issue; the function simply didn’t have permission to complete the next step.</p><p>I changed the function to use my intended cloud-exam-lambda-role, which had permission to perform dynamodb:PutItem on the backup-log table, along with the permissions needed to publish logs to CloudWatch.</p><p>After that change, the function started processing the events successfully.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*c1vOAeFYIuXT3NiwUse7rg.jpeg" /><figcaption><em>The Lambda function using </em><em>cloud-exam-lambda-role with permissions for DynamoDB writes and CloudWatch logging.</em></figcaption></figure><p>I checked CloudWatch to confirm that the function was processing the events. The successful executions included messages showing the backup object keys being logged.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JgHtQxQdevQQfrwjMOmXJw.jpeg" /><figcaption><em>CloudWatch log output showing successful backup event processing.</em></figcaption></figure><p>And, of course, I checked DynamoDB itself.</p><p>The table contained records for the uploaded backups, including their object keys, timestamps and event types.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IhKrid_Dx5UKfOuNK5LcyA.jpeg" /><figcaption><em>DynamoDB records created automatically by the Lambda function after S3 backup uploads.</em></figcaption></figure><h3>The final test: removing the NAT Gateway</h3><p>I wanted to verify that the S3 Gateway Endpoint was actually doing its job, not just sitting there looking useful in the route table.</p><p>So after deleting the NAT Gateway, I tried accessing an external website from the private application server:</p><pre>curl -m 5 https://example.com</pre><p>The request timed out.</p><p>That was expected. Without the NAT Gateway, the private server no longer had the general outbound internet route it previously used.</p><p>But then I ran the backup script again:</p><pre>sudo /usr/local/bin/backup.sh</pre><p>And the upload succeeded.</p><p>That was the result I was looking for. The server could no longer reach that external website, but it could still upload its backup to S3 through the Gateway Endpoint.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/686/1*BcKNDHLLIHDEhLM4fGsrSg.jpeg" /><figcaption><em>The failed external request from the private application server after the NAT Gateway was removed.</em></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*23mQVhBqBbTn3JPHEjadhQ.jpeg" /><figcaption><em>The backup script successfully uploading to S3 despite the absence of the NAT Gateway.</em></figcaption></figure><p>Getting the pipeline working was one thing. Thinking about how it would behave in an actual company environment is another.</p><p>There are a few improvements I would make.</p><p><strong>S3 Versioning:</strong> I would enable versioning on the backup bucket. This would provide another layer of recovery if an object were accidentally overwritten or deleted by an authorised user.</p><p><strong>Lifecycle rules:</strong> Backups can accumulate quickly. I would configure lifecycle policies based on the organisation’s retention requirements, moving older backups to more cost-effective storage classes or expiring them only when the retention policy permits.</p><p><strong>Monitoring and alerts:</strong> A successful backup should not be something I assume happened because cron was configured. I would add monitoring and alerts for failed uploads, missing expected backups, Lambda errors and unusual activity.</p><p><strong>Encryption and retention protection:</strong> I would review encryption settings and key management, and consider S3 Object Lock where stronger retention controls or compliance requirements justified it.</p><p><strong>Recovery testing:</strong> Finally, I would regularly test restoring data from a backup. A backup pipeline that creates files but cannot restore them when needed isn’t much of a backup strategy.</p><h3>So, what did I actually build?</h3><p>I started with a private application server that needed to back up its data automatically. By the end, I had a server that could generate data, package it, upload it to S3, and trigger an automatic audit record in DynamoDB.</p><p>The server had no public IP address. It used an EC2 IAM role instead of stored access keys. Its permissions allowed uploads but denied deletion. And after removing the NAT Gateway, it could still reach S3 through a Gateway VPC Endpoint.</p><p>The part I found particularly useful was seeing how the services depended on one another. IAM permissions, network routes, S3 event notifications and Lambda execution permissions all had to be correct for the complete workflow to function.</p><p>It wasn’t enough to make each individual service work. I had to make them work together.</p><p>And I think that’s one of the more interesting things about working with cloud infrastructure. Sometimes the real lesson isn’t getting a service running. It’s understanding exactly what that service should be allowed to do, what it shouldn’t be allowed to do, and how to prove that your design behaves the way you intended.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=583c7f245122" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[From SSH Errors to a Working Connection: My AWS Bastion Host Experience]]></title>
            <link>https://medium.com/devops-ai-decoded/from-ssh-errors-to-a-working-connection-my-aws-bastion-host-experience-dcd8dec4b8ca?source=rss-26cf531617e2------2</link>
            <guid isPermaLink="false">https://medium.com/p/dcd8dec4b8ca</guid>
            <category><![CDATA[cloud-security]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <dc:creator><![CDATA[Shalom Crownwell]]></dc:creator>
            <pubDate>Sun, 25 Oct 2026 01:49:20 GMT</pubDate>
            <atom:updated>2026-10-25T02:09:14.817Z</atom:updated>
            <content:encoded><![CDATA[<h3>How I Accessed a Private EC2 Instance Through a Bastion Host on AWS</h3><p><em>Building a two-tier network, troubleshooting SSH authentication, and using Proxy-Jump from Windows PowerShell</em></p><h3>1. Introduction</h3><p>One of the things I am learning as a Cloud Engineering student is that launching a virtual machine is only one part of working with cloud infrastructure. You also need to understand how resources communicate, how access is controlled, and how to troubleshoot when a connection does not work as expected.</p><p>For this assignment, I needed to build a two-tier network on Amazon Web Services (AWS). The requirement was to create a public subnet and a private subnet in the same Availability Zone, launch a bastion host in the public subnet, and access a private EC2 instance through that bastion.</p><p>The challenge was not just creating the resources. I also had to get SSH working between my Windows computer and the private instance without assigning the private instance a public IP address or copying its private key onto the bastion.</p><p>In this article, I will walk through the architecture, the AWS configurations, the connection problems I encountered, and the solution that finally worked.</p><h3>2. Understanding the architecture</h3><p>Before creating the resources, I needed to understand why the bastion host was necessary.</p><p>A <strong>bastion host</strong> is a server that acts as a controlled entry point into a private network. Instead of allowing direct SSH access from the internet to every server, you allow access to the bastion and then use it to reach the private resources.</p><p>My architecture consisted of:</p><ul><li>My Windows computer, where I ran SSH commands in PowerShell.</li><li>A bastion EC2 instance in the public subnet.</li><li>A private EC2 instance in the private subnet.</li><li>A VPC containing both subnets.</li><li>An Internet Gateway and route tables to control network traffic.</li><li>Separate security groups and key pairs for the two instances.</li></ul><p>The bastion had a public IP address, while the private EC2 instance did not.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sRnbYfAquHutr-sMXYhLwA.jpeg" /><figcaption><em>Figure 1. The intended connection path from a local computer through a bastion host to a private EC2 instance.</em></figcaption></figure><p>The important distinction is that the private instance did not need to be directly reachable from the internet. It only needed to accept SSH connections from the bastion’s security group.</p><h3>3. Creating the VPC and subnets</h3><p>I worked in the AWS Europe (Stockholm) region, identified as eu-north-1.</p><p>I created a custom VPC named cloud-assignment-3-vpc with the CIDR block 10.0.0.0/16. This provided the private IPv4 address space for the network.</p><p>I then created two subnets:</p><p><strong>Public Subnet</strong></p><ul><li><strong>Resource Name:</strong> cloud-assignment-3-public-subnet</li><li><strong>CIDR Block:</strong> 10.0.1.0/24</li><li><strong>Purpose:</strong> Hosts the bastion host</li></ul><p><strong>Private Subnet</strong></p><ul><li><strong>Resource Name:</strong> cloud-assignment-3-private-subnet</li><li><strong>CIDR Block:</strong> 10.0.2.0/24</li><li><strong>Purpose:</strong> Hosts the private EC2 instance</li></ul><p>Both subnets were placed in the same Availability Zone, as required by the assignment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xc06kZnvNlE4x26yS5ZUgQ.jpeg" /><figcaption><em>Figure 2. The custom VPC and its public and private subnets.</em></figcaption></figure><p>A subnet’s CIDR block determines the range of IP addresses available within it. Using separate ranges also made it easier to distinguish the public and private tiers.</p><h3>4. Configuring the Internet Gateway and route tables</h3><p>Creating a public subnet does not automatically make it publicly accessible. The subnet needs an appropriate route, and the instance also needs a public IP address and suitable security rules.</p><p>I created an Internet Gateway named cloud-assignment-3-igw and attached it to my custom VPC.</p><p>Next, I configured the public route table, cloud-assignment-3-public-rt, with the following routes:</p><ul><li><strong>Destination:</strong> 10.0.0.0/16 | <strong>Target:</strong> Local</li><li><strong>Destination:</strong> 0.0.0.0/0 | <strong>Target:</strong> Internet Gateway</li></ul><p>The local route allows communication within the VPC’s IPv4 network. The default route sends traffic destined for other IPv4 networks towards the Internet Gateway.</p><p>I associated this route table with the public subnet.</p><p>I also used a separate route table for the private subnet. It retained the local VPC route without a default route to the Internet Gateway. I did not create a NAT Gateway for this assignment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XWUidwbAO3Z5zRNLUI3FLg.jpeg" /><figcaption><em>Figure 3. The public route table, showing the local route and the default route to the Internet Gateway.</em></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tvprglKXUg-LFknwgTXKcA.jpeg" /><figcaption><em>Figure 4. The private route table, showing its local route and association with the private subnet.</em></figcaption></figure><p>These screenshots matter because they demonstrate the difference between the two network tiers. A subnet is not public merely because of its name; the routing configuration is part of what makes it public.</p><h3>5. Configuring the security groups</h3><p>The next step was to control which resources could connect to each instance.</p><p>I created two security groups.</p><h3>Bastion security group</h3><p>The bastion security group, cloud-assignment-3-bastion-sg, allowed inbound SSH traffic on TCP port 22 from my own public IP address, using a /32 CIDR to restrict the rule to that single IPv4 address.</p><h3>Private instance security group</h3><p>The private instance security group, cloud-assignment-3-private-sg, allowed inbound SSH traffic on TCP port 22 with the bastion security group as the source.</p><p>This is different from allowing SSH from the bastion’s private IP address alone.</p><p><strong>Bastion Setting:</strong></p><ul><li>SSH port<strong>:</strong> TCP 22</li><li>Inbound source: My public IP /32</li><li>Public IP: Yes</li></ul><p><strong>Private instance Setting:</strong></p><ul><li>SSH port<strong>:</strong> TCP 22</li><li>Inbound source: Bastion security group</li><li>Public IP: No</li></ul><p>I left the default outbound rules in place for the assignment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kFKFt5eeqckGREX_1jEmXQ.jpeg" /><figcaption><em>Figure 5. The bastion permits SSH from my public IP address only</em></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nl2tewD-mrrYRicamQs6xA.jpeg" /><figcaption><em>Figure 6. The private instance accepts SSH from the bastion security group</em></figcaption></figure><p>These rules create two separate access checks. My computer must be allowed to reach the bastion, and the bastion must be allowed to reach the private instance.</p><h3>6. Launching the EC2 instances</h3><p>I launched two Ubuntu EC2 instances.</p><p>The bastion instance, named cloud-assignment-3-bastion, was placed in the public subnet and assigned a public IP address.</p><p>The private instance, named cloud-assignment-3-private, was placed in the private subnet without a public IP address.</p><p>I used different key pairs for the two instances:</p><ul><li>cloud-assignment-3.pem for the bastion.</li><li>cloud-assignment-private.pem for the private instance.</li></ul><p>I kept both private key files on my Windows computer. I did not need to upload either key to the bastion.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1008/1*0mI1iS8w1cAo_YYJWru2bA.jpeg" /><figcaption><em>Figure 7. The bastion instance showing its name, public IP address, VPC, subnet, and security group.</em></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*r-N93yDwJKQ_6jbsSjcj8w.jpeg" /><figcaption><em>Figure 8. The private instance showing its private IP address, private subnet, VPC, and absence of a public IPv4 address.</em></figcaption></figure><p>Do not assume that the IP addresses will remain the same indefinitely. The addresses shown in these screenshots describe the instances at the time the screenshots were captured.</p><h3>7. The first connection: reaching the bastion</h3><p>I was working from Windows and using PowerShell on my computer.</p><p>My first goal was to establish an SSH connection to the bastion using its public IP address and the bastion key.</p><pre>$bastionKey = &quot;$HOME\Downloads\cloud-assignment-3.pem&quot;<br>ssh -A -i &quot;$bastionKey&quot; ubuntu@16.16.78.32</pre><p>That connection worked.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/680/1*1tAL-tcQzprw0NChLds5pw.jpeg" /></figure><p>I also experimented with SSH agent forwarding using ssh -A. This option allows a remote SSH session to use the local SSH agent for authentication without transferring the private key itself to the remote machine.</p><p>However, successfully reaching the bastion did not guarantee that I could authenticate to the private instance. When I tried the second connection from inside the bastion, SSH returned Permission denied (publickey).</p><p>The verbose SSH output also showed an agent communication error. That helped distinguish the problem from a simple network routing failure: the first SSH connection worked, but the second connection was not successfully using the intended authentication identity.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/670/1*OYD7Righxib7gvp3Rzyscw.jpeg" /></figure><p>This was an important troubleshooting lesson. SSH connectivity and SSH authentication are related, but they are not the same thing.</p><h3>8. The solution: SSH Proxy-Jump from PowerShell</h3><p>The approach that finally worked was <strong>SSH Proxy-Jump</strong>, configured on my Windows computer.</p><p>Proxy-Jump allows SSH to connect to an intermediate host before reaching the destination. Instead of manually opening a session to the bastion and then starting a second SSH session, I could tell my local SSH client how to reach the private host through the bastion.</p><p>Because I was using different key pairs, I configured separate host entries in my local SSH configuration file. Each entry specified the relevant hostname, username, and identity file.</p><p>The configuration followed this pattern:</p><pre>Host assignment-bastion<br>    HostName 16.16.78.32<br>    User ubuntu<br>    IdentityFile C:/Users/d/Downloads/cloud-assignment-3.pem<br>    IdentitiesOnly yes</pre><pre>Host assignment-private<br>    HostName 10.0.2.121<br>    User ubuntu<br>    IdentityFile C:/Users/d/Downloads/cloud-assignment-private.pem<br>    IdentitiesOnly yes<br>    ProxyJump assignment-bastion</pre><p>The IP addresses above are examples from my setup at the time of connection. If an automatically assigned public IP changes, the bastion’s HostName must be updated. The private instance&#39;s IP should be checked in the AWS console before relying on it in the configuration.</p><p>With the host entries configured, the connection command became:</p><pre>ssh assignment-private</pre><p>SSH used the private host’s configuration, connected through assignment-bastion, and authenticated to the destination using the private instance&#39;s key.</p><p>This was the successful method. Both private keys remained on my computer, and the private instance remained without a public IP address.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/571/1*68P2gZBkD3GjJnma1FKOfg.jpeg" /><figcaption><em>Figure 9. PowerShell successfully reaching the private EC2 instance through the bastion.</em></figcaption></figure><h3>9. Troubleshooting lessons I learned</h3><p>Getting the connection to work also taught me to check a few things before assuming that the whole network was broken.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/542/1*KjjgbwLZdBFYWzUPF7zQhg.jpeg" /></figure><h3>Lesson 1: Your public IP address can change</h3><p>There are two different IP addresses to keep in mind.</p><p>First, an EC2 instance launched with an automatically assigned public IPv4 address can receive a different public IP after it is stopped and started. An Elastic IP is a separate option for retaining a static public IPv4 address.</p><p>Second, the public IP address assigned to your own internet connection can also change. If your internet provider changes your public IP, the bastion security group may still contain your previous address.</p><p>If the bastion’s inbound SSH rule still allows only the old address, a new connection from your computer may time out.</p><p><strong>What to do:</strong> Check the bastion’s current public IP in the EC2 console. Then check your own current public IP and update the bastion security group’s SSH source to the current My IP value if it has changed. If the bastion&#39;s public IP changed, update the SSH configuration as well.</p><p>Do not solve this by opening port 22 to 0.0.0.0/0. That would allow SSH attempts from anywhere on the internet.</p><h3>Lesson 2: Recheck security-group rules when returning to a project</h3><p>If you leave an instance stopped or return to an assignment after several days, do not assume that every detail is still correct.</p><p>For the bastion, check that the SSH inbound rule matches your current public IP. For the private instance, check that SSH still uses the bastion security group as its source.</p><p>Refreshing the AWS console page alone does not update an outdated rule. If the source IP has changed, edit the rule and save the new value.</p><h3>Lesson 3: A timeout and a public-key error mean different things</h3><p>A connection timeout often indicates that the connection is not reaching the destination successfully. Possible causes include a stopped instance, an incorrect public IP, a stale inbound security-group rule, or a routing problem.</p><p>By contrast, Permission denied (publickey) indicates that the SSH connection reached the authentication stage but the server did not accept the offered key or identity.</p><p>This distinction helped me avoid treating every SSH error as the same problem.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/664/1*JxUiFdHY2-VKwTxpykv9JQ.jpeg" /><figcaption>A new public ip after restarting my instance</figcaption></figure><h3>Lesson 4: Keep separate keys organized</h3><p>Using separate key pairs meant that I had to make sure SSH selected the correct identity for each host.</p><p>The bastion key was for the first host, while the private instance key was for the destination. Configuring these identities explicitly in the local SSH configuration made the final connection easier to repeat.</p><p>Keeping the keys on my computer also avoided the additional risk of placing a private key file on the bastion.</p><h3>10. Final thoughts</h3><p>This assignment helped me understand how network architecture, routing, security groups, and SSH authentication work together.</p><p>I learned that a private EC2 instance does not need a public IP address to be accessed by an authorized administrator. The bastion provides the entry point, the security groups restrict the permitted connections, and Proxy-Jump allows SSH to handle the intermediate hop.</p><p>I also learned the importance of distinguishing network errors from authentication errors, checking whether public IP addresses have changed, and configuring the correct key for each host.</p><p>The biggest takeaway for me was that successful cloud infrastructure is not just about creating resources. It is also about understanding how those resources connect, controlling access, and troubleshooting each layer methodically.</p><p>My final setup allowed me to access the private EC2 instance from my Windows computer through the bastion without copying the private keys onto it.</p><p>That is the practical value of a bastion host: <strong>a controlled route into a private network without exposing the private server directly to the internet.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dcd8dec4b8ca" width="1" height="1" alt=""><hr><p><a href="https://medium.com/devops-ai-decoded/from-ssh-errors-to-a-working-connection-my-aws-bastion-host-experience-dcd8dec4b8ca">From SSH Errors to a Working Connection: My AWS Bastion Host Experience</a> was originally published in <a href="https://medium.com/devops-ai-decoded">Devops &amp; AI Hub</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>