Skip to content
configure-ubuntu logo

Configure Ubuntu Skill

configure-ubuntu

Ubuntu server configuration via cloud-init and systemd. Use when writing cloud-init YAML, configuring systemd services, setting up nginx, or troubleshooting VM configuration issues.

SKILL.md

Full skill instructions

Configure Ubuntu Skill

Purpose

This skill provides guidance for configuring Ubuntu LTS servers via cloud-init automation for any cloud platform (AWS, Azure, GCP, DigitalOcean, etc.).

Note: All examples in this skill currently use Ubuntu 24.04 LTS. Update version-specific package names or paths as needed for other LTS releases.

When to Use This Skill

Use this skill when:

  • Writing cloud-init YAML for VM provisioning
  • Configuring systemd services
  • Setting up nginx reverse proxies
  • Troubleshooting cloud-init or systemd issues
  • Setting file permissions for service users

Reference Selection Guide

Choose the appropriate reference based on your task:

TaskReference File
Complete cloud-init configurationsreferences/​examples/​*.yaml
Cloud-init syntax and patternsreferences/​cloud-init-patterns.md
systemd service unitsreferences/​systemd-patterns.md
Debugging failures or errorsreferences/​common-pitfalls.md

Ready-to-Use Examples

ExampleFile
SSH bastion hostreferences/​examples/​bastion.yaml
Nginx reverse proxy (HTTP)references/​examples/​proxy-http.yaml ← default
Nginx reverse proxy (HTTPS, self-signed)references/​examples/​proxy-https.yaml
Nginx reverse proxy (HTTPS, Let's Encrypt)references/​examples/​proxy-https-letsencrypt.yaml
Nginx static file serverreferences/​examples/​static-files.yaml
Python/​Flask serverreferences/​examples/​flask.yaml
Node.js serverreferences/​examples/​nodejs.yaml
Java/​Spring Boot serverreferences/​examples/​java.yaml
.NET serverreferences/​examples/​dotnet.yaml

HTTPS Options:

  • Use proxy-http.yaml by default (no SSL)
  • Use proxy-https.yaml for self-signed certificates (development/​internal)
  • Use proxy-https-letsencrypt.yaml for trusted certificates (requires domain name)

When to Read Multiple References

  • New VM setup: Start with relevant example, then cloud-init-patterns.md for customization
  • Service won't start: common-pitfalls.md + systemd-patterns.md
  • SSH access broken: common-pitfalls.md (Issue #1)
  • Permission denied errors: common-pitfalls.md (Issues #4, #5, #6)
  • Scheduled tasks: systemd-patterns.md (Systemd Timers section)
  • Production HTTPS: proxy-https-letsencrypt.yaml (requires domain name)
  • Static website: static-files.yaml + proxy-http.yaml (if reverse proxy needed)

Critical Rules (Memorize These)

These rules prevent the most common failures:

  1. NEVER use users: directive in cloud-init — Deletes default SSH user, breaks access
  2. Systemd: NO inline comments — After=network.target # comment fails
  3. Permissions as quoted strings — Use '0640' not 0640 in cloud-init
  4. Wait for cloud-init — Takes 2-3 minutes; don't deploy until done
  5. Absolute paths in systemd — Use /​opt/​app/​venv/​bin/​python not python
  6. Fix permissions after SCP — Files copied retain local permissions

Default Choices for Vague Requests

When the request is ambiguous, use these defaults:

DecisionDefault ChoiceRationale
Application frameworkFlask/​PythonCourse standard, most examples
Reverse proxyHTTP (not HTTPS)Simpler, use proxy-http.yaml
Application port5001Avoids conflict with common ports
Proxy port80 (HTTP) or 443 (HTTPS)Standard web ports
App directory/​opt/<app-name>/Standard for third-party apps
Config directory/​etc/<app-name>/Standard for system config
Service user<app-name>Same as app, no login shell
Ownership patterndeployuser:servicegroupDeploy user writes, service reads
Directory permissions775Group can write (venv installs)
Config file permissions640Owner writes, group reads
WSGI serverGunicornProduction-ready, simple config

Example Defaults

"Set up a web application server" → Use:

  • examples/​flask.yaml for application VM
  • examples/​proxy-http.yaml for proxy VM
  • Port 5001 for Flask, port 80 for nginx

"Configure nginx" → Use:

  • examples/​proxy-http.yaml (reverse proxy, not static files)
  • Unless HTTPS explicitly requested, then proxy-https.yaml

"Set up a secure bastion" → Use:

  • examples/​bastion.yaml (includes UFW + fail2ban)

Environment Variables Pattern

This is the standard way to handle environment variables (database credentials, API keys, connection strings) on the server.

Directory Structure

/​etc/<app-name>/
└── environment      # All environment variables for the application

Setup in Cloud-init

runcmd:
  # Create config directory owned by root, readable by app group
  - mkdir -p /​etc/​myapp
  - chown root:myapp /​etc/​myapp
  - chmod 750 /​etc/​myapp

  # Create environment file with restricted permissions
  - touch /​etc/​myapp/​environment
  - chown root:myapp /​etc/​myapp/​environment
  - chmod 640 /​etc/​myapp/​environment

Reference from systemd

[Service]
EnvironmentFile=/​etc/​myapp/​environment

Environment File Format

# /​etc/​myapp/​environment
DATABASE_URL=postgresql://user:password@host:5432/​dbname
SECRET_KEY=your-secret-key-here
API_KEY=external-service-api-key
DEBUG=false

Why This Pattern?

ConcernSolution
SecurityFile owned by root, only readable by app group (mode 640)
SeparationConfig in /​etc/, code in /​opt/ — different concerns, different locations
DeploymentEnvironment file can be updated without redeploying code
systemd integrationEnvironmentFile= loads variables automatically

Quick Reference Tables

Default SSH Users by Cloud Provider

ProviderDefault User
AWS (Amazon Linux)ec2-user
AWS (Ubuntu)ubuntu
Azureazureuser
GCPYour Google account username
DigitalOceanroot
Linoderoot

File Permission Patterns

PurposeOwner:GroupMode
Application codedeployuser:appgroup640
Application directorydeployuser:appgroup775
Config with secretsroot:appgroup640
Config directoryroot:appgroup750
systemd service filesroot:root644

Common systemctl Commands

sudo systemctl daemon-reload    # After editing service files
sudo systemctl enable myapp     # Start on boot
sudo systemctl start myapp      # Start now
sudo systemctl status myapp     # Check status
sudo journalctl -u myapp -f     # Follow logs

Cloud-init Verification

cloud-init status               # Check status
cloud-init status --wait        # Block until complete
sudo cat /​var/​log/​cloud-init-output.log  # View logs

Reference Summaries

examples/ directory

Ready-to-use cloud-init YAML files for common server types. Copy and customize for your use case.

cloud-init-patterns.md

Reference documentation for cloud-init syntax:

  • Module execution order
  • Package management (packages, package_update)
  • Writing configuration files (write_files)
  • Running commands (runcmd)
  • Debugging and lifecycle

systemd-patterns.md

Reference documentation for systemd services:

  • Service unit file structure ([Unit], [Service], [Install])
  • Service types (simple, forking, oneshot)
  • Environment configuration
  • Restart policies and resource limits
  • Systemd timers (scheduled tasks, replacement for cron)
  • Managing and debugging services

common-pitfalls.md

Prevention checklist and solutions for:

  • Cloud-init issues (user deletion, timing)
  • systemd issues (inline comments, permissions)
  • File permission problems
  • SSH and networking issues

More skills from majiayu000

xiaohongshu logo
majiayu000/claude-arsenal

xiaohongshu

xiaohongshu

286 148
View
agent-task-conductor logo
majiayu000/claude-skill-registry

agent-task-conductor

Conduct multi-agent task orchestration and workflow coordination.

663 1
View
conductor-setup logo
majiayu000/claude-skill-registry

conductor-setup

Initialize project with Conductor artifacts (product definition,

663 1
View
animation-designer logo
majiayu000/claude-skill-registry

animation-designer

Expert in web animations, transitions, and motion design using Framer Motion and CSS

663 1
View
diagramming logo
majiayu000/claude-skill-registry

diagramming

Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...

663 1
View
h3-pg logo
majiayu000/claude-skill-registry-data

h3-pg

PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.

23 1
View
conductor-development logo
majiayu000/claude-skill-registry

conductor-development

Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...

663 1
View
conductor-status logo
majiayu000/claude-skill-registry

conductor-status

Display project status, active tracks, and next actions

663 1
View
dockerization logo
majiayu000/claude-skill-registry

dockerization

Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.

663 1
View

Popular AI tools

Kaiber logo
Video

Kaiber

Generate, edit, and beat-sync AI video with leading models in one workspace.

Paid
View
Vimcal logo
Productivity

Vimcal

The world's fastest calendar for remote work

Free
View

Transform Your Design with AI Designer by ImgCreator.ai

Freemium
View
Akool AI logo
Content & writing

Akool AI

Revolutionizing Video Production with AI-Powered Creativity

Paid
View

Extend an image past the frame and let AI fill the new aspect ratio.

Freemium
View
StarByFace logo
Security

StarByFace

Discover your celebrity doppelgänger with StarByFace!

Free
View
C

ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.

Freemium
View
Opus Clip logo
Coding & apps

Opus Clip

Opus.ai: Revolutionize Your Web Experience

Free
View