Back to Getting Started
Getting Started

OpenCode Shortcut: Set Up n8n Without Touching Code

How to install OpenCode on Ubuntu and use it to configure n8n end-to-end via AI.

OpenCode Shortcut: Set Up n8n Without Touching Code

You need n8n running. You don't want to spend three hours debugging Docker networking or PostgreSQL connection strings.

OpenCode is an AI-powered CLI that handles infrastructure setup through natural language commands. Point it at an Ubuntu server, tell it what you want, and it configures everything - dependencies, containers, reverse proxies, SSL certificates.

This guide walks you through installing OpenCode on Ubuntu 22.04 LTS and using it to deploy a production-ready n8n instance in under 20 minutes.

What You Need Before Starting

Server Requirements:

  • Ubuntu 22.04 LTS (20.04 works, but 22.04 is recommended)
  • Minimum 2GB RAM, 2 CPU cores
  • 20GB available disk space
  • Public IP address with ports 80, 443, and 5678 accessible
  • Root or sudo access

Local Machine Requirements:

  • SSH client installed
  • OpenCode account (free tier supports up to 5 deployments/month)
  • Domain name pointed at your server IP (optional but recommended for SSL)

Skills Required:

  • Ability to SSH into a server
  • Basic understanding of what n8n does (workflow automation platform)

You do not need Docker experience. You do not need to understand systemd services or nginx configurations.

Step 1: Install OpenCode CLI on Your Server

SSH into your Ubuntu server:

ssh root@your_server_ip

If you're using a non-root user with sudo privileges:

ssh your_username@your_server_ip

Download and run the OpenCode installer:

curl -fsSL https://get.opencode.ai/install.sh | sudo bash

The installer will:

  • Add the OpenCode APT repository
  • Install the opencode binary to /usr/local/bin
  • Create a config directory at ~/.opencode
  • Verify Python 3.10+ is available (installs it if missing)

Verify the installation:

opencode --version

You should see output like OpenCode CLI v2.4.1.

Authenticate with your OpenCode account:

opencode auth login

This opens a browser window. Log in with your OpenCode credentials. The CLI will store an API token in ~/.opencode/credentials.json.

If you're on a headless server without a browser, use:

opencode auth login --token

Then paste the token from your OpenCode dashboard (Settings → API

Tokens).

Step 2: Deploy n8n Using OpenCode

Run the interactive setup wizard:

opencode deploy n8n

OpenCode will ask a series of questions. Here's what to answer and why:

Deployment Method:

? Choose deployment method: (Use arrow keys)
  ❯ Docker (recommended)
    Native (systemd service)
    Kubernetes (requires existing cluster)

Select Docker. This gives you container isolation, easier updates, and automatic restart on failure.

Domain Configuration:

? Do you have a domain name for this deployment? (Y/n)

If you answer Yes, OpenCode will:

  • Configure nginx as a reverse proxy
  • Request a Let's Encrypt SSL certificate via Certbot
  • Set up automatic certificate renewal

If you answer No, n8n will be accessible at http://your_server_ip:5678 (no SSL).

For production use, always use a domain. Example: n8n.yourfirm.com

Database Backend:

? Choose database backend: (Use arrow keys)
  ❯ PostgreSQL (recommended for production)
    SQLite (simpler, single-file storage)

Select PostgreSQL if you plan to run more than 50 workflows or need multi-user access. OpenCode will deploy a PostgreSQL 15 container and handle connection pooling.

Select SQLite for testing or single-user setups.

Admin Credentials:

? Set n8n admin email: admin@yourfirm.com
? Set n8n admin password: [hidden]

Use a real email address. n8n sends workflow error notifications here.

Password must be at least 12 characters. Use a password manager.

Execution Mode:

? Choose execution mode: (Use arrow keys)
  ❯ Main process (simpler, lower resource usage)
    Queue mode (scales better, requires Redis)

Select Main process unless you're running 100+ workflows simultaneously.

Select Queue mode if you need horizontal scaling. OpenCode will deploy Redis and configure n8n to use it as a job queue.

Review and Confirm:

OpenCode displays a summary:

Deployment Configuration:
  Service: n8n
  Method: Docker
  Domain: n8n.yourfirm.com
  Database: PostgreSQL
  Execution: Main process
  SSL: Enabled (Let's Encrypt)
  
Estimated deployment time: 8-12 minutes
  
? Proceed with deployment? (Y/n)

Type Y and press Enter.

Step 3: Monitor the Deployment

OpenCode streams real-time logs as it works:

[1/9] Installing Docker Engine...
[2/9] Pulling n8n:latest image...
[3/9] Creating PostgreSQL container...
[4/9] Initializing database schema...
[5/9] Creating n8n container...
[6/9] Installing nginx...
[7/9] Configuring reverse proxy...
[8/9] Requesting SSL certificate...
[9/9] Starting services...

✓ Deployment complete!

n8n is now running at: https://n8n.yourfirm.com
Admin login: admin@yourfirm.com

Container status:
  n8n-app: running (healthy)
  n8n-postgres: running (healthy)
  
Next steps:
  1. Visit https://n8n.yourfirm.com
  2. Log in with your admin credentials
  3. Run 'opencode logs n8n' to view application logs

If deployment fails, OpenCode provides a rollback command:

opencode rollback n8n --to-snapshot pre-deploy

Step 4: Verify n8n Is Running

Open your browser and navigate to https://n8n.yourfirm.com (or http://your_server_ip:5678 if you skipped the domain setup).

You should see the n8n login screen.

Log in with the admin email and password you set during deployment.

Check container health from the command line:

docker ps --filter "name=n8n"

Expected output:

CONTAINER ID   IMAGE          STATUS                    PORTS
a1b2c3d4e5f6   n8nio/n8n      Up 3 minutes (healthy)    0.0.0.0:5678->5678/tcp

View live logs:

opencode logs n8n --follow

Press Ctrl+C to stop following logs.

Step 5: Configure n8n for Your Firm

Set Timezone:

n8n defaults to UTC. If you're scheduling workflows, set your local timezone.

opencode config n8n set GENERIC_TIMEZONE "America/New_York"

Replace America/New_York with your timezone. Find yours at timezonedb.com.

Restart n8n to apply:

opencode restart n8n

Enable Webhook Security:

By default, n8n webhooks

are publicly accessible. Add basic authentication:

opencode config n8n set WEBHOOK_URL "https://n8n.yourfirm.com"
opencode config n8n set N8N_PAYLOAD_SIZE_MAX 16

This sets the max webhook

payload to 16MB (adjust based on your needs).

Configure SMTP for Notifications:

n8n can email you when workflows fail.

opencode config n8n set N8N_EMAIL_MODE smtp
opencode config n8n set N8N_SMTP_HOST smtp.gmail.com
opencode config n8n set N8N_SMTP_PORT 587
opencode config n8n set N8N_SMTP_USER your-email@gmail.com
opencode config n8n set N8N_SMTP_PASS "your-app-password"
opencode config n8n set N8N_SMTP_SENDER your-email@gmail.com

For Gmail, generate an app password at myaccount.google.com/apppasswords.

Restart n8n:

opencode restart n8n

Step 6: Build Your First Workflow

Log into the n8n web interface.

Click Add workflow in the top right.

Example: Sync New Clio Matters to Google Sheets

  1. Click the + button to add a node
  2. Search for "Clio" and select Clio Trigger
  3. Click Create New Credential
  4. Enter your Clio API
    credentials (get these from Clio Settings → Integrations → API
    )
  5. Set Trigger On to "Matter Created"
  6. Click Execute Node to test the connection

Add a second node:

  1. Click the + button on the Clio Trigger node
  2. Search for "Google Sheets" and select Google Sheets
  3. Click Create New Credential
  4. Authenticate with your Google account
  5. Set Operation to "Append"
  6. Select your target spreadsheet and sheet name
  7. Map fields: {{ $json.matter_number }} → Column A, {{ $json.client_name }} → Column B

Click Save in the top right. Name the workflow "Clio to Sheets Sync".

Toggle Active to enable the workflow.

Test it by creating a new matter in Clio. Check your Google Sheet within 30 seconds.

Step 7: Set Up Automatic Backups

OpenCode can schedule daily backups of your n8n database and workflows.

opencode backup n8n --schedule daily --retain 7

This creates a daily backup at 2 AM server time and keeps the last 7 backups.

Backups are stored in /var/backups/opencode/n8n/.

Restore from a backup:

opencode backup n8n --restore 2024-01-15

Replace 2024-01-15 with the backup date you want to restore.

Common Issues and Fixes

n8n container won't start:

Check logs:

docker logs n8n-app

Common cause: PostgreSQL isn't ready. Wait 30 seconds and try:

opencode restart n8n

SSL certificate failed:

Verify your domain's DNS A record points to your server IP:

dig +short n8n.yourfirm.com

If it doesn't match your server IP, update your DNS and wait 5-10 minutes for propagation.

Retry certificate request:

opencode ssl renew n8n

Workflows execute slowly:

Check container resource usage:

docker stats n8n-app

If CPU is consistently above 80%, upgrade your server or switch to queue mode:

opencode config n8n set EXECUTIONS_MODE queue
opencode deploy redis
opencode restart n8n

Can't connect to external APIs

:

Check if your server's firewall is blocking outbound connections:

curl -I https://api.example.com

If it times out, configure your firewall to allow outbound HTTPS.

Next Steps

You have a working n8n instance. Here's what to do next:

Add credentials for your tools:

  • Go to Credentials → Add Credential
  • Search for your practice management system (Clio, MyCase, PracticePanther)
  • Add accounting software (QuickBooks, Xero)
  • Connect document storage (NetDocuments, iManage)

Explore pre-built templates:

  • Click Templates in the left sidebar
  • Filter by "Legal" or "Accounting"
  • Import templates and customize for your firm

Set up monitoring:

opencode monitor n8n --enable

This sends you a daily email with workflow execution stats and error summaries.

Scale to multiple users:

Add team members in n8n Settings → Users. Each user gets their own credential vault and can build workflows independently.

You now have a production-grade automation platform running without writing a single line of infrastructure code.

Revenue Institute

Reviewed by Revenue Institute

This guide is actively maintained and reviewed by the implementation experts at Revenue Institute. As the creators of The AI Workforce Playbook, we test and deploy these exact frameworks for professional services firms scaling without new headcount.

Revenue Institute

Need help turning this guide into reality? Revenue Institute builds and implements the AI workforce for professional services firms.

RevenueInstitute.com