Ubuntu Cloud & Linux Security Cheat Sheet for AU DevOps
Provision Ubuntu with Terraform, run auto-restart Docker containers, and lock SSH keys with chmod 600 — a practical beginner-to-pro cheat sheet for Australian server owners, plus when to book Fixwebnode remote support.
This guide is for Australian homeowners, small-business operators, and junior DevOps engineers who need a clear path from a bare cloud VM to a hardened Ubuntu server — Terraform-provisioned, Docker-backed, and free of the classic chmod 777 mistake on private SSH keys.
If your app dies after a reboot, Terraform plans fail on the wrong Ubuntu image, or SSH suddenly rejects your key, you are not alone. Fixwebnode provides direct remote server support across Australia for exactly this stack: Infrastructure-as-Code, container runtime hygiene, and Linux permission hardening — not a freelance marketplace, a specialist you can book when DIY stops being safe.
Why cloud architecture and Linux security matter on Ubuntu
Modern DevOps work in Australia almost always lands on Ubuntu LTS images in AWS, Azure, or GCP. The reliable pattern is simple: declare the server in Terraform, ship the workload with docker run -d -p 80:8080 --restart always, and protect access with private keys set to mode 600. Skip any of those three and you get flaky deploys, silent outages after reboot, or keys that OpenSSH refuses to use (or worse, keys that anyone on the box can read).
This cheat sheet stays on that path only: provision, containerise with auto-restart, and secure SSH the right way — with real commands you can paste over SSH or in a CI runner.
What breaks Ubuntu Terraform, Docker restart, and SSH keys in Australia?
Searchers often ask a blunt question when a new cloud box will not stay healthy. Here is the short answer before we dig into fixes.
Why did my Ubuntu Docker container stop after reboot, and is my SSH key insecure?
Containers started without --restart always (or a Compose/systemd equivalent) do not come back after a host reboot. Private keys left at 644 or 777 are either rejected by OpenSSH or dangerously world-readable. Fix the run flags and lock key mode to 600 before you expose port 22 to the internet.
| Symptom | Quick fix | When to call Fixwebnode |
|---|---|---|
| Container gone after reboot | Recreate with docker run ... --restart always | Orchestration, multiple hosts, or unknown images |
| SSH: “UNPROTECTED PRIVATE KEY FILE” | chmod 600 on the key; never 777 | Key compromise suspected or fleet-wide access |
| Terraform apply fails on Ubuntu AMI/image | Pin a current Ubuntu LTS image + cloud-init | Multi-account IaC or state lock issues |
Common issues (unique symptoms)
1. Terraform provisions the wrong Ubuntu image or leaves SSH locked out
Symptom: terraform apply succeeds but you cannot SSH, cloud-init never installs Docker, or the instance is a non-LTS daily build that drifts from your playbooks.
2. Containers exit and stay down after host reboot or Docker daemon restart
Symptom: site on port 80 is dead every morning; docker ps is empty; you previously used a plain docker run -d -p 80:8080 without a restart policy.
3. Private SSH key permissions are too open (the chmod 777 trap)
Symptom: Permissions 0777 for 'id_rsa' are too open or keys copied to shared folders with world read/write — a direct path to credential theft on multi-user jump hosts.
4. Port publish works locally but UFW or security groups block Australia-facing traffic
Symptom: curl localhost:80 works on the VM; external clients time out; Docker published 80:8080 but host firewall still drops packets.
How to fix issue 1 — Provision Ubuntu correctly with Terraform
Declare a current Ubuntu LTS image, inject your public key via cloud-init or the provider’s key resource, and open only the ports you need. Example shape for a generic cloud provider (adjust provider block to AWS/Azure/GCP as required):
Step 1 — Initialise and validate
terraform version
terraform init
terraform validate
terraform plan -out=tfplanStep 2 — Pin Ubuntu LTS and user-data for Docker
# snippets inside main.tf (illustrative)
# data source or image SKU = Ubuntu 22.04 or 24.04 LTS only
resource "local_file" "cloud_init" {
filename = "${path.module}/cloud-init.yaml"
content = <<EOF
#cloud-config
package_update: true
packages:
- docker.io
- ufw
runcmd:
- systemctl enable --now docker
- ufw allow OpenSSH
- ufw allow 80/tcp
- ufw --force enable
EOF
}Step 3 — Apply and confirm SSH
terraform apply tfplan
ssh -i ~/.ssh/id_ed25519_ubuntu ubuntu@YOUR_SERVER_IP 'uname -a && docker --version'Step 4 — Verify cloud-init finished
ssh -i ~/.ssh/id_ed25519_ubuntu ubuntu@YOUR_SERVER_IP 'cloud-init status --wait && systemctl is-active docker'If SSH still fails, check the provider console serial log for cloud-init errors and confirm the public key fingerprint matches the private key on your laptop. When state is locked across a team or you manage multiple Australian accounts, book remote help rather than deleting state files by hand.
How to fix issue 2 — Deploy auto-restarting containers the DevOps way
A detached publish without a restart policy is the number-one reason small AU business sites vanish after patch reboots.
Step 1 — Inspect what is running
sudo docker ps -a
sudo docker inspect --format '{{.Name}} Restart={{.HostConfig.RestartPolicy.Name}}' $(sudo docker ps -aq)Step 2 — Stop and remove the fragile container (note the name/id first)
sudo docker stop myapp || true
sudo docker rm myapp || trueStep 3 — Recreate with the production-minded flags from this cheat sheet
sudo docker run -d \
--name myapp \
-p 80:8080 \
--restart always \
--log-driver json-file \
--log-opt max-size=10m \
--log-opt max-file=3 \
your-registry.example/your-image:stableStep 4 — Prove restart policy survives a daemon bounce
sudo systemctl restart docker
sleep 3
sudo docker ps --filter name=myapp
curl -I http://127.0.0.1/Step 5 — Optional hardening: drop Linux capabilities you do not need
sudo docker run -d --name myapp -p 80:8080 --restart always \
--read-only --cap-drop ALL --cap-add NET_BIND_SERVICE \
your-registry.example/your-image:stableDIY is enough for a single VM. Call Fixwebnode when you need rolling updates, secrets injection, or Nginx in front of several upstream containers.
How to fix issue 3 — Secure private SSH keys (never chmod 777)
OpenSSH will refuse keys that are group- or world-accessible. Worse, chmod 777 on a private key makes theft trivial on any shared workstation or misconfigured CI runner.
Step 1 — Diagnose current mode
ls -l ~/.ssh/id_ed25519 ~/.ssh/id_rsa 2>/dev/null
stat -c '%a %n' ~/.ssh/id_ed25519 ~/.ssh/id_rsa 2>/dev/nullStep 2 — Lock down directory and private keys
chmod 700 ~/.ssh
chmod 600 ~/.ssh/id_ed25519 ~/.ssh/id_rsa 2>/dev/null
chmod 644 ~/.ssh/id_ed25519.pub ~/.ssh/id_rsa.pub ~/.ssh/known_hosts 2>/dev/null
chmod 600 ~/.ssh/config 2>/dev/nullStep 3 — On the Ubuntu server, fix authorized_keys the same way
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys
sudo chown -R ubuntu:ubuntu /home/ubuntu/.sshStep 4 — Test authentication with verbose SSH
ssh -i ~/.ssh/id_ed25519 -o IdentitiesOnly=yes -vvv ubuntu@YOUR_SERVER_IP trueStep 5 — If the key was ever mode 777 or copied to chat/email, rotate it
ssh-keygen -t ed25519 -a 100 -f ~/.ssh/id_ed25519_ubuntu_new -C "au-prod-$(date +%F)"
ssh-copy-id -i ~/.ssh/id_ed25519_ubuntu_new.pub ubuntu@YOUR_SERVER_IP
# then remove the old public key line from authorized_keys on the serverNever “fix” a stubborn key with chmod 777. That is the dangerous shortcut this cheat sheet exists to stop. If you suspect the private key left your control, rotate immediately and review auth.log for unexpected logins:
sudo grep -E 'Accepted|Failed' /var/log/auth.log | tail -n 50How to fix issue 4 — Firewall and publish path for port 80
Step 1 — Confirm Docker is listening on the host
sudo ss -tlnp | grep -E ':80|:8080'
sudo docker port myappStep 2 — Allow SSH and HTTP in UFW without disabling the firewall
sudo ufw status verbose
sudo ufw allow OpenSSH
sudo ufw allow 80/tcp
sudo ufw reload
sudo ufw status numberedStep 3 — Mirror the same rule in your cloud security group / NSG (provider console or Terraform ingress on TCP 80 and 22 from known admin IPs only).
Step 4 — From your laptop in Australia, verify path
curl -I --max-time 10 http://YOUR_SERVER_IP/Beginner-to-pro mini runbook (end-to-end order)
- Generate an ed25519 key pair; set private key to mode 600 before first use.
- Terraform-apply an Ubuntu LTS VM with cloud-init installing Docker and UFW.
- SSH in, confirm
docker --versionandcloud-init status. - Run the workload with
docker run -d -p 80:8080 --restart always. - Restart Docker once on purpose and confirm the container returns.
- Tighten UFW and cloud firewalls; disable password SSH if keys work.
- Document image tags and Terraform state backend so the next change is repeatable.
When DIY is enough vs when to book Fixwebnode
DIY is enough when you control one Ubuntu VM, can still SSH with a working key, and the failure is a missing restart policy, a wrong file mode, or a simple UFW rule. The commands above are safe on a non-production box first; always snapshot or take a provider backup before changing firewall or SSH daemon settings.
Book a specialist when any of these are true: you are locked out of SSH entirely; Terraform state is corrupted or locked across a team; you need production load balancing, TLS termination, or multi-region failover; private keys may have leaked; or a customer-facing store cannot tolerate trial-and-error. Fixwebnode works remotely with Australian teams as a direct provider for secure Linux admin and full-stack infrastructure — see Secure Linux Admin & Full-Stack Infrastructure Australia. For geography coverage only, browse all service areas. Related hardened edge work is also documented under our Nginx load balancer direct expert config guide when you outgrow a single docker run publish.
Closing — keep the cheat sheet, get help when it counts
Stay on the three rails: Terraform for Ubuntu LTS, docker run -d -p 80:8080 --restart always for durable containers, and chmod 600 on private keys so you never reach for chmod 777. That sequence alone prevents most beginner outages we see on Australian small-business servers.
If you want a second pair of eyes on IaC, container restart behaviour, or SSH hardening, start a conversation with Fixwebnode via the Ubuntu Linux server support page: https://fixwebnode.com.au/ubuntu-linux-server-support-bug-fixing-adelaide-australia. Bring your error text, Terraform plan output, and docker ps -a — we will tell you plainly whether DIY still makes sense or a remote session is the faster path.