Description #
Imaxe Hardened Memcached is a hardened, production-ready Memcached AMI, designed as a drop-in replacement for “Memcached packaged by Bitnami”. It installs Memcached from the standard Ubuntu packages — apt, systemd and FHS paths, with no monolithic trees under /opt and no proprietary supervisors — on top of the imaxe hardened base.
Two out-of-the-box security differences from the Bitnami product: SASL authentication comes enabled (not disabled), with a unique per-instance password, and network traffic is encrypted with TLS, with a certificate also generated on each instance. Since memcached’s only SASL mechanism is PLAIN, without TLS the password would travel in the clear — here that cannot happen.
The rest is the imaxe hardened base: default-deny firewall, hardened SSH, AppArmor in enforce mode, auditing with auditd, file integrity with AIDE, rootkit detection with rkhunter, ClamAV antivirus and brute-force protection with fail2ban. All of it verified on every release with a Lynis audit whose full report you can read below.
Quick start: up and running in 5 minutes #
Everything you need to go from zero to a hardened cache in production.
No need to wrestle with the AWS console. The imaxe launcher is a guided form that asks you only the essentials — region, instance type, network and SSH access — and generates a CloudFormation template that deploys the AMI already configured. It saves you the typical manual-launch mistakes (wrong architecture, security group open too wide, keypair not assigned) and leaves the whole stack under your control in your own account.
If you’d rather do it by hand, the long way is five steps:
| Step | Action | Where | Time |
|---|---|---|---|
| 1 | Subscribe and launch the AMI — any arm64 (Graviton) instance; t4g.medium is the recommended one. Includes a 7-day free trial. | AWS Marketplace → EC2 | ~2 min |
| 2 | Open port 22 in the security group, restricted to your IP or CIDR. Port 11211 comes closed on purpose: open it only to your VPC CIDR if your application lives on another machine. | EC2 console | 1 min |
| 3 | Read the SASL credential — it’s in the system console (EC2 System Log) or, over SSH, with sudo imaxe memcached credentials. On first boot the password is the instance-id. | EC2 console or SSH | 1 min |
| 4 | Connect your client with TLS + SASL: user memcached, the instance’s password and port 11211. The certificate is self-signed: tell your client to trust /etc/memcached/tls/server.crt. | Your application | ~1 min |
| 5 | Done — the cache size is already tuned to the instance. Explore the state with imaxe memcached status. | The instance | — |
There is no setup wizard and no mandatory follow-up steps: the image ships hardened and sized out of the box. The rest of this page is optional. If something goes wrong, head straight to troubleshooting.
Features #
Everything the image includes, grouped into what is standard and what is ours.
General
- Memcached 1.6 from the official Ubuntu 26.04 LTS packages (resolute, arm64), managed with systemd — no trees under
/opt, no proprietary scripts. - Ubuntu base updated on every build, with automatic security patches (
unattended-upgrades) enabled. ufwfirewall in default-deny: only 22 (SSH) and 11211 (memcached) allowed locally; the Marketplace security group only exposes 22.- Hardened SSH: no root, no passwords, public key only, modern cryptography (ed25519, chacha20-poly1305, post-quantum kex sntrup761x25519).
- AppArmor with extra profiles installed and all of them in enforce mode.
- Kernel hardened via sysctl, mounts with
noexec,nosuid,nodev,/procwithhidepid=2. - Full auditing with
auditd, integrity with AIDE and debsums, anti-malware with rkhunter and ClamAV, fail2ban integrated with ufw.
Special
- SASL mandatory out of the box: user
memcachedwith a unique per-instance password (the instance-id on first boot), dumped to the EC2 system console — where anyone coming from Bitnami looks for it. Nothing is baked into the AMI: every instance gets a fresh credential. - TLS built into port 11211 (minimum TLS 1.2): a self-signed certificate issued on each instance — EC P-256 key, instance-id as CN, the instance’s IPs and names as SANs — before the service starts. You can install your own.
- Port 11212 in the clear on loopback only, for the system tools (
memcstatand friends don’t speak TLS). It still requires SASL and is not reachable from outside. - UDP affirmatively disabled (
-U 0): memcached’s UDP protocol is the classic DDoS amplification vector. - Automatic tuning on every boot:
imaxe memcached optimizerecomputes cache memory, connections and threads from the real CPU and RAM — stop the instance, change the type, boot, and the cache resizes itself. - SASL user management with no restarts:
imaxe memcached users add/rotate/delete— the SASL database is read on every authentication and the cache is not flushed. imaxetool included: a CLI to operate the service, the credentials, the certificate and all the hardening without editing files by hand.- Lynis audit on every release, with the full report published on this page.
imaxe modules
Modules of the imaxe tool baked into this AMI, with their documentation:
| Module | What it does | Documentation |
|---|---|---|
| memcached | The product’s module: status, credentials, SASL users, TLS and automatic service tuning. | View docs → |
| os | System base: unattended updates, locale, time zone, hostname and time. | View docs → |
| ssh | Authorized keys, host keys, active sessions and sshd hardening from a single command. | View docs → |
| firewall | ufw status, blocking/unblocking IPs and opening or closing ports. | View docs → |
| audit | auditd events and CIS audit rules without fighting auditctl. | View docs → |
| aide | File integrity monitoring (FIM) with AIDE. | View docs → |
| rkhunter | Scans the server for rootkits. | View docs → |
| clamav | ClamAV antivirus at runtime. | View docs → |
| lynis | System hardening audit with an actionable report. | View docs → |
| fail2ban | Jail status, banned IPs, manual ban and unban. | View docs → |
| secrets | Generates, reads and rotates the instance’s local secrets — including the SASL password. | View docs → |
| info | AMI inventory at /etc/imaxe/info.yaml, with no secrets. | View docs → |
| global-alerts | The instance’s cross-cutting alert bus (SNS). | docs in progress |
Sizing and costs #
The AMI runs on any AWS arm64 (Graviton) instance and sizes itself: on every boot, imaxe memcached optimize assigns 60% of the usable RAM to the cache (after reserving 512 MB for the OS and the agents) and derives threads and connections from the instance size. Pick the type by the cache you need: more RAM = more cache, with no configuration changes. The recommended starting instance is t4g.medium, which is also where this image’s builds and tests run.
| Item | Price |
|---|---|
| Hourly subscription | $0.014/h per instance |
| Annual subscription | $99/year per instance |
| Free trial | 7 days |
On top of the subscription price you pay the usual AWS costs (EC2 instance, EBS disk and traffic), billed directly by AWS at your rate. Memcached is an in-memory cache: prioritise RAM over disk when choosing the instance.
Lynis reports #
Result of the Lynis hardening audit for each published version: hardening index, warnings and suggestions, with the full line-by-line report.
| Version | Hardening index | Tests | Warnings | Suggestions | Audit | Report |
|---|---|---|---|---|---|---|
| v2.0 | 100/100 | 241 | 0 | 0 | 2026-08-15 | HTML · PDF ↓ |
| v1.0 | 94/100 | 244 | 1 | 1 | 2026-08-05 | HTML · PDF ↓ |
The hardening index is computed by Lynis from the tests passed. We rerun the audit on every release and manually review every warning and suggestion before uploading the image to the Marketplace; the detail of the open findings is in the report itself.
Available versions #
Versions of this AMI published on AWS Marketplace:
| Version | Memcached | Ubuntu | Architecture | Status | Published |
|---|---|---|---|---|---|
| v2.0 | 1.6 | 26.04 LTS (resolute) | arm64 | ✓ active | 2026-08 |
| v1.0 | 1.6 | 24.04 LTS (noble) | arm64 | ✓ active | 2026-08 |
Lifecycle
v2.0 is the current version, active and maintained: Ubuntu security patches reach the instances on their own via unattended-upgrades, and we publish new AMI versions on the Marketplace on a regular cadence, each with its own Lynis audit. When a new version ships it will appear in this table and in the changelog.
How to launch the AMI #
The AMI follows the standard EC2 launch flow on arm64 (Graviton) instances. The Marketplace security group only exposes one port:
| Type | Protocol | Port | Source |
|---|---|---|---|
| (*) SSH | TCP | 22 | your CIDRs |
| Memcached (optional) | TCP | 11211 | only your VPC CIDR or your clients’ SG |
Port 11211 comes closed in the security group on purpose, same as in the Bitnami product. Even with TLS in the way, open it only to your private network — never 0.0.0.0/0. The internal firewall (ufw) already allows it, so the security group rule is all you need. For occasional access from outside, use an SSH tunnel: ssh -i key.pem -L 11211:127.0.0.1:11211 ubuntu@<public-ip> (port forwarding is allowed on this AMI, unlike the rest of the imaxe images). Inside the instance, sudo imaxe memcached open-port --cidr <your-network> and close-port control the local firewall.
v2.0 is published for the arm64 architecture: pick a Graviton family (t4g, m7g/m8g, c6g–c8g, r7g/r8g…). It does not boot on x86_64 instances.
Once it’s running — SSH: user ubuntu with the keypair chosen at launch. There is no accessible root user and no password authentication. Cache credential: SASL user memcached with the instance-id as the initial password, visible in the EC2 system console or over SSH:
ssh -i mi-keypair.pem ubuntu@<ip-de-la-instancia>
sudo imaxe memcached credentials # usuario, password y puerto
imaxe memcached tls show # huella del certificado de esta instanciaInside the image # expert
Everything running inside the AMI, where each piece lives and the commands you’ll use day to day.
Services and ports
| Service | systemd unit | Port | What it does |
|---|---|---|---|
| Memcached | memcached.service | 11211 | The cache, with TLS (min. 1.2) and SASL both mandatory |
| Memcached (loopback) | memcached.service | 11212 | Listens in the clear on 127.0.0.1 only, for local tools; SASL is still mandatory |
| Instance setup | imaxe-memcached-instance-setup.service | — | Before memcached on every boot: TLS certificate, SASL credential and tuning. Idempotent |
| OpenSSH | ssh.service | 22 | Hardened remote access (drop-in 99-imaxe-harden.conf) |
| ufw | ufw.service | — | Default-deny firewall (allows 22 and 11211) |
| auditd | auditd.service | — | System auditing (identity, sudoers, sshd, logins) |
| fail2ban | fail2ban.service | — | SSH brute-force banning via ufw, reading the journal |
| AppArmor | apparmor.service | — | Mandatory access control, all profiles in enforce |
| freshclam | clamav-freshclam.service | — | ClamAV signature updates, 24 times a day |
| unattended-upgrades | apt-daily-upgrade.timer | — | Automatic security patches |
The memcached service is left stopped in the bake and starts for the first time on your instance: neither the certificate nor the credential exists in the AMI. The marker /etc/memcached/tls/.generated-for stores the certificate’s instance-id; if you clone the instance, the id no longer matches and the material regenerates itself.
Key paths
| Path | What it is |
|---|---|
| /etc/memcached.conf | Service configuration; the BEGIN/END imaxe memcached optimize block is rewritten by the module on every boot |
| /etc/memcached/tls/ | This instance’s TLS certificate and key (server.crt / server.key) |
| /etc/sasl2/memcached-sasldb2 | SASL user database (managed via imaxe memcached users) |
| /etc/imaxe/secrets/memcached/password | The instance’s SASL password (0600, root) |
| /etc/imaxe/memcached.yml | Configuration of the imaxe memcached module |
| /etc/ssh/sshd_config.d/99-imaxe-harden.conf | sshd hardening (drop-in, doesn’t touch the main file) |
| /etc/sysctl.d/99-zz-imaxe-harden-kernel.conf | Kernel hardening via sysctl |
| /var/log/sudo.log | Log of every sudo use |
| /usr/local/bin/imaxe | The imaxe CLI binary |
Useful commands
| Task | Command |
|---|---|
| Service status, listeners, TLS, SASL and statistics | imaxe memcached status |
| This instance’s credential | sudo imaxe memcached credentials |
| Rotate the SASL password (no restart, doesn’t flush the cache) | sudo imaxe memcached users rotate |
| SASL users: add / list / delete | sudo imaxe memcached users add app1 |
| Certificate in use (subject, SANs, expiry, fingerprint) | imaxe memcached tls show |
| Regenerate the certificate (e.g. after a public IP change) | sudo imaxe memcached tls renew –force |
| See the recommended tuning for this instance | imaxe memcached optimize –show |
| Apply the tuning now (restarts: flushes the cache) | sudo imaxe memcached optimize |
| Service logs | journalctl -u memcached |
| Instance setup logs | journalctl -u imaxe-memcached-instance-setup |
Local checks with the system tools — libmemcached-tools doesn’t speak TLS, so the cleartext loopback port is used (--binary because libmemcached only does SASL over the binary protocol):
memcstat --binary --servers=127.0.0.1:11212 --username=memcached \
--password=$(sudo imaxe memcached credentials --show-password --json | jq -r .password)To install your own certificate instead of the self-signed one:
sudo install -m 0644 -o root -g root mi.crt /etc/memcached/tls/server.crt
sudo install -m 0640 -o root -g memcache mi.key /etc/memcached/tls/server.key
sudo rm -f /etc/memcached/tls/.generated-for # sin testigo, el módulo no lo toca
sudo systemctl restart memcachedEvery hardening subsystem also has its own module in the imaxe CLI — see imaxe modules.
Backups and updates #
- Automatic patches:
unattended-upgradesapplies Ubuntu security updates daily, with no intervention. - Antivirus signatures: freshclam updates the ClamAV database 24 times a day.
- New AMIs: we publish updated versions of the image on the Marketplace on a regular cadence; every version passes its own Lynis audit before being published.
- Backups: there are none, by design. Memcached is a volatile cache: its contents are lost on every restart and it must never hold the only copy of any data. There is nothing to back up or restore.
Any systemctl restart memcached — including the one sudo imaxe memcached optimize performs when applying tuning — flushes the cache. SASL user and password changes, on the other hand, do not require a restart. And if you install or modify software, regenerate the AIDE baseline (sudo aideinit or via the imaxe aide module).
Troubleshooting #
The issues behind almost every ticket, with their usual cause and the fix.
| Symptom | Likely cause | Fix |
|---|---|---|
| The instance won’t even launch | x86_64 instance type | The AMI is arm64: use a Graviton family (t4g, c6g–c8g, m7g…) |
| Can’t connect over SSH | Port 22 closed in the security group, or your IP is outside the allowed CIDR | Check the SG — see how to launch the AMI |
Permission denied (publickey) | Password authentication is disabled | Connect as ubuntu with the launch keypair: ssh -i key.pem ubuntu@<ip> |
| SSH stops responding after several attempts | fail2ban has banned your IP (5 failures in 10 min = 1 h) | Wait an hour or, from another IP: sudo fail2ban-client set sshd unbanip <ip> |
| Can’t reach 11211 from another machine | The Marketplace security group only opens 22 | Add an SG rule for 11211 restricted to your CIDR — ufw already allows it |
| The client closes the socket on connect | The client doesn’t speak TLS, or doesn’t do SASL | Use a library with TLS + SASL (pymemcache with tls_context, php-memcached with OPT_USE_TLS…) and trust /etc/memcached/tls/server.crt |
memcstat doesn’t respond on 11211 | libmemcached-tools isn’t compiled with TLS | Use the cleartext loopback port: memcstat --binary --servers=127.0.0.1:11212 … |
| Authentication fails after cloning/replacing the instance | The credential regenerates for the new instance-id | Read the new one: sudo imaxe memcached credentials (or the EC2 system console) |
| The cache isn’t using the RAM after an instance type change | Tuning is applied at boot | Reboot the instance or run sudo imaxe memcached optimize |
Frequently asked questions #
Where is the memcached password?
On first boot, the SASL user memcached is created with the instance-id as the password. It’s dumped to the EC2 system console (System Log) — where anyone coming from Bitnami looks for it — and stored at /etc/imaxe/secrets/memcached/password. Over SSH: sudo imaxe memcached credentials.
How do I change the password or add users?
sudo imaxe memcached users rotate generates a new random password; --stdin accepts a specific one without going through the shell history. users add / users delete manage additional users. No operation restarts the service or flushes the cache.
Why won't my client connect when it worked on Bitnami?
Because here SASL and TLS come enabled out of the box (on Bitnami, SASL comes disabled). Your client needs to support TLS + SASL and trust the instance’s certificate. It’s deliberate: memcached’s only SASL mechanism is PLAIN, and without TLS the password would travel in the clear.
Can I open 11211 to the Internet?
You can — but don’t. Restrict the security group rule to your VPC CIDR or your clients’ SG, or use an SSH tunnel (-L) for occasional access. A public cache is a classic target, even encrypted.
Is the certificate self-signed? Can I install my own?
Yes and yes. The stock one is issued by each instance for itself (CN = instance-id, SANs with its IPs and names); its SHA-256 fingerprint is printed to the system console and by imaxe memcached tls show. To use yours, copy the crt/key to /etc/memcached/tls/, delete the .generated-for marker and restart — see inside the image.
How do I size the cache? What if I run short?
You don’t size it: on every boot the module assigns 60% of the usable RAM to the cache and derives threads and connections from the instance size. If you need more cache, stop the instance, switch to a type with more RAM and boot — the tuning recomputes itself.
Does it work on x86_64 instances?
No. v2.0 is published for arm64 (AWS Graviton): the t4g, c6g–c8g, m6g–m8g, r6g–r8g families, and so on.
What exactly does the subscription include?
The hardened AMI, new versions during the product’s lifecycle, and support from the team that builds it. It’s billed per instance: $0.014/h or $99/year, with a 7-day free trial.
Changelog #
AMI history. Dates are the publication date of each version on AWS Marketplace.
Ubuntu 26.04 base and Lynis 100/100
The AMI is rebuilt on Ubuntu 26.04 LTS (resolute), arm64, and the Lynis audit reaches the maximum index.
Initial release
First public version on AWS Marketplace, on Ubuntu 24.04 LTS arm64.
imaxe memcached optimize) and the imaxe tool with 13 modules baked into the image.Need help with this AMI?
You get an answer from the same team that builds the image — real engineers, no bots, no first-line triage.