<?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 MUHAMMAD AHAD USMAN on Medium]]></title>
        <description><![CDATA[Stories by MUHAMMAD AHAD USMAN on Medium]]></description>
        <link>https://medium.com/@ahadusman377?source=rss-fcd0b31a42c6------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*VjCnoXAu8Z7AvYoRQ-tAog.png</url>
            <title>Stories by MUHAMMAD AHAD USMAN on Medium</title>
            <link>https://medium.com/@ahadusman377?source=rss-fcd0b31a42c6------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 14:16:34 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ahadusman377/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[Linux Server Hardening: A Production Baseline Built From a Fresh Ubuntu Box]]></title>
            <link>https://medium.com/@ahadusman377/linux-server-hardening-a-production-baseline-built-from-a-fresh-ubuntu-box-725eee9b31f9?source=rss-fcd0b31a42c6------2</link>
            <guid isPermaLink="false">https://medium.com/p/725eee9b31f9</guid>
            <category><![CDATA[ubuntu]]></category>
            <category><![CDATA[system-administration]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[devops]]></category>
            <dc:creator><![CDATA[MUHAMMAD AHAD USMAN]]></dc:creator>
            <pubDate>Thu, 01 Oct 2026 04:09:48 GMT</pubDate>
            <atom:updated>2026-10-01T04:09:48.477Z</atom:updated>
            <content:encoded><![CDATA[<p><em>A full walkthrough of locking down a fresh Ubuntu server for production, including a real troubleshooting detour, and proving every core Linux admin skill still works entirely from the terminal</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hC_cxo_UA6kcnoSPbUkKLQ.png" /></figure><p>A brand new server is, by default, the least trustworthy thing on your network. Root login is open, passwords are enough to get in, no firewall is watching the door, and nothing is logging who tried what. That’s not a flaw in Ubuntu, it’s just the honest state of a machine nobody has configured yet. The work of turning “a server exists” into “a server is safe to put in production” is almost entirely invisible once it’s done well, which is exactly why it’s worth documenting while it’s happening.</p><p>I took a fresh Ubuntu virtual machine through a full hardening pass: locked down SSH, set up least privilege user accounts, configured a firewall and brute force protection (hitting a real configuration error along the way), then used that same hardened server to run through the core Linux administration skills any admin needs on hand. Here’s the whole thing, command by command.</p><h3>Part 1: Server hardening and security baseline</h3><h4>Step 1: Updating the system and installing essential tools</h4><p>Every hardening pass starts with a clean, current system. I ran sudo apt update to refresh the local package repository cache, pulling the latest version metadata from Ubuntu&#39;s official archive mirrors so the package manager knew about the newest available updates and security patches.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2FIyjRmQgYPD4yLT1VHaXQ.png" /></figure><p>Next, sudo apt upgrade -y downloaded and installed all available system upgrades, with -y skipping manual confirmation prompts. Packages including linux-firmware, libyelp0, and yelp were upgraded to their latest versions, and the process finished by regenerating the initial RAM filesystem (initramfs) to finalize the patching.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NYeHtKwlCqhBbhM8pmLT1Q.png" /></figure><p>With the base system current, I installed the actual security tooling: sudo apt install openssh-server ufw fail2ban -y. That one command pulled in OpenSSH for remote management, UFW for the firewall, and Fail2ban for intrusion prevention, resolving dependencies like python3-pyinotify and whois automatically.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FJ1EivFRaTSPiz1wLhscVg.png" /></figure><p>The installation continued by unpacking each package in sequence, and systemd registered the new services as it went, creating symlinks so ssh.socket and ssh.service would activate automatically on boot.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9m0dmG913rtwc_nSA621IQ.png" /></figure><p>The installation finished cleanly: Fail2ban’s own regex test suite ran through some expected warnings, man page and UFW triggers processed without errors, and the terminal prompt returned smoothly, confirming every baseline security package was in place.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bGbWW_bFzYuRjWewsRkaqQ.png" /></figure><h4>Step 2: Configuring least privilege user and group management</h4><p>Root should never be the account doing daily work. I started by creating a dedicated administrative group with sudo addgroup sysadmins. Ubuntu assigned it GID 1001 automatically within the standard system range, a small but deliberate piece of enforcing least privilege access control from the start.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/574/1*Cw3M4N1yAZv156aGL2gsag.png" /></figure><p>Next, sudo adduser secadmin created a dedicated system administrator account. The password prompt rejected a few attempts for being too simplistic or containing the username, standard dictionary check behavior, before accepting a secure password. The home directory (/home/secadmin) initialized automatically from the standard /etc/skel template, and the account was added to its default supplemental group as part of the same process.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/950/1*ofMXpps4U3ofeMSXI4fvxA.png" /></figure><p>I then ran sudo usermod -aG sysadmins,sudo secadmin to grant secadmin both administrative and sudo rights, followed by sudo passwd -l root to lock the root account&#39;s password directly, closing off any direct console or brute force root login attempt. Running groups secadmin confirmed the account belonged to secadmin, sudo, users, and sysadmins.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/710/1*ExNvAqRymzP55LqZPEX-Zg.png" /></figure><h4>Step 3: Setting up SSH key based authentication</h4><p>Passwords over SSH are a weak point the moment they’re optional. Switching to the secadmin user via su - secadmin, I generated a 4096 bit RSA key pair with ssh-keygen -t rsa -b 4096, appended the public key to ~/.ssh/authorized_keys, then locked the permissions down with chmod 700 on the ~/.ssh directory and chmod 600 on the authorized_keys file itself, so no other local user could read or modify the authentication keys.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/819/1*CQVMZgyk4TMeKb1gDKDgLw.png" /></figure><h4>Step 4: Hardening the SSH server configuration</h4><p>With keys in place, the server configuration itself needed tightening. I opened the daemon’s config file with sudo nano /etc/ssh/sshd_config, using elevated privileges to modify this protected file directly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/605/1*ZGGE_ZU3EHq0Qxc4EV6uXQ.png" /></figure><p>Inside the file, I set the parameters that actually matter for lockdown: PermitRootLogin no to block any direct root login over the network, PasswordAuthentication no to force cryptographic key based logins and eliminate password guessing entirely, PubkeyAuthentication yes to confirm key based auth stays enabled, and MaxAuthTries 3 to cap failed login attempts per connection.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wXmSoGeEUf5az6tgQxVSoQ.png" /></figure><p>Before restarting anything, I validated the syntax with sudo sshd -t, which surfaced a missing privilege separation directory warning. I resolved it with sudo mkdir -p /run/sshd, ran sudo sshd -t again with zero errors, then restarted the daemon with sudo systemctl restart ssh to apply the hardened configuration.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/578/1*fM4eYzyXee0TWAHvHk87Wg.png" /></figure><h4>Step 5: Configuring firewall rules with UFW</h4><p>An open server with hardened SSH is still an open server everywhere else. I set UFW’s default policies to deny incoming and allow outgoing, then explicitly opened only the ports actually needed: 22/tcp for SSH, 80/tcp for HTTP, and 443/tcp for HTTPS. Running sudo ufw enable made the rules persist across reboots, and sudo ufw status verbose confirmed active enforcement across both IPv4 and IPv6.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/728/1*2jd8pLGrUXGbdS3ag_fEXg.png" /></figure><h4>Step 6: Configuring Fail2ban, and fixing a real configuration error</h4><p>A firewall stops unknown ports, but it doesn’t stop someone hammering port 22 with password guesses. I created a local configuration copy with sudo cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local, edited it, and restarted the service. The first attempt didn&#39;t work: sudo fail2ban-client status sshd returned an error, Failed to access socket path: /var/run/fail2ban/fail2ban.sock. Is fail2ban running? I edited the file again and tried a fresh restart, but hit the exact same socket error a second time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IFNfxdUhcEmBSqbiJ28QPA.png" /></figure><p>Rather than keep retrying the same broken approach, I removed jail.local entirely with sudo rm /etc/fail2ban/jail.local and created a scoped override at /etc/fail2ban/jail.d/sshd.local instead, the more targeted, recommended way to configure a single jail without touching the whole default file. That fixed it immediately: sudo systemctl restart fail2ban succeeded, and sudo fail2ban-client status sshd returned a clean report, the SSH jail active, watching the systemd journal, zero failures and zero bans at that point.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Yax2QXzE7TX0EdmaWyJwHw.png" /></figure><p>That detour is worth pausing on. The fix wasn’t a bigger hammer, it was switching to the correct configuration pattern instead of repeating the same broken one. Here’s the shape of everything Part 1 builds, once all four layers are actually working:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OplHHAP38M16ZOvBdnS-Yg.png" /></figure><h3>Part 2: Core Linux administration exercises</h3><p>Hardening a server proves you can lock it down. Running it day to day proves you can actually operate it. The rest of this task worked through the core admin skills that come up constantly once a server is live.</p><h4>Section A and B: Navigation, file operations, and permissions</h4><p>Starting from pwd, I built a nested directory structure with mkdir -p ~/practice/project/logs, created sample and hidden files (file1.txt, file2.txt, .hidden_config), and listed them with ls -lhA. From there I practiced the core file operations: copying file1.txt to logs/backup.txt, moving file2.txt to logs/file2_archived.txt, locating all text files with find, and safely removing the archived copy with rm.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/882/1*wPRRWoFYkqKOAdh8NmMr3w.png" /></figure><p>For permissions, I created ~/practice/script.sh, assigned ownership to secadmin:sysadmins with sudo chown, applied octal permissions with sudo chmod 750 (read, write, and execute for the owner, read and execute for the group, nothing for everyone else), tested symbolic mode separately with chmod u+x, then confirmed the final state with ls -l: -rwxr-x---, ownership exactly as intended.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/996/1*yeQOw-JnnnKJluO0vBjBPw.png" /></figure><h4>Section C: Text processing and log analysis</h4><p>I built a sample log file at ~/practice/app.log using cat &lt;&lt; &#39;EOF&#39;, containing a mix of INFO, WARNING, and ERROR lines. From there: grep &quot;ERROR&quot; filtered the critical entries, grep -c &quot;ERROR&quot; counted them (2 total), awk &#39;{print $1, $2, $3}&#39; extracted specific timestamp and log level fields, and sed &#39;s/WARNING/CRITICAL/g&#39; rewrote log severity strings on the fly, all in one continuous sequence against the same file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/929/1*3rErV4VUXhInB4Z47ZKbyA.png" /></figure><p>Separately, sudo tail -n 20 /var/log/syslog pulled the last 20 real system log entries, surfacing background activity from gnome-shell, sysstat, and periodic CRON executions, confirming the system&#39;s own logs were populated and readable.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*axLhbMl_uSJnGBhsLNb1cA.png" /></figure><h4>Section D: Process management and resource monitoring</h4><p>I ran ps aux | head -n 10 to inspect the top 10 rows of the active process table: user, PID, CPU and memory percentages, and running commands like /sbin/init splash and various kernel worker threads, confirming the ability to inspect what&#39;s actually consuming resources from a static snapshot.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J3mKfttFfj-5Ytakq9oGSw.png" /></figure><p>Launching top moved from that static snapshot to a live one.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/459/1*ubMRHEfnnGbMtfOY2R3_gw.png" /></figure><p>The live display showed system uptime, load averages, memory statistics (5921 MB total, 3017 MB free at the time), swap utilization, and processes sorted dynamically by resource consumption, a full real time health check in one view.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3DIdvH-rFLm-yoLFTuHuEw.png" /></figure><p>free -m broke memory usage down in megabytes (about 1.3 GB used, 4.6 GB available), and df -h checked disk capacity in human readable form, confirming the root partition (/dev/sda2) had 12 GB available at 52% utilization.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/1*vnmzm-EDmSGKIMAZxHvBJg.png" /></figure><p>I closed this section by auditing the SSH service itself: systemctl status ssh showed its initial state, sudo systemctl restart ssh performed a routine restart, and a follow up status check confirmed it changed to Active: active (running), actively listening on port 22, proving services can be monitored and maintained live through systemctl.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/983/1*Kax4ivugOCtapKayR-VN4Q.png" /></figure><p>Here’s the same core toolkit, grouped by what each command actually verifies:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*btRnXl_D_3J_HWBAW4Bi_A.png" /></figure><h4>Section E: Networking and troubleshooting</h4><p>ip addr show displayed every local network interface: the loopback (lo) at 127.0.0.1, and the primary interface (enp0s3) in the UP state with the assigned address 10.0.2.15/24, confirming the network layer was correctly bound.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rAB8lpgYoX2ttWOymIHXDw.png" /></figure><p>ping -c 4 8.8.8.8 tested external reachability against Google&#39;s public DNS: 4 ICMP echo requests, 0% packet loss, average round trip time around 84 ms, confirming stable outbound connectivity.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/705/1*mb5hn_oaeWFPiCvMZalX5w.png" /></figure><p>sudo ss -tulpn listed every listening socket on the server: port 22 for sshd, the local DNS resolver on port 53, and CUPS on port 631, each tied to its process ID and name, confirming only expected services were actually listening.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oKi1QZFuIl-eX-D0hSIULA.png" /></figure><p>curl -I https://ubuntu.com inspected the HTTP response headers from a real external server. The first line, HTTP/2 200, confirmed successful HTTPS communication, and the response revealed server metadata including the server type (nginx) and an extensive content security policy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e5SbrGSrPuw96zMawNljwQ.png" /></figure><p>The trailing portion of that same response showed strict security headers like strict-transport-security and x-content-type-options: NOSNIFF, confirming the complete header stream came through cleanly with no transport errors.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ShBPsTYDRIs5frINqdHzmw.png" /></figure><h4>Section F: Package management and automation</h4><p>apt search nginx queried the full repository for anything Nginx related, returning matches like anonip, centreon-plugins, and collectd-core across the configured software archives.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/824/1*pXI4x4s6olK3cHgOyziJng.png" /></figure><p>The tail end of that same search surfaced additional utilities, including python3-certbot-nginx and the tryton-server family of packages, each with its version number and a short description straight from the repository metadata.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/813/1*qFZMAMZepbLn4nByoDqdOg.png" /></figure><p>To demonstrate clean removal, sudo apt purge nginx -y removed the package and its configuration, and sudo apt autoremove -y cleared out orphaned dependencies afterward. The system removed 4 unneeded packages (libfwupd2, libgl1-amber-dri, and others), freeing 16.7 MB of disk space in the process.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/872/1*SCgdOITJZfUXqg6k3rNjsQ.png" /></figure><h3>Part 3: Task scheduling with cron</h3><p>Manual maintenance doesn’t scale, so the last piece was automating a routine cleanup task. crontab -e initialized a user crontab for the first time, prompting for an editor choice between Nano, Vim, and Ed. I chose Nano (option 1) for the most straightforward editing experience.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/638/1*fjfaepcXPnxqCP1KOIyuRg.png" /></figure><p>Inside Nano, I added one scheduled job at the bottom of the file: 0 0 * * * /usr/bin/find /tmp -type f -mtime +7 -delete, a nightly midnight task that deletes anything in /tmp older than 7 days, standard cron syntax for routine housekeeping.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/811/1*pZ09dpIo-MlsCiNYarrmEA.png" /></figure><p>After saving and exiting, crontab -l listed the file back out, confirming the job was properly installed and the automated /tmp cleanup was live under the system cron daemon.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/778/1*8khtMmiCmkSuaM63sVZn2g.png" /></figure><h3>Part 4: Verification and final audit</h3><p>None of this counts until it’s actually verified, not assumed. The final audit ran through every hardening decision one more time, directly: grep checks against /etc/ssh/sshd_config confirmed both PermitRootLogin no and PasswordAuthentication no were genuinely in effect. sudo ufw status verified the firewall was active with exactly ports 22, 80, and 443 allowed. sudo systemctl is-active fail2ban returned active, confirming the intrusion prevention system that took two attempts to configure correctly was actually running. And sudo -l -U secadmin confirmed full sudo privileges ((ALL : ALL) ALL) were correctly assigned to the one account meant to have them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hG2kZZTC-QOFOwBtsuSH4A.png" /></figure><h3>The takeaway</h3><p>Hardening a server isn’t one big decision, it’s a series of small, specific ones: which account can log in, which ports are open, which authentication method is allowed, which service is watching for abuse. None of those decisions are complicated in isolation. What makes a baseline actually solid is doing all of them together, then checking every single one again at the end instead of trusting that they held, and being willing to abandon a broken configuration approach rather than repeating it, the way the Fail2ban socket error in Part 1 eventually got resolved.</p><p>The second half of this exercise matters just as much as the first. A hardened server that nobody can actually operate isn’t more secure, it’s just less useful. Being fluent in the same terminal for permissions, logs, processes, networking, and scheduling is what turns “I locked it down” into “I can run this in production.”</p><p>Next up: extending this baseline with centralized log shipping, so the audit trail survives even if the server itself doesn’t.</p><p><em>If you’re building your own baseline, don’t skip the final audit step, even when you’re confident everything worked. Configuration drift is quiet, and the whole value of a checklist is that it doesn’t rely on memory. And if something like Fail2ban refuses to start the same way twice, that’s usually a sign to change the approach, not repeat it a third time.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=725eee9b31f9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Activating CloudTrail: From Raw S3 Logs to a Queryable Audit Trail]]></title>
            <link>https://medium.com/@ahadusman377/activating-cloudtrail-from-raw-s3-logs-to-a-queryable-audit-trail-185521fca029?source=rss-fcd0b31a42c6------2</link>
            <guid isPermaLink="false">https://medium.com/p/185521fca029</guid>
            <category><![CDATA[aws-cloudtrail]]></category>
            <category><![CDATA[aws-s3]]></category>
            <category><![CDATA[aws-athena]]></category>
            <category><![CDATA[ahad-usman]]></category>
            <dc:creator><![CDATA[MUHAMMAD AHAD USMAN]]></dc:creator>
            <pubDate>Thu, 17 Sep 2026 17:25:25 GMT</pubDate>
            <atom:updated>2026-09-17T17:25:25.036Z</atom:updated>
            <content:encoded><![CDATA[<p><em>A walkthrough of setting up full API auditing on AWS, hitting a wall in the console, and fixing it with Athena instead of giving up on the search</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T-OgCEVwsfeGqLjHh64WLg.png" /></figure><p>Every AWS account has a history of what’s happened inside it. Every bucket created, every object deleted, every permission changed. The problem is that none of that history exists anywhere useful by default. If someone asks “who deleted that file last Tuesday,” the honest answer in a fresh AWS account is usually “we don’t know, because we never turned on logging.”</p><p>CloudTrail is the fix for that, but turning it on is only step one. I set up a trail to capture both management activity and S3 object level events, generated some real activity against a test bucket, then ran directly into a wall that catches almost everyone the first time: the console’s own event search couldn’t find the exact thing I was looking for. Here’s the setup, the wall, and the actual fix.</p><h3>Step 1: Creating the trail</h3><p>Every CloudTrail setup starts on the service’s landing page, which explains its job in plain terms: continuous logging, management, and auditing of API activity across the account. I clicked <strong>Create a trail</strong> to begin.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LLmQgSRx8B_eAEJIEv0PBg.png" /></figure><p>I named the trail ManagementAndDataEventsTrail and selected <strong>Create new S3 bucket</strong>, letting AWS automatically provision a dedicated bucket (aws-cloudtrail-logs-339254021884-2f2c3572) for storing whatever the trail captures, rather than pointing it at an existing bucket.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WgpuYHKyTgZ5rjX0XTLu0A.png" /></figure><h3>Step 2: Choosing what to log</h3><p>This decision matters more than it looks like at first glance. On <strong>Choose log events</strong>, I selected both <strong>Management events</strong>, which cover administrative actions like creating or deleting resources, and <strong>Data events</strong>, which cover resource level object operations. Most default setups only capture management events, since data events can generate a lot more volume. I wanted full coverage here on purpose.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NKTVlLe9s-z_bOqPSHnGrQ.png" /></figure><p>Under <strong>Data events</strong>, I set the resource type to <strong>S3</strong> and selected <strong>Log all events</strong>, capturing read, write, and object level API calls across the S3 environment rather than scoping it to a specific bucket at this stage.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*z96sTYjaLAMEXDAh73yxdw.png" /></figure><p>On <strong>Review and create</strong>, I verified the configuration end to end: a multi region trail, logging both management and data events, writing directly to the newly created S3 log bucket.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WlV5gU4RJLsbfvVBQZz54g.png" /></figure><p>The CloudTrail dashboard confirmed it worked: a green banner reading Trail successfully created, with the trail&#39;s status showing Logging in green.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2q7MQZ29I-M5FMhwmI6yLA.png" /></figure><h3>Step 3: Setting up a bucket to actually generate activity</h3><p>A trail with nothing happening in the account doesn’t prove much. I navigated to the S3 console, where the general purpose buckets view already listed the automatically provisioned CloudTrail logging bucket.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cuABPiTh524QIUQbp81w-g.png" /></figure><p>I created a second, entirely separate bucket named my-main-activity-bucket-ahad-339254021884, intended purely as a target for testing object level activity logging, distinct from where the logs themselves would land.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nyzaCWmo-hJ7ravR0SJMug.png" /></figure><p>The S3 console confirmed the bucket was created successfully, starting out empty with zero objects, exactly as expected before any activity had touched it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dZOfEiayLXLZMHGx_aGiBg.png" /></figure><p>To actually generate something for CloudTrail to catch, I uploaded a sample text file, AWS_Notes.txt, into the new bucket. The object details confirmed it landed in us-east-1.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*E4DVzAZ1LvTqSlBYebDvEg.png" /></figure><h3>Step 4: Hitting the wall in Event history</h3><p>Back on the CloudTrail dashboard, the <strong>Event history</strong> summary already showed recent S3 management events, including PutBucketEncryption and CreateBucket, confirming the trail was actively capturing activity.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TdbhVa4noc-nSt9r4y4DWQ.png" /></figure><p>Here’s where things got interesting. I filtered Event history by the event name PutObject, expecting to find the file upload from Step 3. Instead, the console returned <strong>No matches</strong>. The reason is specific and easy to miss: S3 data events like PutObject simply aren&#39;t displayed in CloudTrail&#39;s basic Event history view. That view only surfaces management events, and data events have to be queried a different way entirely.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Q1rpRPj5f0MJJ5gf_MiOtg.png" /></figure><p>To confirm the trail itself wasn’t the problem, I filtered by CreateBucket instead, a management event. It returned two distinct results immediately, both performed by identity admin-ahad, matching the two buckets created earlier in this task.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HHexs2P41doQPlaQvUwjEA.png" /></figure><p>That confirmed the trail was working correctly the entire time. The gap wasn’t in the logging, it was in which events the console’s default search is built to show.</p><p>Here’s the shape of the whole pipeline, and where that gap actually sits:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FLtlF8x0mrT_1-UAVfWgvA.png" /></figure><h3>Step 5: Finding the data events at the source</h3><p>If the console search couldn’t show data events, the raw logs themselves still had them. I opened the CloudTrail log storage bucket and found an automatically created AWSLogs/ root folder, the top of CloudTrail&#39;s own storage structure.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*te0-rBLnavUdzJsAT8i8jQ.png" /></figure><p>Navigating down to AWSLogs/339254021884/CloudTrail/ revealed regional subfolders: eu-north-1, us-east-1, and us-west-2, CloudTrail organizing logs by region even though the trail itself is multi region.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fBi6Giq8_JQFnLoqetsj_Q.png" /></figure><p>Inside CloudTrail/us-east-1/2026/08/02/, there were already 78 compressed log files (.json.gz), generated dynamically as the trail kept monitoring activity throughout the day.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-UV_UsvOwC4-vVzoBXx0sA.png" /></figure><p>I selected one specific file, containing activity timestamped 19:45:00 UTC, and clicked <strong>Download</strong> to confirm what was actually inside these logs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lxLpGQony857eNRLSgYwJQ.png" /></figure><p>Downloading and reading raw .json.gz files one at a time clearly wasn&#39;t a real strategy for actual analysis. That&#39;s what the next step was for.</p><h3>Step 6: Making the logs queryable with Athena</h3><p>Back on the CloudTrail dashboard, I prepared to integrate <strong>Amazon Athena</strong>, a service built specifically to run SQL queries directly against data sitting in S3, without needing to manually download or parse anything.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*opX94F7NgQVgzl8kmnZybw.png" /></figure><p>Clicking <strong>Create Athena table</strong> opened a modal with an autogenerated SQL DDL query, designed to create a structured external table pointed directly at the CloudTrail log bucket.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eYqzvUcr_MMlkNmVVU5tUw.png" /></figure><p>A green banner confirmed success: Successfully created Athena table: cloudtrail_logs_aws_cloudtrail_logs_..., the raw JSON logs now had a proper table structure sitting on top of them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aPNdSrjBg17Vf-DK7KlcCA.png" /></figure><h3>Step 7: Querying the full picture</h3><p>Opening the <strong>Amazon Athena Query Editor</strong>, the left navigation panel already showed the newly registered table, cloudtrail_logs_aws_cloudtrail_logs_339254021884_2f2c3572, sitting under the default catalog.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-I7pmtFMD5cYnEEfbsz4_w.png" /></figure><p>Before running any queries, Athena needed a defined S3 location to store its own query results in. I opened <strong>Query settings</strong> and clicked <strong>Manage</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IwWcZPdddhb-dByOYG2qjw.png" /></figure><p>I entered s3://aws-cloudtrail-logs-339254021884-2f2c3572/athena-results/ as the dedicated output directory and saved it, keeping Athena&#39;s own results inside the same log bucket rather than scattering them elsewhere.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ji7SLRTPihK2OQyRl5jcww.png" /></figure><p>The banner confirmed Settings successfully updated. Athena was now fully ready to run SQL against the S3 CloudTrail dataset.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zRXWgq47joU3WHB9JpA41A.png" /></figure><p>In the SQL editor, I constructed a query specifically scoped to activity logged against the target bucket, my-main-activity-bucket-ahad-339254021884, rather than querying the entire account&#39;s history at once.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p0DE7lmJNQ3VPPdpOiCpUg.png" /></figure><p>The query completed in 0.97 seconds and returned 31 matching records. The results included exactly the kind of data events that Event history couldn’t show: HeadBucket, DeleteObjects, GetObject, and ListObjects, real API calls that had been sitting in the logs the entire time, just invisible to the basic console search.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VSIuQ3DnkV5LpgjtSRgzLg.png" /></figure><p>Here’s that entire detour laid out as one sequence, from a dead end search to a full result set:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J1CpSRm3wPByZcBo9FqIDw.png" /></figure><h3>The takeaway</h3><p>The actual lesson here isn’t really about CloudTrail specifically, it’s about trusting the data over the interface. When PutObject returned no matches, the tempting read was &quot;the logging isn&#39;t working.&quot; The correct read was &quot;this particular view of the logging has a scope limit,&quot; and those are very different problems with very different fixes. One means starting over. The other means finding a different door into data that was there all along.</p><p>Athena is that different door for CloudTrail specifically, but the pattern generalizes well beyond it. Almost every AWS service that generates high volume logs has a lightweight built in viewer that’s genuinely useful for quick checks, and a real query layer underneath it for when the quick check comes up empty. Knowing that second layer exists, and reaching for it instead of assuming failure, is a big part of what separates comfortable AWS usage from constantly refighting the same dead ends.</p><p>Next up: building a scheduled Athena query that watches for specific high risk actions automatically, so this kind of investigation doesn’t have to start from scratch every time.</p><p><em>If you’re setting this up yourself, don’t stop at the first “no matches” you see in a console search. Ask whether the view you’re looking at was ever built to show what you’re searching for in the first place. Often it wasn’t, and the data is one query away.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=185521fca029" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[IAM Cross Account Roles: Borrowed Access, Never Owned Access]]></title>
            <link>https://medium.com/@ahadusman377/iam-cross-account-roles-borrowed-access-never-owned-access-dc1bef9cef46?source=rss-fcd0b31a42c6------2</link>
            <guid isPermaLink="false">https://medium.com/p/dc1bef9cef46</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[aws-security]]></category>
            <category><![CDATA[iam-roles]]></category>
            <category><![CDATA[ami]]></category>
            <category><![CDATA[ahad-usman]]></category>
            <dc:creator><![CDATA[MUHAMMAD AHAD USMAN]]></dc:creator>
            <pubDate>Tue, 15 Sep 2026 17:57:07 GMT</pubDate>
            <atom:updated>2026-09-15T17:57:07.365Z</atom:updated>
            <content:encoded><![CDATA[<p><strong><em>A walkthrough of building a delegated IAM role and proving that a user with zero permissions can still reach S3, temporarily and on purpose</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ogETvDqI9BvnmqKiWlbgig.png" /></figure><p>The instinct when someone needs occasional access to a resource is to just grant them a policy directly. It’s fast, it’s simple, and it’s exactly the kind of decision that quietly turns into a permissions sprawl six months later, when nobody remembers why twelve different users all have standing S3 access they use once a quarter.</p><p>IAM roles solve this differently. Instead of handing out permissions, you hand out the ability to <em>borrow</em> permissions, temporarily, and only when explicitly requested. I built exactly that: a cross account role carrying read only S3 access, and a completely unprivileged user that could still reach S3 by assuming it. Here’s how the mechanism actually works underneath the console clicks.</p><h3>Step 1: Creating the delegated role</h3><p>Every cross account setup starts with the role itself, and the role starts with a decision about who’s allowed to assume it. In the IAM console, under <strong>Trusted entity type</strong>, I selected <strong>AWS account</strong>, then chose <strong>This account</strong>, allowing authorized identities within the same account to assume the role securely rather than opening it to an external account.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nthNiINhm72DbsbXOtiRGA.png" /></figure><p>On the <strong>Add permissions</strong> step, the console displayed its full default list of AWS managed policies, using the <strong>Use existing policy</strong> option rather than writing one from scratch.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*po57gw8jLmldifrQpTLoGw.png" /></figure><p>Before filtering, I scrolled through the list to get a sense of what was available: dozens of service specific policies covering everything from DevOps agents to Alexa business devices, none of them relevant here.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q_zwRrvriMKpCknqCUvpxQ.png" /></figure><h3>Step 2: Attaching read only S3 access</h3><p>Rather than scroll indefinitely, I filtered directly for AmazonS3ReadOnlyAccess and selected its checkbox. This is the policy that actually matters here: it grants read only permissions to S3 buckets and objects for whatever identity ends up holding it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PnZhz7sBFnPC3uASEoJk4w.png" /></figure><p>With the policy selected, I named the role CrossAccountAccessRole. Below the name field, AWS auto generates a trust policy in JSON, and it&#39;s worth actually reading rather than skipping past: it confirms the sts:AssumeRole action is permitted, scoped to the specific account principal chosen back in Step 1.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UQKCMCMK2Na7f2RpNzBe7Q.png" /></figure><p>Scrolling further down showed the full trust policy, the permissions policy summary confirming AmazonS3ReadOnlyAccess was attached, and the <strong>Create role</strong> button to finalize everything.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KaCbxjeraZv9ZEQFga5NJA.png" /></figure><p>A green confirmation banner announced Role CrossAccountAccessRole created, and the role appeared immediately in the active IAM roles directory alongside the account&#39;s other service linked roles.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mesRgINkPMyVxgSTjRuo5w.png" /></figure><p>Here’s the shape of what this role actually does, once every piece connects:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tArixEbLMthBDVaU7F6_7w.png" /></figure><p>The role by itself doesn’t do anything until something is allowed to assume it. That’s the next piece.</p><h3>Step 3: Creating an intentionally unprivileged user</h3><p>To actually test the delegation, I needed a second identity with nothing handed to it directly. I opened the role’s details page, copied its Role ARN (arn:aws:iam::339254021884:role/CrossAccountAccessRole) and its direct console switch link for later, then moved to IAM Users to build that test identity.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rOw_zkZeeJNiLha9Kd37kQ.png" /></figure><p>I created a new user named UserB, enabling AWS Management Console access so it could actually log in and test the flow, rather than only existing for programmatic access.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Gue2zkOGiPYG2ATqk68_DQ.png" /></figure><p>For this test, I selected <strong>Custom password</strong>, set a secure password directly, and unchecked the mandatory password reset requirement, purely to simplify testing rather than something you’d do for a real onboarding flow.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oPThT9OpTsdr1ZQ8GqOxsw.png" /></figure><p>The next screen is where the actual point of this exercise lives. On <strong>Set permissions</strong>, I attached nothing: no managed policies, no group membership, nothing at all. UserB was created holding exactly zero access rights.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t3kYP-Fo9xHdRkYGgki5Aw.png" /></figure><p>The review screen confirmed it: the permissions summary showed no resources, no attached policies, nothing to click through and verify because there was genuinely nothing there.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T2AADXWmWEuvi19FxKb19g.png" /></figure><h3>Step 4: Verifying the user really has nothing</h3><p>It’s worth actually confirming a claim like “zero permissions” rather than just assuming the console did what you expected. The console confirmed user creation and surfaced UserB&#39;s sign in credentials along with the account specific login URL.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*c551RUVVbQB5SxpIIhGgMw.png" /></figure><p>Checking the IAM Users table showed UserB listed right alongside the primary administrator account, same table, wildly different access levels.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0e8juWXFJaaevFXQM-VwFQ.png" /></figure><p>Opening UserB&#39;s own summary page and checking the <strong>Permissions</strong> tab confirmed it directly: zero policies attached. Not a low privilege set, not a read only default. Zero.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JDnJNEE1J_R8oOE_cnXsUQ.png" /></figure><h3>Step 5: Granting exactly one permission: the ability to ask</h3><p>This is the part that makes the whole delegation model click. UserB doesn&#39;t get S3 access directly. It gets permission to <em>request</em> the CrossAccountAccessRole identity, nothing more. I selected <strong>Add permissions</strong>, then <strong>Create inline policy</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9DmYYTLBqGIdsMem1s8KXw.png" /></figure><p>Rather than clicking through the visual builder, I switched to the JSON tab and wrote the statement directly: allow the sts:AssumeRole action, scoped to exactly one resource, the ARN of CrossAccountAccessRole copied back in Step 3.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HS_82WhtqZF90-TkC1nFMQ.png" /></figure><p>The editor’s right panel confirmed the statement structure as I built it, showing the available services and actions alongside the JSON I’d already written.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7e-Bd2CfEUpzyvUn8l0IQA.png" /></figure><p>On <strong>Review and create</strong>, I named the inline policy AllowAssumeCrossAccountRole. The permissions summary confirmed exactly what it should: limited write access to STS, and nothing broader.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XcY49l64PfYdLmcqFwqWjQ.png" /></figure><p>A green banner confirmed Policy AllowAssumeCrossAccountRole created, now directly attached to UserB. That&#39;s the entire permission set this user will ever hold on its own: one action, one resource.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*csXCkgX0JQN4Vvy5wAxdZw.png" /></figure><h3>Step 6: Switching roles as UserB</h3><p>With the setup complete, it was time to actually test it from UserB&#39;s side. I logged out of the admin account, signed in as UserB, opened the account menu in the top right corner, and clicked <strong>Switch role</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*y58SSLpE26KrtEPPamNEJA.png" /></figure><p>The Switch Role form loaded with blank fields: Account ID, IAM role name, and optional display settings, nothing pre-filled.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*H4uRituIdtWxhVYE6Kru3w.png" /></figure><p>Here’s the full sequence this form represents, from an unprivileged login to an active delegated session:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Jb8I0BzXboQ-XMMwE72bBA.png" /></figure><p>I entered account ID 339254021884, IAM role name CrossAccountAccessRole, set the display name to Delegated-S3-Role, chose green as the display color for visual clarity, and clicked <strong>Switch Role</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yLColSs17Lie3JFEQbxlbA.png" /></figure><h3>Step 7: Confirming the delegation actually worked</h3><p>The console reloaded with a green Delegated-S3-Role badge sitting in the top navigation bar. That badge is the confirmation: UserB had successfully assumed CrossAccountAccessRole and, for the duration of this session only, inherited its read only access to S3.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ea-rwU--lDAj0S4pP3qlrA.png" /></figure><p>Nothing about UserB&#39;s own permissions changed. It still holds exactly one inline policy allowing it to assume one specific role. The S3 access exists only while that badge is showing, and disappears the moment the session ends or UserB switches back.</p><h3>The takeaway</h3><p>The interesting part of this setup isn’t the S3 access itself, it’s where the permission actually lives. UserB never owns read access to anything. It owns the narrower, safer capability of temporarily becoming an identity that does, and only for as long as that session lasts. If UserB&#39;s credentials leaked, an attacker would find a user that can do exactly one thing: ask to become CrossAccountAccessRole, which itself only grants read only S3 access for up to an hour at a time. Compare that to the blast radius of a leaked credential holding AmazonS3ReadOnlyAccess directly, forever, with no session boundary at all.</p><p>That’s the actual argument for cross account roles over direct policy attachment: it’s not about convenience, it’s about shrinking what any single compromised credential can do. A role assumption is loud, logged, and time boxed. A directly attached policy is quiet, permanent, and easy to forget existed.</p><p><em>If you’re setting up your own version of this, resist the urge to attach the managed policy directly to the user “just for now.” The whole value of this pattern comes from making access something a user has to actively request, not something they quietly already have.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dc1bef9cef46" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Enrolling a Wazuh Agent by Hand: The CLI and Manual Key Method]]></title>
            <link>https://medium.com/@ahadusman377/enrolling-a-wazuh-agent-by-hand-the-cli-and-manual-key-method-3fd02966b993?source=rss-fcd0b31a42c6------2</link>
            <guid isPermaLink="false">https://medium.com/p/3fd02966b993</guid>
            <category><![CDATA[ahad-usman]]></category>
            <category><![CDATA[wazuh-agent-enrollment]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[wazuh]]></category>
            <dc:creator><![CDATA[MUHAMMAD AHAD USMAN]]></dc:creator>
            <pubDate>Fri, 11 Sep 2026 18:33:01 GMT</pubDate>
            <atom:updated>2026-09-11T18:33:01.706Z</atom:updated>
            <content:encoded><![CDATA[<p><em>What happens when you skip the dashboard wizard and pair a Wazuh agent with nothing but manage_agents, a copied key, and a config file edit.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p80LsMuASBwwYtmmHNlH1Q.png" /></figure><p>A dashboard wizard that generates a ready to run install command is convenient, but it also hides exactly what makes a Wazuh agent trust a Wazuh manager in the first place. That trust comes down to a single shared key, and Wazuh ships a tool called manage_agents specifically so you can create, extract, and import that key yourself, no wizard involved. This post walks through doing exactly that: registering an agent manually on the manager side, extracting its key, importing it on the endpoint, and pointing the agent at the right server address by hand.</p><p>It also walks through something I did not plan for: a mystery third agent that appeared in the dashboard before the one I actually registered ever showed up, and the two rounds of troubleshooting it took to sort out. That detour ended up being the most useful part of the exercise, since it exposed a Wazuh behavior that the GUI method never surfaces at all.</p><h3>Why the manual method still matters</h3><p>Wazuh officially supports two ways to connect an agent to a manager. One is the dashboard’s deployment wizard, which asks for your OS and server address and hands you a finished install command. The other is the CLI and manual key method: you register the agent’s identity on the manager with manage_agents, extract the resulting key, and import that same key on the agent using the same tool. Nothing is auto generated, nothing is copied for you.</p><p>The manual path exists for good reasons. Some environments have no browser access to the manager at all, some organizations provision agents through configuration management tools that need a scriptable enrollment step, and understanding this flow makes it much easier to reason about what could be going wrong when an agent will not connect. It is also, as this post turned out to demonstrate, the method that will show you Wazuh’s automatic enrollment behavior up close, whether you intended to see it or not.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h_KeDTO6EHr8BAAKeIqntQ.png" /></figure><h3>Step 1: Reconnecting after a stop and start</h3><p>Both EC2 instances involved here had been stopped and restarted since they were first set up, and AWS does not preserve a public IP across a stop and start unless you have attached an Elastic IP. Trying the old server address confirmed this the hard way: the browser sat waiting and eventually gave up entirely.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FxTe_7qCJlkH1mgwlrzccg.png" /></figure><p>A quick check of the EC2 console showed both instances still running, just with new public addresses assigned. The Wazuh server had moved to 54.81.172.247, and the existing agent endpoint had moved to 54.235.9.141.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*k2K7dCgM1sPIJyH6nTqThg.png" /></figure><p>SSH into the server on its new address worked immediately.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/895/1*A0IJXdJhVsVMWwAH_ZKYvg.png" /></figure><h3>Step 2: Fixing an existing agent’s stale configuration</h3><p>Before starting anything new, it was worth checking whether the existing agent still worked. Its ossec.conf still pointed at the manager&#39;s old address, which explained why it had gone quiet.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*0oPKCku2c773_EPbKq5qrQ.png" /></figure><p>A quick edit with nano fixed the &lt;address&gt; field to the new server IP.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/666/1*wUM_pxjrzH3MHWdLMDgnGg.png" /></figure><p>Restarting the agent service brought it back, and the dashboard confirmed it: one agent active again, a clean baseline to build on before touching anything new.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BXDNODbEV9P2DWFIbXEsTA.png" /></figure><h3>Step 3: A dedicated endpoint for the manual method</h3><p>Reusing an endpoint that already went through the GUI enrollment process would muddy the results, so this called for a separate, purpose built instance. A new EC2 instance, Wazuh-Agent-CLI-Endpoint, went up on the same Ubuntu 24.04 image used everywhere else in this setup.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SvXjSqGDL7POVBOngYEu5g.png" /></figure><p>Its security group needed nothing beyond SSH, since this instance would never be reached through a browser or a dashboard wizard, only through the terminal.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*COssYa3_1IbPv216tVvSjQ.png" /></figure><p>A minute later, three instances sat in the EC2 console: the original server, the original endpoint, and this new one at 100.54.107.191, all fully running.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*okOwXVxYLbFDflVNUcHE4g.png" /></figure><p>On this new instance, the Wazuh agent package went in without any manager address attached to the install command at all, a deliberate difference from the wizard driven install. The point of the manual method is that the agent starts out with no idea which server it belongs to, and no key, until you tell it both.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4pYgLJVZDf_FOJRo35sPmQ.png" /></figure><h3>Step 4: Registering the agent and extracting its key</h3><p>On the manager, manage_agents opens a small text menu with four real options: add an agent, extract a key, list agents, or remove one. Choosing to add an agent asks for a name and an IP address. Since this endpoint&#39;s public IP is not fixed, any is the right answer, the same approach used for any cloud instance whose address might change.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/783/1*Jca9uF00AqdGQAlZCQvqHw.png" /></figure><p>With the agent registered as ID 002, the next run of manage_agents listed both existing agents and extracted the key for the new one: a long base64 encoded string containing the agent&#39;s ID, name, IP, and a shared secret.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1012/1*lO9YmkZx7a8Ja2Xy79rGAQ.png" /></figure><h3>Step 5: Importing the key on the endpoint</h3><p>Back on the CLI endpoint, manage_agents offers a different, shorter menu since this side only needs to import a key, not manage a whole roster of agents. The first paste attempt failed outright.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lthb4sQrb6IpGJe1I-K9eg.png" /></figure><p>This is a common snag with copy and paste over SSH, an extra space, a dropped character, or a line break introduced by the terminal can corrupt a long base64 string just enough to fail decoding. Pasting it again, more carefully, worked on the second attempt.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ufEtXWSmYSlt5glUPdbUNA.png" /></figure><p>The key import handles identity and the shared secret, but the agent still needs to know where to send its traffic. That address lives in ossec.conf, set with nano to the server&#39;s current IP.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_HTbnC_MUcItqWCiN8zf0Q.png" /></figure><p>With the key imported and the address set, everything looked ready.</p><h3>Step 6: The phantom agent</h3><p>Restarting the agent service and checking the dashboard should have shown two active agents. Instead, it showed three, and the one that was supposed to matter, agent 002, was sitting on never connected while an agent numbered 003 was already active on the exact same IP address as the endpoint.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4bf2CbNEq4NQYMZx-a46AQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BGxYwVVjLj6HHZZSTwbLXg.png" /></figure><p>Checking the actual key file on the endpoint explained the mismatch immediately. The file on disk was registered under ID 003, not the 002 that had just been imported.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/985/1*tVCzkDSbKYikU-oYOVG3WQ.png" /></figure><p>Here is what actually happened. The moment the agent had a manager address in its configuration and started up, it attempted its own automatic self enrollment over port 1515, the same mechanism the GUI wizard relies on internally, and the manager happily registered it as a brand new agent, ID 003, using its actual hostname and IP. That auto enrolled identity then overwrote the manually imported key for 002 in the local key file. Two competing enrollment mechanisms had quietly collided.</p><p>The fix is to tell the agent not to attempt that automatic enrollment at all, since this deployment is deliberately using the manual key method instead. Adding an &lt;enrollment&gt; block with &lt;enabled&gt;no&lt;/enabled&gt; inside &lt;client&gt; does exactly that.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Qm_hL4vsTDr-GmUPdIvcjA.png" /></figure><h3>Step 7: A second round of key trouble</h3><p>After stopping the agent and re-importing the 002 key, the log told a slightly different story than before. On the agent side, ossec.log showed a steady cycle of the agent trying to connect and the server closing the connection.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XCEuuhXqdrMFRt6seEhA-g.png" /></figure><p>The manager’s own log made the actual cause clear: it was rejecting every message from agent 002 with a decryption failure.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3URBfkNTZIH5JIbcdDR6pQ.png" /></figure><p>This pointed at the key itself again, not the enrollment setting this time. The safest fix was to treat it the same way as the first paste failure: extract a fresh copy of the key directly from the manager rather than trust whatever had ended up on the endpoint.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1011/1*G54MtFleFhlCEjWFrUQR8A.png" /></figure><p>Importing that freshly extracted key on the endpoint succeeded cleanly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JmQZcnoRgN8-oDkPseHp3g.png" /></figure><h3>Step 8: Confirmation, and cleaning up the leftover</h3><p>Restarting the agent one more time and checking the dashboard finally showed the result this whole exercise was after: agent 002, CLI-Enrolled-Agent, reporting active at its real IP address.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fm32MRhW9ru2-oxcaclysg.png" /></figure><p>The auto enrolled agent 003 was still sitting in the roster, disconnected now but cluttering the list. Since it was never a real intended agent, just a side effect of the enrollment conflict, manage_agents made removing it straightforward.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/786/1*ftauYkfhdb7iBbdkH4161w.png" /></figure><p>With that cleanup done, the dashboard showed exactly two agents, both active, both accounted for.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TCMiqelPcwozyPep9XtS6g.png" /></figure><h3>The takeaway</h3><p>The manual key method is not complicated once you know the two commands involved, manage_agents to add and extract on the manager, manage_agents again to import on the agent, and a one line edit to ossec.conf to point the agent at the right address. What makes it worth understanding is not the happy path, it is what happened when that path collided with a feature working exactly as designed in the background.</p><p>Wazuh agents will attempt automatic self enrollment the instant they have a manager address configured, regardless of whether you are also handing them a key by hand. If you are deliberately using the manual method, disabling &lt;enrollment&gt; explicitly is not optional, it is the difference between the identity you intended to create and a phantom one the agent invents for itself. And when a key import fails or an agent gets rejected with a decryption error, the fastest fix is rarely to debug the string you already have. Extract a fresh copy from the manager and start that half of the process over.</p><p><em>If you have run into Wazuh’s auto enrollment fighting with a manual setup of your own, or found a cleaner way to disable it upfront before the conflict ever happens, I would like to hear about it. Thanks for reading.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3fd02966b993" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deploying EC2 Instances with Lambda: Treating Infrastructure as Code]]></title>
            <link>https://medium.com/@ahadusman377/deploying-ec2-instances-with-lambda-treating-infrastructure-as-code-82fddd7ab929?source=rss-fcd0b31a42c6------2</link>
            <guid isPermaLink="false">https://medium.com/p/82fddd7ab929</guid>
            <category><![CDATA[ec2]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[aws-lambda]]></category>
            <category><![CDATA[iac]]></category>
            <category><![CDATA[ahad-usman]]></category>
            <dc:creator><![CDATA[MUHAMMAD AHAD USMAN]]></dc:creator>
            <pubDate>Thu, 10 Sep 2026 12:59:59 GMT</pubDate>
            <atom:updated>2026-09-10T12:59:59.333Z</atom:updated>
            <content:encoded><![CDATA[<p><strong><em>A hands on account of writing a Boto3 script that provisions EC2 instances automatically, and the four errors it took to get there</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qa3wsOIw4HhbtWWE_BhLIw.png" /></figure><p>Most people’s first encounter with “infrastructure as code” is a diagram. A box labeled “code” points to a box labeled “cloud resources,” and somewhere in between a lot of manual clicking disappears. It looks clean. It looks instant.</p><p>It rarely is, on the first try.</p><p>I wanted to see what that gap actually looks like in practice: not the polished end state, but the real path from “write a script that launches EC2 instances” to “the script actually works.” So I built a Lambda function that provisions EC2 instances programmatically, using an IAM role scoped specifically for that purpose. It took one clean setup phase and four separate failures before it succeeded. Here’s the whole thing, mistakes included, because the mistakes are honestly the more useful part.</p><h3>Why automate instance launches at all?</h3><p>Clicking through the EC2 console to launch an instance takes maybe two minutes. That’s fine once. It stops being fine the moment you need it to happen the same way every time: same instance type, same tags, same region, triggered by a schedule or an event rather than a person remembering to do it.</p><p>That’s the actual promise of “code as infrastructure.” Not that it’s faster than clicking (it often isn’t, especially while you’re debugging it), but that it’s repeatable, version controlled, and auditable. A script either runs correctly or it throws an error you can read. A person clicking through a wizard at 2 AM might not do either reliably.</p><p>Here’s the shape of what this setup actually looks like once it’s finished:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AwwypBOyyFp4LdLbXoJA3g.png" /></figure><p>Three pieces, each doing one job: a role that grants permission, a function that uses it, and the instances that result. Getting to that clean picture took some detours, which the rest of this post covers, step by step.</p><h3>Step 1: Creating the IAM execution role</h3><p>A Lambda function can’t touch EC2 by default. It needs to be handed permission explicitly, through an IAM role it assumes when it runs. That role has two parts: who’s allowed to assume it (the trust policy), and what it’s allowed to do once it has (the permissions policy).</p><p>I started building the role by selecting <strong>AWS service</strong> as the trusted entity type, which lets an internal AWS service, rather than a person or another account, assume this role on my behalf.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Yxhipw0HGNKMmQ0LovS0hA.png" /></figure><p>Under <strong>Service or use case</strong>, I chose <strong>Lambda</strong> specifically. This is what generates the trust policy naming lambda.amazonaws.com as the principal allowed to assume the role, rather than leaving it open to any AWS service.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uWDMVUPpuK0c5nWlUvE0tw.png" /></figure><p>For permissions, I attached the managed policy AmazonEC2FullAccess. This is what actually lets the role launch, describe, and configure EC2 instances once Lambda assumes it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CxBX8xKY46JWnFq5-3Jj-g.png" /></figure><p>I named the role Lambda-EC2-Deployer-Role and reviewed the auto generated trust policy document, confirming lambda.amazonaws.com was listed as the trusted principal exactly as expected.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6QpcKHBxl0VCqQgzV98blg.png" /></figure><p>A final review of the attached policy and optional tags, then <strong>Create role</strong> to finalize it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fXCfRtMR7bL5NSYJk4WTLg.png" /></figure><p>The IAM console confirmed the role was created and now sits in the active roles list, ready to be attached to a function.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3QCZv57JjAeyn5EuQiaO8w.png" /></figure><h3>Step 2: Building the Lambda function</h3><p>With permissions in place, I moved to the Lambda console to build the actual function.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mOgN34aKNTs3aWN17K3SEw.png" /></figure><p>I chose <strong>Author from scratch</strong>, named the function Deploy-5-EC2-Instances, and set the runtime to <strong>Python 3.14</strong> to write the automation script in Boto3, AWS&#39;s Python SDK.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LQDaFSHlQRgHrYAhtrQeDA.png" /></figure><p>By default, Lambda creates a brand new execution role with just basic CloudWatch logging permissions, not what I needed here. Expanding <strong>Additional settings</strong> exposes the option to attach a custom role instead.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S-ehVlCIZel5J_J06EdHOQ.png" /></figure><p>Under <strong>Custom execution role</strong>, I selected <strong>Use an existing role</strong> and picked Lambda-EC2-Deployer-Role from the dropdown, attaching the exact permissions I&#39;d just built in Step 1.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DTsUWpLhXTihgM8bhMRbNg.png" /></figure><p>A quick check confirmed the custom role was correctly attached under the function’s general settings before clicking <strong>Create function</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Tk4w1XqCh5cblNxO6FAmvA.png" /></figure><p>The function initialized with the default lambda_function.py boilerplate, a basic &quot;hello from Lambda&quot; placeholder.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0V0MQVMVKSAxUWh-NqLh4w.png" /></figure><p>Below the editor, the function’s properties confirmed the handler configuration (lambda_function.lambda_handler), the architecture, and deployment package details, the underlying scaffolding the function runs on.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h-jFdOSE-djoIlcQ6pstUg.png" /></figure><h3>Step 3: Writing the deployment script and running the first test</h3><p>With the scaffolding in place, I replaced the placeholder code with a real Boto3 script: initialize an EC2 client, then call run_instances to launch five t2.micro instances in a single API call, tagged for identification. I clicked <strong>Deploy</strong> to save it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Q6cAANXtwraM7-fgJKRs9Q.png" /></figure><p>The deploy succeeded. Time to actually run it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4bNNc0b0Fx7lFMVCOKy2Lg.png" /></figure><p>Before testing, I opened <strong>Edit basic settings</strong> to confirm the memory limit (128 MB), timeout, and execution role were all correctly configured.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3KlpYSdzINTy60q-kS7J-A.png" /></figure><p>Then I clicked <strong>Test</strong>, which opens a modal for defining a test event, the trigger that simulates invoking the function.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EN8HH6_WpT-ckFdl1S23FA.png" /></figure><p>I named the test event TestTrigger, using the standard JSON template, and saved it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*O6vA8_87EdS2ZzQzwt417Q.png" /></figure><p>Running it returned an InvalidParameterCombination error. The t2.micro instance type wasn&#39;t eligible for Free Tier in this account or region combination, which meant the very first assumption in the script was already wrong.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GTdnBypmolmDDuDOVA-IJg.png" /></figure><h3>Step 4: Debugging through four failed attempts</h3><p>This is the part that doesn’t usually make it into tutorials: the script didn’t work the second time either. Or the third.</p><p>I swapped the instance type to t2.nano and re-ran the test. This time it got further, past the eligibility check, but failed with VcpuLimitExceeded. The account&#39;s vCPU quota (8 total) couldn&#39;t support launching five instances of that family at once.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*E9bzicxCdQQW1bu_pRiI1Q.png" /></figure><p>Next I tried t3.micro, expecting the quota issue to be the last obstacle. Instead, it hit the same InvalidParameterCombination error as the very first attempt, a different instance family running into the identical Free Tier restriction.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Jqe-XC8WSNrerldW2VgkEQ.png" /></figure><p>At this point the pattern was clear enough to look directly at the code. Line 15 of lambda_function.py is where InstanceType=&#39;t3.nano&#39; was declared, the exact line responsible for each parameter validation failure so far.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/686/1*JDXD2pSn2k8VZJV9oxhlQg.png" /></figure><p>Fixing the instance type wasn’t the end of it, either. The script also had a hardcoded AMI ID (ami-0c7217cdde317cfec), and running it returned InvalidAMIID.NotFound. That confirmed a second, separate problem: a static AMI string baked into the code will only ever work in the exact region it was copied from.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1Hkze5-KdIbhaxRGYMGPQw.png" /></figure><p>Here’s the full sequence, laid out end to end:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DYjxXNssSzN72dbXVOTCwQ.png" /></figure><p>Each failure wasn’t really a separate problem. They were four symptoms of two root causes: an instance type assumption that didn’t hold in this account, and an AMI ID that was never going to be portable in the first place.</p><h3>Step 5: Fixing it properly and verifying the result</h3><p>The real fix meant rewriting the approach, not just swapping another instance type and hoping. I rewrote the script to dynamically query <strong>AWS Systems Manager (SSM) Parameter Store</strong> for the latest valid Amazon Linux 2023 AMI ID at runtime, removing the hardcoded string entirely. I also switched the instance type to t4g.micro (1 vCPU each, comfortably inside the account&#39;s quota) and reduced the launch count from five instances to three, keeping total vCPU usage strictly within the limit instead of running right up against it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5GgjQ5_xh_eIfHJmy6LNAA.png" /></figure><p>I clicked <strong>Deploy</strong>, then <strong>Test</strong>. This time the execution output returned Status: Succeeded with an HTTP 200 response, confirming three EC2 instances launched successfully via infrastructure as code, along with their instance IDs: i-0ffc28908f3e778a3, i-01b24e006e80d4679, and i-0cef81bceaaa52ae8.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VXWH_aywabApDNmoLWztjA.png" /></figure><p>A trip to the EC2 console confirmed it wasn’t just a clean response body: all three Lambda-Auto-Deployed-Instance servers were genuinely running and passing status checks in us-east-1.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*38nAZbiiKlYx6m3MneMMsQ.png" /></figure><h3>The takeaway</h3><p>The finished script is maybe thirty lines of Python. What actually took the time wasn’t writing those thirty lines, it was the four rounds of “deploy, test, read the error, adjust” that got the assumptions right. That loop is the real shape of infrastructure as code in practice: not a single clean deployment, but a script that gets more correct each time it fails in a specific, readable way.</p><p>Two lessons carried the most weight here. First, <strong>hardcoded values are the recurring failure point</strong>: a hardcoded instance type broke across quota limits, and a hardcoded AMI ID broke across regions. Querying for current values at runtime, through SSM in this case, is what actually makes a script portable rather than merely functional in the one account it was written in. Second, <strong>every error message was specific enough to act on directly</strong>. VcpuLimitExceeded isn&#39;t a mystery to debug, it&#39;s a quota number and a next step. That&#39;s the entire case for scripting this in the first place: a script fails loudly and specifically, in a way a person clicking through a console under time pressure usually doesn&#39;t notice until much later.</p><p><em>If you’re building your own version of this, budget real time for the error loop rather than treating it as a sign something’s wrong. A Lambda function that fails four times with four different, specific errors before succeeding isn’t a broken process, it’s the process working exactly as it should.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=82fddd7ab929" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Wazuh Agent Deployment Using the Dashboard GUI: A Hands-On AWS EC2 Walkthrough]]></title>
            <link>https://medium.com/@ahadusman377/wazuh-agent-deployment-using-the-dashboard-gui-a-hands-on-aws-ec2-walkthrough-c776579c0449?source=rss-fcd0b31a42c6------2</link>
            <guid isPermaLink="false">https://medium.com/p/c776579c0449</guid>
            <category><![CDATA[wazuh-dashboard]]></category>
            <category><![CDATA[ahad-usman]]></category>
            <category><![CDATA[wazuh]]></category>
            <category><![CDATA[aws-ec2]]></category>
            <category><![CDATA[wazuh-agent]]></category>
            <dc:creator><![CDATA[MUHAMMAD AHAD USMAN]]></dc:creator>
            <pubDate>Tue, 08 Sep 2026 15:00:33 GMT</pubDate>
            <atom:updated>2026-09-08T15:00:33.712Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Installing Wazuh’s Quickstart on EC2, then enrolling an agent the beginner friendly way, straight from the dashboard.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KU4KObRBlOlkkkzXx44qjw.png" /></figure><p>Wazuh is one of those tools that reads simply on paper: install a server, install an agent, watch the dashboard light up. In practice, getting there on a fresh cloud instance involves a handful of decisions (instance size, security group ports, which install method) and, if you are unlucky with your local network like I was, a genuine debugging session halfway through. This post walks through the whole thing end to end: standing up a Wazuh server on AWS EC2 using the official Quickstart installer, then deploying an agent onto a second instance using the Wazuh dashboard’s built in deployment wizard.</p><h3>Why deploy this way at all?</h3><p>Wazuh ships two officially supported paths for getting agents talking to a server: a GUI wizard baked into the dashboard that generates a ready to run install command for you, and a CLI/manual key method where you register the agent yourself and import its key by hand. This post covers the first. It is the path most people should start with, since the dashboard already knows your server’s address and agent version, and it turns what used to be a multi step manual process into copy, paste, run.</p><p>None of that removes the need to understand what is actually happening underneath, though. A Wazuh deployment is really three things working together: the manager that receives and processes security events, the indexer that stores and searches them, and the dashboard that visualizes them. On a small deployment, all three can live on a single EC2 instance, which is exactly what the Quickstart installer sets up in one pass. Agents are a separate, much lighter piece that just needs to reach that instance over a couple of specific ports.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hHv9L2PIJ8OGksLlvPuD5A.png" /></figure><p>With that picture in mind, here is the build.</p><h3>Step 1: Launching the Wazuh server on EC2</h3><p>The server needs more than a default EC2 instance to feel comfortable. Wazuh’s own sizing guidance calls for at least 4 vCPUs for a production style setup, but for a lab deployment monitoring a handful of agents, a t3.large (2 vCPU, 8 GiB RAM) is a reasonable middle ground between official recommendations and free tier constraints.</p><p>I started the launch wizard, named the instance Wazuh-Server, and picked <strong>Ubuntu Server 24.04 LTS (64 bit x86)</strong> from the Quick Start AMIs. This mattered more than it might look: AWS&#39;s AMI picker also shows Ubuntu 26.04, which is newer but not yet on Wazuh&#39;s list of officially supported and tested operating systems. Sticking to 24.04 avoided any risk of dependency issues during install.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kUuuDZzhqB8rhhRNHZxz6w.png" /></figure><p>For sizing, I went with t3.large and reused a single key pair, wazuh-key, that I would also use for the agent endpoint later.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qikuPOhN6xqhs0CclgZeww.png" /></figure><p>Networking is where a Wazuh deployment actually lives or dies. The dashboard needs HTTPS (443) reachable from a browser, agents need port 1514 for normal event traffic and 1515 for enrollment, and the Wazuh API (used for some integrations and the CLI) listens on 55000. I created a new security group, wazuh-server-sg, and gave it a description that would make sense to future me scrolling through a list of security groups later.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YuF6oQKe6poLazILnXRwTg.png" /></figure><p>Then came the actual inbound rules: SSH for management, HTTPS for the dashboard, and 1514 for agent communication.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lmteAbsKih-R3wHX79hLzQ.png" /></figure><p>And the two remaining Wazuh specific ports, 1515 for enrollment and 55000 for the API. AWS flags any 0.0.0.0/0 source with a yellow warning, which is worth reading rather than dismissing: for a real deployment you would scope these to known IP ranges, but for a training lab reachable from anywhere, open is the tradeoff being made deliberately here.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Yk19SfvMS_YjglAhAomTKg.png" /></figure><p>Storage got bumped from the 8 GiB default to 50 GiB on a gp3 volume, since the indexer and its logs need real room to breathe.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NKOEwU1cQjgyGviS4FjT-w.png" /></figure><p>With that, the launch went through cleanly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UTGnZqjIBQpT7zGTuXbVTw.png" /></figure><h3>Step 2: Waiting for the instance, then hitting a wall</h3><p>This is the part that is easy to skip past in a tutorial and easy to trip over in real life. Right after launch, the instance shows as <strong>Running</strong>, but its status check still reads <strong>Initializing</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3fZ60w621Y0HfmwAtFIRlg.png" /></figure><p>I tried connecting anyway. The SSH handshake completed, the host fingerprint prompt appeared as expected, and I typed yes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EReUEScFvYh6tMuo_oP1Ow.png" /></figure><p>The session then closed itself immediately with Connection closed by ... port 22, no login banner, nothing. The instance was accepting TCP connections but SSH itself was not fully up yet, since the underlying status checks had not finished.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*E9yYYMF7z9-fxGwJbibe4w.png" /></figure><p>Waiting roughly a minute and refreshing the EC2 console until the status check read <strong>3/3 checks passed</strong> solved it completely.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VVf83i9mV-EZqRyeDIcXpQ.png" /></figure><p>Same command, same key, and this time it logged in cleanly with the full Ubuntu welcome banner.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/901/1*buDCfiDdHeeV_SKyiLCgOA.png" /></figure><h3>Step 3: Installing Wazuh, and losing the connection more than once</h3><p>Wazuh’s Quickstart installer is a single command :</p><blockquote><strong><em>curl -sO </em></strong><a href="https://packages.wazuh.com/4.14/wazuh-install.sh"><strong><em>https://packages.wazuh.com/4.14/wazuh-install.sh</em></strong></a><strong><em> &amp;&amp; sudo bash ./wazuh-install.sh -a</em></strong></blockquote><p>The -a flag installs everything, manager, indexer, and dashboard, on the one instance. This is where a second problem showed up, one that had nothing to do with Wazuh at all: my local internet connection kept dropping the SSH session, sometimes within seconds of typing a command.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PCC4Xv-ir14UbZbGcaKhpA.png" /></figure><p>The fix for a dropped connection is just to reconnect and try again, and after doing that, a plain sudo apt update ran without issue, which at least confirmed the instance itself was healthy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/891/1*qjXkbiLn1BjrndcsnzdA6g.png" /></figure><p>Since the installer script had already been downloaded in the failed attempt, ls -la confirmed wazuh-install.sh was sitting there at its full size, so there was no need to curl it again.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/813/1*UHRL8zNjRflSCYFgIaTV2A.png" /></figure><p>Running the installer again got further this time, through hardware verification and into the dependency stage, before the connection dropped a second time, right as it was installing debhelper.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wl0TR9FY1rBEhLK1Hd2jgQ.png" /></figure><p>At this point it was clear that running a fifteen minute install directly over a flaky SSH session was not going to work. The fix is screen: a terminal multiplexer that keeps a session, and anything running inside it, alive on the server even if the SSH connection itself drops. Reconnecting and trying to reattach to an existing screen session, though, surfaced a session state left over from the earlier disconnect: it showed as (Attached) even though nothing was actually attached to it anymore, and screen -r refused to resume it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/871/1*UUnBxjpT_w9Sl8Bk38Y4Lg.png" /></figure><h3>Step 4: Diagnosing a genuinely stuck install</h3><p>Rather than guessing, the next move was to check whether the installer was actually still doing anything, using ps aux.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tEjv8lVNaOgwwP3jJmTf_g.png" /></figure><p>The processes were alive, but a closer look at what apt itself was doing told the real story: apt-get install debhelper had been running for many minutes but had accumulated only about a second of actual CPU time. That is the signature of a hung process, not a slow one.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ptKRDIamvI1qW0vb0Ger0Q.png" /></figure><p>Before assuming a network problem, it was worth ruling one out directly. Killing the stuck processes, cleaning up any leftover dpkg locks, and then running a plain ping against Wazuh&#39;s package server came back with 0% packet loss and sub millisecond response times. The network was fine. The apt process had simply wedged itself, most likely from the earlier abrupt disconnects leaving it in a bad state.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xRVrm8x6a3-T8J0u1V-WBQ.png" /></figure><h3>Step 5: Restarting cleanly inside screen</h3><p>With the stuck processes cleared and the network confirmed healthy, it was time for a genuinely clean restart: apt update again, then the Wazuh installer once more.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uHv4T4gcpvRmeTNKRBS9hQ.png" /></figure><p>This time, the installer ran inside a brand new screen session named wazuh-install2, detached from safely with Ctrl+A then D. Sure enough, the SSH connection dropped again a few moments later, but because the install was running inside screen rather than directly in the SSH session, it kept going in the background regardless.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1018/1*BlfPicVXlCAaBmNoEpnGsg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XbbCRcY4RmJ7LFedoML-sQ.png" /></figure><p>Checking on progress no longer required reattaching to anything fragile. Tailing the log file directly worked from any fresh SSH session:</p><blockquote><strong>sudo tail -30 /var/log/wazuh-install.log</strong></blockquote><p>A little while later, that log ended with exactly the line to look for.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-kroF_NY9mH52jjsp1NO_g.png" /></figure><p>The install also prints a one time summary with the dashboard URL and a generated admin password, retrievable afterward with sudo tar -O -xvf wazuh-install-files.tar wazuh-install-files/wazuh-passwords.txt if you miss it scrolling past. I am deliberately not including a screenshot of that output here, since it contains live, working credentials for the dashboard, and publishing those anywhere public defeats the point of having them be secret in the first place. Grab yours from your own terminal and keep it somewhere safe.</p><h3>Step 6: Verifying the three services</h3><p>Before touching a browser, a quick sanity check on the three core services confirmed the install had actually taken effect and not just logged success.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*__s7AOGUs_mh3vgkVOlCvg.png" /></figure><p>wazuh-indexer came back active (running) as well (its output is mostly Java startup warnings that look scarier than they are), and the dashboard service showed the same healthy status, already running for twenty hours by that point since it had actually finished installing during an earlier attempt that I had not yet confirmed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cA5BCzN0Lx0iD2opfGH83w.png" /></figure><h3>Step 7: Getting into the dashboard for the first time</h3><p>Pointing a browser at https://&lt;server-ip&gt; triggers a certificate warning, since Wazuh&#39;s installer generates a self signed certificate rather than one from a public certificate authority. This is expected, not a sign something went wrong.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*klhkzrWcRfiwqbib-bEV-g.png" /></figure><p>Clicking through to the advanced view surfaces a direct link to proceed anyway.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Kw-DYW5bEVJNobmdwli3AQ.png" /></figure><p>From there, the actual Wazuh login page appears, and logging in with the admin username and the password retrieved earlier lands on the dashboard&#39;s overview page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IxIlluTC1UMHmlTAJRZpbA.png" /></figure><p>At this point the overview page correctly reported zero registered agents, exactly as expected for a server that has nothing pointed at it yet.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4YFEnEzCs2lMTYgjpPzxxA.png" /></figure><p>That completes the server half of the setup. Everything from here is about the agent.</p><h3>Step 8: A second, much lighter instance for the agent</h3><p>Wazuh agents are intentionally lightweight, so this instance did not need anywhere near the server’s specs. I launched a second EC2 instance, Wazuh-Agent-Endpoint, on the same Ubuntu 24.04 AMI for consistency, but sized down to t3.micro.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XbwHQ2fJvy12lEMF8OYg1g.png" /></figure><p>Its security group, wazuh-endpoint-sg, only needed one inbound rule: SSH, for management. Outbound traffic to the Wazuh server&#39;s ports is allowed by default on a new security group, so the agent can reach the manager without any extra outbound rules. Storage stayed at the 8 GiB default, since an agent has nowhere near the footprint of the full indexer and dashboard stack.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wTvBZBc67yzzROjZDAEj5A.png" /></figure><p>A minute later, both instances were sitting side by side in the EC2 console, fully running: the server on 54.88.77.122, the endpoint on 54.237.154.158.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ji8P5fNYLKU7tKdYr6JWrw.png" /></figure><h3>Step 9: Deploying the agent through the dashboard wizard</h3><p>Back in the Wazuh dashboard, the <strong>Deploy new agent</strong> wizard walks through package selection, server address, and optional naming, then hands you a ready made install command. Since the endpoint runs Ubuntu, the correct package format is <strong>DEB amd64</strong>, and the server address is the Wazuh server’s own IP, not the endpoint’s.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6MOz86maa2GYmvijepZq3A.png" /></figure><p>Leaving the agent name blank lets Wazuh default to the endpoint’s hostname, which is perfectly fine for a single test agent, and leaving the group as <strong>Default</strong> skips a layer of configuration that only matters once you are managing many agents with shared policies. With those two optional fields left alone, the wizard generates the exact install command needed for this specific server and OS combination:</p><p><strong>wget </strong><a href="https://packages.wazuh.com/4.x/apt/pool/main/w/wazuh-agent/wazuh-agent_4.14.7-1_amd64.deb"><strong>https://packages.wazuh.com/4.x/apt/pool/main/w/wazuh-agent/wazuh-agent_4.14.7-1_amd64.deb</strong></a><strong> &amp;&amp; sudo WAZUH_MANAGER=’54.88.77.122&#39; dpkg -i ./wazuh-agent_4.14.7–1_amd64.deb</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qLOKX1tWWXcRvhGVS4ob8w.png" /></figure><p>The wizard also lists the follow up commands needed to actually start the service once the package is installed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-Dut5pIRzmWA7PTRALDqxA.png" /></figure><h3>Step 10: Running it all on the endpoint</h3><p>SSHing into the endpoint this time went smoothly on the first try, connection stability apparently having improved since the server install.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/909/1*OVJmm5ekLw8dF1C-v7f74Q.png" /></figure><p>Pasting the generated command downloaded and installed the agent package in well under a second, a nice contrast to the server’s fifteen minute ordeal, since an agent install is just unpacking a single lightweight .deb file rather than standing up an indexer and dashboard stack.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YJx2hkXJU3BOjMvL6q3v0A.png" /></figure><p>Running the three follow up commands, daemon-reload, enable, and start, brought the agent service up immediately, and systemctl status confirmed it active with all of its worker processes (wazuh-agentd, wazuh-execd, wazuh-syscheckd, wazuh-logcollector, wazuh-modulesd) running.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oA0SKtSOs3yaRL0iSFFGAA.png" /></figure><h3>Step 11: Confirming it in the dashboard</h3><p>Back on the Wazuh dashboard’s endpoints summary page, the payoff: one agent, status <strong>active</strong>, correctly reporting its hostname, private IP, and OS.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eZfsg1WSyjKznbP2IveKqw.png" /></figure><p>That green <strong>active</strong> status is the actual completion criteria for this whole exercise. An agent that installs cleanly but never reports in is still a failed deployment, usually pointing to a security group rule, a wrong server address, or a firewall blocking ports 1514 or 1515. None of that happened here, but it is worth knowing where to look if it does: sudo tail -f /var/ossec/logs/ossec.log on the agent side, and a nc -vz &lt;server-ip&gt; 1514 to check basic reachability, are the first two things to reach for.</p><h3>The takeaway</h3><p>Most of what makes a Wazuh deployment work is the same as any other piece of security tooling: the right ports open to the right places, the right OS on the supported list, and enough patience to let a status check finish before assuming something is broken. The genuinely useful lesson here was not about Wazuh specifically at all. It was that anything expected to run for more than a minute or two over SSH belongs inside screen (or tmux, or nohup) from the very first attempt, not bolted on after a dropped connection already killed it halfway through. That one habit would have saved a good chunk of the troubleshooting in this post.</p><p>With the server up and one agent reporting in through the GUI wizard, the natural next step is the other officially supported enrollment path: registering an agent manually through manage_agents and importing its key by hand, which is exactly what the next post in this series covers.</p><p><em>If you have hit your own version of the stuck </em><em>apt process or the stale </em><em>screen session, I would like to hear how you diagnosed it. Thanks for reading, and good luck with your own deployment.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c776579c0449" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Subnetting in AWS VPC: Building a Public and Private Network from Scratch]]></title>
            <link>https://medium.com/@ahadusman377/subnetting-in-aws-vpc-building-a-public-and-private-network-from-scratch-075b5b6194fb?source=rss-fcd0b31a42c6------2</link>
            <guid isPermaLink="false">https://medium.com/p/075b5b6194fb</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[vpc]]></category>
            <dc:creator><![CDATA[MUHAMMAD AHAD USMAN]]></dc:creator>
            <pubDate>Mon, 07 Sep 2026 14:18:59 GMT</pubDate>
            <atom:updated>2026-09-07T14:18:59.186Z</atom:updated>
            <content:encoded><![CDATA[<p><strong><em>A hands-on, fully-documented walkthrough of creating an isolated cloud network, splitting it into public and private zones, and controlling exactly which one talks to the internet</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oHu8taRL1L1ZEfkCsszWCg.jpeg" /></figure><p>Every AWS project starts the same way, with a network nobody sees. Before an EC2 instance boots, before a database spins up, before a single line of application code runs, there’s a quiet decision that shapes everything downstream: <em>how is this network laid out?</em></p><p>That decision is<strong> </strong>subnetting inside a VPC (Virtual Private Cloud). It’s one of those AWS fundamentals that looks simple in a diagram but trips people up the first time they actually click through the console. So I built one from scratch, a VPC with a public subnet that can reach the internet, and a private subnet that deliberately can’t, and documented every single step, screenshot by screenshot, along the way.</p><h3>Why bother splitting the network at all?</h3><p>The instinct when you’re starting out is to throw everything into one flat network. It works, until it doesn’t. A single subnet means your database sits exactly as exposed to the internet as your web server, your internal tools are one misconfigured security group away from being public, and there’s no architectural boundary between “things the world should see” and “things it shouldn’t.”</p><p>Splitting a VPC into public and private subnets fixes that at the network layer, not just the application layer. The public subnet routes traffic to and from the internet. The private subnet doesn’t. No matter what runs inside it, it has no path out. That’s a much sturdier guarantee than simply saying “we configured the firewall correctly.”</p><p>Here’s the end state we’re building toward, before we get into the console:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rQZdFowHn9BfHl7hfAqyPQ.png" /></figure><h3><strong>Step 1: Creating the VPC</strong></h3><p>Everything lives inside a VPC, so that’s where it starts. I created a custom VPC named My-Lab-VPC, using the <strong>VPC only</strong> option so I could configure every networking component myself rather than letting AWS auto-generate subnets, route tables, and gateways. The VPC was given an IPv4 CIDR block of 10.0.0.0/16, a private address range that provides roughly 65,000 IP addresses to carve up however the project needs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BvlAH6mD9juwtWxc9ucyUA.png" /></figure><p>Encryption and tenancy settings were left at their defaults, a Name tag of My-Lab-VPC was attached for easy identification later, and I clicked the orange <strong>Create VPC</strong> button to deploy it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4sifqTGIFe7M1hwH-kmAJQ.png" /></figure><p>At this point, there’s a network, but nothing inside it yet. No subnets, no way in, no way out.</p><h3>Step 2: Carving out the subnets</h3><p>With the VPC in place, the next step is deciding how to slice that /16 block into smaller pieces. I created two subnets, each in a different Availability Zone for basic resilience. Starting with the subnet creation screen, I selected My-Lab-VPC from the VPC ID dropdown and named the first subnet Public-Subnet-1.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wXd93ND5EsJGfI2zFvbT3g.png" /></figure><p>Public-Subnet-1 was assigned to Availability Zone us-east-1a with an IPv4 CIDR block of 10.0.1.0/24, giving it 256 usable addresses.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jhzntd2WvyDHvoXOUkpJEQ.png" /></figure><p>Then, in the same flow, I configured the second subnet, Private-Subnet-1, in a separate Availability Zone, us-east-1b, with its own CIDR block of 10.0.2.0/24.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mQwhbVdiA13V0A9LONFg3w.png" /></figure><p>Right now, these two subnets are functionally identical: same VPC, same default settings, no internet access for either. What actually makes one “public” and the other “private” isn’t a checkbox on the subnet itself. It’s entirely about what route table gets attached to it. That distinction matters, because it’s the part of AWS networking that confuses people the most, and it’s exactly what the next few steps are about.</p><h3>Step 3: Giving the VPC a door to the internet</h3><p>A VPC is sealed off from the internet by default. That’s the correct default, but it means even the “public” subnet has nowhere to send outbound traffic yet. To fix that, I created an <strong>Internet Gateway</strong> named My-Lab-IGW.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CPBDq58e10aiC31t2Wrzmg.png" /></figure><p>Creating an Internet Gateway doesn’t automatically connect it to anything, though. It’s created in a detached state. I selected it and chose <strong>Attach to VPC</strong>, picking My-Lab-VPC from the list of available VPCs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*x35IGCTJ2sH3HR04aTQ7nQ.png" /></figure><p>Once attached, the gateway’s state flips to <strong>Attached</strong>, shown in green. This confirms there’s now a physical path between the VPC and the internet, even though no subnet is using it yet.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mav29XFzhWTIEIKgwXXSoQ.png" /></figure><h3>Step 4: Route tables, where “public” and “private” actually get decided</h3><p>This is the part that’s easy to gloss over but does all the real work. A route table is a set of rules that determines where network traffic is allowed to go. Every subnet is associated with exactly one route table, and that association is what determines its behavior, not any setting on the subnet itself.</p><p><strong>Building the public route table.</strong> I created a new route table named Public-RT, associated with My-Lab-VPC.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wO5DPsvpKybrjWo7R18QKg.png" /></figure><p>By default, a brand-new route table only contains a local route, allowing traffic to move freely within the VPC’s own 10.0.0.0/16 range, but nowhere else.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Lcz1PwVjF4AoRkMRDGVVIQ.png" /></figure><p>To actually make it “public,” I edited the routes and added a new destination of 0.0.0.0/0, meaning <em>anywhere on the internet</em>, and pointed its target at the Internet Gateway I&#39;d just attached.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*534w90GyYGp-w-m-ci7wqw.png" /></figure><p>Having the route isn’t enough on its own. A route table only affects the subnets it’s explicitly associated with. I opened the <strong>Subnet associations</strong> tab, which showed zero subnets attached yet.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-pi4WT_ZU68jQPfWq_HUDA.png" /></figure><p>I edited the subnet associations and selected Public-Subnet-1, leaving Private-Subnet-1 unchecked so it stays completely isolated from this route table.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XF-k7d2sajSejnZ7nbUhhw.png" /></figure><p>The confirmation shows Public-Subnet-1 now explicitly tied to Public-RT. From this point on, anything launched in that subnet has a real path to the internet.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZiDjXPaJ0i5KeizK9mUnvA.png" /></figure><p><strong>Building the private route table.</strong> For the private side, I created a second, completely separate route table, Private-RT, also tied to My-Lab-VPC.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SFjVWIkr1tTleqx_imWeqA.png" /></figure><p>The key difference: I never added a 0.0.0.0/0 route pointing to the Internet Gateway here. Private-RT keeps only its default local route, so I went straight to editing its subnet associations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*twys-IKaxX8-ON48zgARUQ.png" /></figure><p>I selected Private-Subnet-1 and saved the association. This ties the subnet strictly to internal, VPC-local traffic. There&#39;s no route out, so there&#39;s nothing to leak.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*F39JtDFfm7tFC9uriIql-A.png" /></figure><p>That’s the entire mechanism behind “public” versus “private.” Nothing about the private subnet is locked down in some special, extra way. It simply has no route to the internet, so traffic destined there has nowhere to go.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Nxwb9Xs_Vk5C1b68jJ585Q.png" /></figure><h3>Step 5: Making the public subnet actually reachable</h3><p>One more piece is easy to miss: having a route to the internet isn’t the same as having a <em>public IP address</em> to be reached at. Before touching that setting, I filtered the full subnet list in the region down to just the two I’d created, using the VPC ID as a filter.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KEj-U66Tu8l7Uh3x37m5rQ.png" /></figure><p>After filtering by My-Lab-VPC&#39;s ID, only Public-Subnet-1 and Private-Subnet-1 remain, both showing an Available state.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sJqnnsmR_zAxGwGVoR05ww.png" /></figure><p>Instances launched into Public-Subnet-1 still wouldn&#39;t be reachable from outside unless they&#39;re assigned a public IPv4 address on launch. To handle that automatically going forward, I selected the subnet, went to <strong>Actions → Edit subnet settings</strong>, and enabled <strong>Enable auto-assign public IPv4 address</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mu9TBVFG16mLi2ArqXpx7Q.png" /></figure><p>The confirmation banner shows the setting applied successfully, and the subnet’s details tab now reports 251 available IP addresses ready to be handed out.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*g3MxxN17n9epGWg9iohGKA.png" /></figure><h3>Step 6: Verifying everything actually connects</h3><p>The last step was just confirming the pieces line up the way they should. Checking the summary tab for Public-Subnet-1 confirmed all four pieces were tied together correctly: it sits in us-east-1a, belongs to My-Lab-VPC, is associated with Public-RT, and now auto-assigns public IPv4 addresses to anything launched inside it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oqmtgcqEXY0jH3dQNFLBoQ.png" /></figure><p>That’s a fully working, minimal public/private network, the same pattern that sits underneath most production AWS architectures, just without the extra services layered on top yet.</p><h3>The takeaway</h3><p>If there’s one thing worth remembering from this whole exercise, it’s that <strong>“public” and “private” subnets aren’t a property you set. They’re a consequence of routing.</strong> A subnet is public because its route table sends 0.0.0.0/0 to an Internet Gateway. It&#39;s private because its route table doesn&#39;t. Everything else, the CIDR block, the Availability Zone, the auto-assign setting, is just supporting configuration around that one core decision.</p><p>Once that clicks, the rest of AWS networking (NAT Gateways for private subnets that still need <em>outbound</em> internet access, VPC peering, Transit Gateways) starts to feel a lot less like memorizing console clicks and a lot more like reasoning about where you want traffic to be allowed to flow.</p><p><em>If you’re working through AWS networking fundamentals yourself, I’d recommend building this exact setup in a sandbox account. Reading about route tables only gets you so far; watching a </em><em>curl request succeed from the public subnet and time out from the private one is what actually makes it stick.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=075b5b6194fb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deploying Wazuh on EC2: Standing Up an Open Source SIEM From Scratch]]></title>
            <link>https://medium.com/@ahadusman377/deploying-wazuh-on-ec2-standing-up-an-open-source-siem-from-scratch-de1b32dd5c1d?source=rss-fcd0b31a42c6------2</link>
            <guid isPermaLink="false">https://medium.com/p/de1b32dd5c1d</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[wazuh]]></category>
            <category><![CDATA[ahad-usman]]></category>
            <category><![CDATA[wazuh-with-aws]]></category>
            <dc:creator><![CDATA[MUHAMMAD AHAD USMAN]]></dc:creator>
            <pubDate>Mon, 07 Sep 2026 14:17:41 GMT</pubDate>
            <atom:updated>2026-09-07T14:17:41.659Z</atom:updated>
            <content:encoded><![CDATA[<p><strong><em>A step by step account of launching, sizing, and securing a Wazuh server on AWS, including the one moment that looks like a failure but isn’t</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mxs7WUCm_NGHGcIHDDwqqA.png" /></figure><p>Security monitoring tools have a reputation for being expensive, complicated, or both. Splunk licenses scale with data volume in a way that gets uncomfortable fast. Commercial SIEM platforms often assume you already have a dedicated security team to run them. That reputation keeps a lot of smaller teams and solo learners away from ever touching a real SIEM at all.</p><p>Wazuh breaks that pattern. It’s open source, it runs on a single EC2 instance for testing purposes, and the entire stack, indexer, manager, and dashboard, installs with one script. I wanted to see what standing one up from a blank AWS account actually looks like in practice: not just the happy path, but the sizing decisions, the security group configuration, and the one browser warning that trips up almost everyone the first time they see it.</p><h3>Step 1: Launching the base EC2 instance</h3><p>Every Wazuh deployment starts with a server to run it on. I launched a new EC2 instance, named it Wazuh-Server, and selected <strong>Ubuntu</strong> as the base operating system.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Vfa_AXpSSsxhkJBtRW8I5Q.png" /></figure><p>Specifically, I chose <strong>Ubuntu Server 26.04 LTS</strong> on 64-bit x86 architecture. For initial testing, the instance type defaulted to t3.micro, a reasonable starting point before actually accounting for what Wazuh needs to run.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5UuJZa0Ywd7rQdY2BkQWNg.png" /></figure><p>I reviewed the network configuration next: the instance would sit in the default VPC with an auto-assigned public IP, and a default security group initially configured to allow SSH access.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*X7s0SEFlEUvNc9fH1KVYCA.png" /></figure><p>Storage defaulted to 8 GiB on a gp3 volume, the standard starting point before I’d accounted for Wazuh’s actual footprint.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XmNp25l0RPSWmi3vApT-dQ.png" /></figure><h3>Step 2: Sizing the instance correctly</h3><p>This is where the “just spin up a small instance” instinct runs into reality. A full Wazuh stack, indexer, manager, and dashboard, all running on one box, is genuinely resource hungry. I opened the instance type dropdown to compare options, starting from the smallest available: t3.micro and t3.small.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/773/1*Twq5zdi142IvEm5_qWvwpA.png" /></figure><p>Neither of those was going to cut it. Knowing that indexing, rule evaluation, and the web dashboard all compete for the same CPU and memory on a single node, I selected c7i-flex.large instead: 2 vCPUs and 4 GiB of RAM, a meaningfully different tier from the free tier defaults.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/823/1*5ocJLmr_YMQMNP9aLpOF9A.png" /></figure><p>With the larger instance type selected, I revisited storage too, increasing the volume from 8 GiB to 30 GiB to comfortably hold the Wazuh installation packages and the security logs it would start generating immediately.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yEd215xmQ_mgbG3R19FvkQ.png" /></figure><p>The summary panel on the right confirmed the updated configuration: 1 volume at 30 GiB, matched to the new instance type.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Av8i8C084qbXfnKLzfY7XA.png" /></figure><p>Here’s what the finished setup looks like end to end, once every piece is in place:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GbOrxcZ9kcr9Uo3SIAHUiA.png" /></figure><p>Getting there meant configuring the security group carefully, which is the next step.</p><h3>Step 3: Configuring the security group</h3><p>Wazuh doesn’t run on just one port. The indexer and manager need certain ports open for agent communication, the dashboard needs HTTPS, and administration needs SSH. Leaving all of that on defaults would either lock the service out entirely or open far more than necessary. I created a custom security group named Wazuh-Security-Group, with a description identifying exactly what it was for.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Yv7L4VeH7ybAulg15JAvrQ.png" /></figure><p>The first inbound rule handled SSH on port 22, sourced from 0.0.0.0/0 for this lab setup, to allow remote command line access for the installation itself.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DJy2tteqH-OxT1qRFUQZ7g.png" /></figure><p>Before adding more rules, I reviewed what was there so far to make sure the description and metadata were correctly formatted.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WHmHMnMo4LIz8iYM3F5fDQ.png" /></figure><p>Then came the Wazuh specific ports: HTTPS on port 443 for the web dashboard, and a custom TCP rule on port 1514 for agent communication, the channel monitored endpoints use to report back to the manager.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iM1NpuXu5UvJVRQeP4mciQ.png" /></figure><p>A fourth rule opened port 1515 over Custom TCP, used specifically for agent registration, distinct from the ongoing communication channel on 1514. The summary panel on the right confirmed the storage and instance type were still correctly set.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BZVMQYuSAGGwpEzdBBXN-w.png" /></figure><p>A final pass over the storage configuration and file system attachments, keeping the defaults, before moving on to launch.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wAPZ2uMOMSdXb3V_S_oxCw.png" /></figure><h3>Step 4: Launching without a key pair, and confirming it’s running</h3><p>AWS prompted for key pair settings next. I reviewed the default option to generate an RSA key in .pem format, the standard method for SSH authentication into a new Linux instance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EZJABdyVY23Kln4H_TvGKg.png" /></figure><p>For this lab environment specifically, I selected <strong>Proceed without a key pair</strong> instead, since I’d be using EC2 Instance Connect through the browser rather than a local SSH client. Worth flagging explicitly: in a production environment, a proper key pair or SSM Session Manager access is required, skipping it is a lab shortcut, not a practice to carry into anything real.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*32u1KyGJ3UmZAmwKt05T9w.png" /></figure><p>The console confirmed the launch with a green banner and the new instance ID.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h-0qAhPEsOz6roDJ8yagkg.png" /></figure><p>Filtering the EC2 dashboard by running instances showed Wazuh-Server in state Running, with its status check reading Initializing, exactly what you&#39;d expect in the first minute or two after launch.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xXIi5hKW71RhUx2uACuEjA.png" /></figure><p>Selecting the instance surfaced its network details: a public IPv4 address of 98.93.103.153 and a private IP of 172.31.37.22, the two addresses I&#39;d need for the rest of the setup.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kLGsMn0rtllgdREonFvO1w.png" /></figure><h3>Step 5: Connecting and installing Wazuh</h3><p>With the instance running, I clicked <strong>Connect</strong> and chose <strong>EC2 Instance Connect</strong>, using the default ubuntu username to open a browser based SSH session, no local terminal or key file required.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l5dmhpVyrQeMzFcAY7JT3A.png" /></figure><p>The browser terminal connected successfully, greeting the session with Ubuntu 26.04 LTS’s standard welcome message and a ready command prompt.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DAHEVL8LKx0ctqaVVPuhdA.png" /></figure><p>From there, I ran the official Wazuh all in one installation script. The terminal output confirmed each component installing in sequence: the indexer, the manager, Filebeat (which ships logs into the indexer), and finally the dashboard, ending with the default admin credentials printed directly to the terminal.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B4ZULkjSwFDmp_9C47Dvhg.png" /></figure><h3>Step 6: The certificate warning, and why it’s not a problem</h3><p>This is the part that catches almost everyone off guard the first time. Navigating to https://98.93.103.153 in Chrome doesn&#39;t load a clean dashboard. It loads a <strong>&quot;Your connection is not private&quot;</strong> warning, with the specific error NET::ERR_CERT_AUTHORITY_INVALID.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*s6Jhd7mHisDDwMtxAUvTDA.png" /></figure><p>That warning is expected, not a sign the installation went wrong. The default Wazuh install generates a self-signed TLS certificate rather than one issued by a trusted public Certificate Authority, since there’s no domain name or CA account involved in a quick lab deployment. Browsers are supposed to flag self-signed certificates. That’s the feature working correctly, not a bug in the install.</p><p>Here’s the full sequence from that warning to a working login:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*N-rkODnI52mAsIEDgG31Ww.png" /></figure><p>Clicking <strong>Advanced</strong>, then selecting <strong>Proceed to 98.93.103.153 (unsafe)</strong>, bypasses the warning for this browser session.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Gs1h5bwt3EW9bAhoPBNXgg.png" /></figure><h3>Step 7: Logging in and reaching the dashboard</h3><p>Past the certificate warning, the actual Wazuh Web Dashboard login page loaded correctly over HTTPS. I entered the default admin username along with the password generated during installation, the same one printed in the terminal output back in Step 5.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*85dwoSgkjNs_AOwTP5HxBg.png" /></figure><p>Login succeeded, landing on the <strong>Wazuh Overview Dashboard</strong>, already populated with threat intelligence metrics and a severity breakdown of alerts from the instance itself, even before any external agents had been registered.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6ASypgCVjnyBgWzXdE-Jmw.png" /></figure><h3>The takeaway</h3><p>Nothing about this deployment was exotic. A right-sized EC2 instance, a security group with exactly four ports opened for a documented reason each, one installation script, and a certificate warning that looks alarming but means the opposite of what it seems to. That last part is worth sitting with for a second: the scariest looking screen in this entire process, a full page red warning about an unsafe connection, was actually the expected, correct behavior of a properly functioning self-signed certificate.</p><p>That’s a pattern worth carrying into other tools too. Not every red warning means something broke. Sometimes it means the safety mechanism noticed exactly what it was built to notice, and the next step is simply understanding why, not panicking and starting over. Being able to tell the difference between “this is broken” and “this is a security control doing its job” is arguably a bigger skill than knowing which button to click next.</p><p><em>If you’re setting this up yourself, don’t let the certificate warning talk you out of continuing. Read the error message, understand why it’s there, and proceed deliberately. That’s a more useful habit than either blindly clicking through every warning or stopping cold at the first one.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=de1b32dd5c1d" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>