# How to Set Up OpenClaw on AWS EC2 from Scratch

> A complete 18-step guide to installing OpenClaw on AWS EC2. Learn how to configure your Ubuntu instance, bypass permissions with Claude Code, and connect Telegram.

Source: https://llamapress.ai/how-to-set-up-openclaw-on-aws-ec2-from-scratch | Updated: 2026-08-01

---

[LlamaPress Blog](https://llamapress.ai/blog)

A complete 18-step guide to installing OpenClaw on AWS EC2. Learn how to configure your Ubuntu instance, bypass permissions with Claude Code, and connect Telegram.

 [Back to all articles](https://llamapress.ai/blog)

If you have been following the AI agent space, you have likely heard of OpenClaw. It is a powerful, open-source tool that lets you run an agent with full system access through familiar interfaces like Telegram or WhatsApp.

![AWS Server Rack](https://images.unsplash.com/photo-1695668548342-c0c1ad479aee?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=M3w4NTU2MDF8MHwxfHNlYXJjaHwxfHxBV1MlMjBzZXJ2ZXIlMjBkYXRhJTIwY2VudGVyfGVufDB8fHx8MTc3NjcxNjQ4Nnww&ixlib=rb-4.1.0&q=80&w=1080)

Photo by [Kevin Ache](https://unsplash.com/@kevinache?utm_source=leonardo_rails_app&utm_medium=referral) on [Unsplash](https://unsplash.com/?utm_source=leonardo_rails_app&utm_medium=referral)

However, for many business operators, the technical barrier of setting up a cloud server can be daunting. This guide is designed to bridge that gap. We will walk through every single click and command needed to move your agent from idea to execution on a dedicated AWS EC2 instance.

#### Why AWS EC2?

Running OpenClaw on your personal laptop is fine for testing, but a business-grade agent needs to be always on. AWS EC2 provides the reliability and static IP addresses required for a professional setup.

STEPS 1 - 3

## AWS Console & EC2 Dashboard

1. Register for a new AWS account, or sign into your existing one.

2. Sign into your AWS Cloud Console Home.

3. Find and Click on the “EC2” dashboard link (search “EC2” in the top search bar, if it doesn’t appear on the Console Home page).

![AWS EC2 Dashboard Search](https://llamapress-ai-image-uploads.s3.us-west-2.amazonaws.com/s114v374sy2zgp6ss2dynoqqimb4)

STEPS 4 - 5

## Launch Instance & Naming

4. In the EC2 Dashboard, click on “Launch Instance”.

5. Under “Name and tags”, type your Claw’s name. E.g., “Kody’s Claw”.

![Launch Instance Button](https://llamapress-ai-image-uploads.s3.us-west-2.amazonaws.com/lko0nrtsni9cwuosxi23thi3tbgu)

STEP 6

## OS Selection: Ubuntu 24.04

Under the “Application and OS Images (Amazon Machine Image):

- Select **Ubuntu**.
- Make sure it’s **Ubuntu Server 24.04**.
- Leave the Architecture to **64-bit (x86)**.

![Ubuntu Server 24.04 Selection](https://llamapress-ai-image-uploads.s3.us-west-2.amazonaws.com/703gfn66ja3vomzdplx7dur1iygq)

STEP 7

## Instance Type: t2.medium

Under “Instance type”, change from **t3.micro** to **t2.medium**.

T2 medium has 4GB RAM and 2vCPUs, which is the bare minimum needed for a smooth OpenClaw experience without constant crashes.

![Instance Type t2.medium](https://llamapress-ai-image-uploads.s3.us-west-2.amazonaws.com/hjx4manua0dbt0gjd5iuigdicn96)

STEPS 8 - 9

## Key Pair (Login)

8. Under “Key pair (login)” click “create new key pair”.

9. In the create key pair popup modal:

- Name your key pair.
- Select **ED25519**.
- Select **.pem**.
- Click “Create key pair”.

![Create Key Pair Link](https://llamapress-ai-image-uploads.s3.us-west-2.amazonaws.com/ddh4dxyjosvsmt0f3hlt5avyox03)

![Key Pair Settings](https://llamapress-ai-image-uploads.s3.us-west-2.amazonaws.com/55x4i2kr5gov79fsi1bmrim83y5z)

STEP 10

## Download PEM File

Your browser should automatically download your .pem file. Keep this safe; it is the only way to access your server.

![PEM File Download](https://llamapress-ai-image-uploads.s3.us-west-2.amazonaws.com/3er5frhnbban0ny2rgzv85wul5bv)

STEPS 11 - 13

## Storage & Launch

11. Keep your VPC network settings the exact same.

12. ⚠️ **Bump the 8GB Up to 30GB!** OpenClaw generates a lot of logs, and you’ll want space on your device.

13. Click “Launch Instance”.

![Storage and Launch Settings](https://llamapress-ai-image-uploads.s3.us-west-2.amazonaws.com/v76ot6zj7p6qesg63vzngdmibf1x)

STEPS 14 - 15

## Connect to Instance

14. After successful launch, click “Connect to your instance”.

15. Now, you must use your terminal to SSH into your Ubuntu instance. You will use the SSH information provided by AWS.

![Connect Button](https://llamapress-ai-image-uploads.s3.us-west-2.amazonaws.com/zgmn6s8mm1618276uq6m65qm1ksd)

![SSH Client Instructions](https://llamapress-ai-image-uploads.s3.us-west-2.amazonaws.com/vx7ky8j35nb8dwimnaajkfkrivhh)

STEP 16

## Terminal Configuration & Installation

On your Mac, click **Command + Space** and search for “terminal” to open it.

![Open Mac Terminal](https://llamapress-ai-image-uploads.s3.us-west-2.amazonaws.com/xc1hh90jqf8iq1pyh4r1xhnwjq1t)

Move the PEM key to your `.ssh` folder and change directory:

$ mv ~/Downloads/Kody\\'s\\ OpenClaw\\ Key.pem ~/.ssh
 $ cd ~/.ssh

![Moving PEM Key](https://llamapress-ai-image-uploads.s3.us-west-2.amazonaws.com/6jxr4gbznsa51k2mbx3pnzbbifvl)

Set the correct permissions for the key file:

$ chmod 400 "Kody's OpenClaw Key.pem"

![Chmod Command](https://llamapress-ai-image-uploads.s3.us-west-2.amazonaws.com/rwqs28v7tg83fog483ikrkbmgca0)

Copy the SSH command from your AWS dashboard and paste it into your terminal to begin the connection process.

![SSH Command Copy](https://llamapress-ai-image-uploads.s3.us-west-2.amazonaws.com/z59gcope3rbkphckcm4jmjfa6tmd)

When prompted to continue connecting, type **'yes'** and press Enter to add the host to your known hosts file.

![SSH Confirmation](https://llamapress-ai-image-uploads.s3.us-west-2.amazonaws.com/fb7lg4o160agxq3q6ulgnp0u9lly)

Success! You are now logged into your Ubuntu instance via SSH. You'll see the Ubuntu greeting and system information.

![SSH Connected](https://llamapress-ai-image-uploads.s3.us-west-2.amazonaws.com/haykhvbnu7s908oq54cv1fuwycpl)

Run the update command to ensure your server has the latest security patches and package lists:

sudo apt-get update

![Ubuntu Update](https://llamapress-ai-image-uploads.s3.us-west-2.amazonaws.com/cm4gdj0n6g103gt8z584qs39dk9m)

Add a swap file to prevent the VM from freezing under heavy load. This is critical for t2.medium instances:

sudo fallocate -l 4G /swapfile
 sudo chmod 600 /swapfile
 sudo mkswap /swapfile
 sudo swapon /swapfile
 echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab

Install Claude Code using the official installation script. This will set up the Claude CLI on your server:

curl -fsSL https://claude.ai/install.sh | bash
 echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc && source ~/.bashrc

![Claude Install](https://llamapress-ai-image-uploads.s3.us-west-2.amazonaws.com/vhrn35fjqlagkn5eqrewnixfo9z7)

Launch Claude for the first time to begin the initialization and authentication process:

claude

![Claude Launch](https://llamapress-ai-image-uploads.s3.us-west-2.amazonaws.com/djv4qbkq86vd38tfi0enh2cq7pqn)

Select your preferred login method (typically Google or Email) to sign into your Anthropic account.

![Claude Login Option](https://llamapress-ai-image-uploads.s3.us-west-2.amazonaws.com/blqtpqx04vewekfa7m08ilwfx34v)

Since we are on a headless server, Claude will provide a unique authorization URL. Copy this URL carefully.

![Claude URL Copy](https://llamapress-ai-image-uploads.s3.us-west-2.amazonaws.com/hs37tppic8ot44ijhuxd8cvf207a)

Paste the URL into your local computer's browser and click **'Authorize'** to grant Claude Code access.

![Claude Authorize](https://llamapress-ai-image-uploads.s3.us-west-2.amazonaws.com/v8wubxpv6y41lugsu3t65fzf74ds)

After authorizing, you will be given a temporary login code. Copy this code to your clipboard.

![Claude Copy Code](https://llamapress-ai-image-uploads.s3.us-west-2.amazonaws.com/jbn9a5nd79ovknh7f7whdn77oajk)

Return to your terminal and paste the code when prompted to complete the authentication process.

![Claude Paste Code](https://llamapress-ai-image-uploads.s3.us-west-2.amazonaws.com/yblo38lmidzwm6pvwc6q4n9tealr)

Once authenticated, you'll see a **'Login successful'** message. You're now ready to start using Claude Code.

![Login Successful](https://llamapress-ai-image-uploads.s3.us-west-2.amazonaws.com/x97qvgz2xlxidkbvcxun161qy9go)

Claude will present some initial security notes. Read through these to understand how it interacts with your system.

![Security Notes](https://llamapress-ai-image-uploads.s3.us-west-2.amazonaws.com/xxfe6j4hqnavfi73jxu7ti4wm99w)

Confirm that you trust the current folder. This allows Claude to read and write files in your OpenClaw directory.

![Trust Folder](https://llamapress-ai-image-uploads.s3.us-west-2.amazonaws.com/mjbvw1ubc074s81ik7weece1kqw0)

You're now **'In'** with Claude. The interface will change to the Claude Code shell, ready for your commands.

![In with Claude](https://llamapress-ai-image-uploads.s3.us-west-2.amazonaws.com/secr54mggr9kwkay6qvx63kk6b70)

Send a quick test message like **'Hello'** to verify that Claude is responding correctly and connected to the internet.

![Test Message](https://llamapress-ai-image-uploads.s3.us-west-2.amazonaws.com/35t5lld3jljiejt08wt9sq4f9e8d)

Type **'exit'** or press **Ctrl+D** to leave the Claude shell and return to your Ubuntu terminal.

![Exit Claude](https://llamapress-ai-image-uploads.s3.us-west-2.amazonaws.com/imcixl5hdbowrph8e5xz3x9bfido)

We'll set up an alias for **'Danger Mode'** to skip permission prompts. Run the `clauded` command to begin.

echo 'alias clauded="claude --dangerously-skip-permissions"' >> ~/.bashrc && source ~/.bashrc
 clauded

![Clauded Command](https://llamapress-ai-image-uploads.s3.us-west-2.amazonaws.com/2r69y5for16vbj0afuf3za8h6va4)

Confirm that you trust the environment for Danger Mode. This is required for advanced system interactions.

![Trust Environment](https://llamapress-ai-image-uploads.s3.us-west-2.amazonaws.com/cl6dj9p0custbhryxq04ncwsiv1s)

Acknowledge the security warning. Danger Mode gives Claude more freedom to act, which is essential for automated configuration.

![Security Warning](https://llamapress-ai-image-uploads.s3.us-west-2.amazonaws.com/esjwkez0p2m2ya8x4vfihs65lyms)

OpenClaw requires Node.js. We'll start by downloading the NodeSource setup script for version 24:

curl -fsSL https://deb.nodesource.com/setup\_24.x | sudo -E bash -

![Node JS Setup](https://llamapress-ai-image-uploads.s3.us-west-2.amazonaws.com/nn6law7gqdvflu36myawn1cznzaq)

Execute the installation command to set up Node.js and npm on your system:

sudo apt-get install -y nodejs

![Node JS Install](https://llamapress-ai-image-uploads.s3.us-west-2.amazonaws.com/p6efg7ig8kskhd2mkmvhp1rl23lx)

Verify the installation by checking the Node.js version. It should be **v24** or higher:

node --version

![Node Version Check](https://llamapress-ai-image-uploads.s3.us-west-2.amazonaws.com/czgczgveapw9oo3t6p41paxieg0w)

Now we're ready to install OpenClaw. Run the installation script to pull down the latest version:

curl -fsSL https://openclaw.ai/install.sh | bash

![OpenClaw Install 1](https://llamapress-ai-image-uploads.s3.us-west-2.amazonaws.com/rsrq4x5dxlzr1o7uelj5y0xih87j)

The installer will begin setting up the necessary dependencies and directories for your agent.

![OpenClaw Install 2](https://llamapress-ai-image-uploads.s3.us-west-2.amazonaws.com/sc80yungookqe38p3djkvihbrrp3)

Acknowledge any final security warnings before moving into the interactive configuration wizard.

![Security Warning](https://llamapress-ai-image-uploads.s3.us-west-2.amazonaws.com/ak9vuhrbzpyff6zy5t0tei5reeth)

Start the **QuickStart** wizard to begin the configuration process for your agent.

![OpenClaw QuickStart](https://llamapress-ai-image-uploads.s3.us-west-2.amazonaws.com/vrvv1lzwmit3cw1kfobdubddo7ue)

Select **Google Gemini 1.5 Flash** as your model provider. It offers the best balance of speed and cost.

![Model Provider Selection](https://llamapress-ai-image-uploads.s3.us-west-2.amazonaws.com/zly35fugtja2kun45n9vmsd3ui05)

OpenClaw will prompt you for your **Gemini API key**. We'll get this from Google AI Studio.

![API Key Prompt](https://llamapress-ai-image-uploads.s3.us-west-2.amazonaws.com/lbslvzzmh22tnnk69fr8ge9xgoge)

Open [Google AI Studio](https://aistudio.google.com/) to manage your API keys and projects.

![Google AI Studio](https://llamapress-ai-image-uploads.s3.us-west-2.amazonaws.com/k80exh87zjzvqqankxk2nvdbbe1n)

Click on the **'Get API key'** link in the sidebar to view your existing keys or create a new one.

![Get API Key Link](https://llamapress-ai-image-uploads.s3.us-west-2.amazonaws.com/4s6lze0wgb6cdsgtczmmve2rgax7)

Click **'Create API key in new project'** to generate a fresh credential specifically for OpenClaw.

![Create Project](https://llamapress-ai-image-uploads.s3.us-west-2.amazonaws.com/gaeg566jh5zqr0t3yc6ibjlhy8jl)

Follow the prompts to name your project. Using a descriptive name like **'OpenClaw'** helps with organization.

![Name Project](https://llamapress-ai-image-uploads.s3.us-west-2.amazonaws.com/5n9jkqi9n8re3x1f0jlxkjyjmw74)

Google will now generate your unique API key. This key grants access to the Gemini models.

![Create Key](https://llamapress-ai-image-uploads.s3.us-west-2.amazonaws.com/0bg85az5ivwz5uyv6zvad6st9k2g)

Copy the generated API key to your clipboard. **Warning:** Keep this key private and secure.

![Copy API Key](https://llamapress-ai-image-uploads.s3.us-west-2.amazonaws.com/0sbb9ozpoksnaut5n9ad2zagk1ux)

Return to your Ubuntu terminal and paste the API key into the OpenClaw prompt.

![Paste API Key](https://llamapress-ai-image-uploads.s3.us-west-2.amazonaws.com/ov551k6yedak2udidvbxfd4qyhi8)

Select the specific model version you want to use. We recommend the latest **Gemini 1.5 Flash**.

![Select Model](https://llamapress-ai-image-uploads.s3.us-west-2.amazonaws.com/4yizbi6idd0v0zvmi1kzhoypqc1z)

STEP 17

## Telegram Bot Configuration

Open Telegram and search for **@BotFather**, the official bot for creating and managing other Telegram bots.

![Search BotFather](https://llamapress-ai-image-uploads.s3.us-west-2.amazonaws.com/iph87gdg198evjowf5u0b5pi9de9)

Start a conversation with BotFather and send the `/newbot` command to begin creating your AI agent's Telegram presence.

![/newbot command](https://llamapress-ai-image-uploads.s3.us-west-2.amazonaws.com/5j0brb08dbhge5ij37q3rlf6daay)

Follow the prompt to give your bot a name. This is the display name users will see (e.g., **Kody's OpenClaw Bot**).

![Name Bot](https://llamapress-ai-image-uploads.s3.us-west-2.amazonaws.com/g1gxz7g01ehy279z6dm0yfscnk5y)

Choose a unique username for your bot. It must be unique across all of Telegram and **must end in \_bot**.

![Bot Username](https://llamapress-ai-image-uploads.s3.us-west-2.amazonaws.com/u7cduuj4834xr8nydfaqi59kl03p)

BotFather will generate an HTTP API token. **Copy this token carefully**; you'll need it for the OpenClaw configuration.

![Token Copy](https://llamapress-ai-image-uploads.s3.us-west-2.amazonaws.com/mbd6ye0ji7r99prwu40cmsdi64be)

Back in your Ubuntu terminal, install the OpenClaw gateway service using the following command:

export PATH="/home/ubuntu/.npm-global/bin:$PATH"
 openclaw gateway install

![Gateway Install](https://llamapress-ai-image-uploads.s3.us-west-2.amazonaws.com/tu6etii2wsi61et3a9owaerzyxsf)

Start the gateway to begin listening for incoming Telegram messages:

openclaw gateway start

![Gateway Start](https://llamapress-ai-image-uploads.s3.us-west-2.amazonaws.com/6nqpxhnl9kil38lm9atn5gk0fad5)

Open Telegram on your phone or desktop and search for your newly created bot's username in your contacts list.

![Telegram Contacts](https://llamapress-ai-image-uploads.s3.us-west-2.amazonaws.com/yuj02vx65fvvu20gqm0jffceyhxl)

Select your bot from the search results to open the chat interface and start your session.

![Select Bot](https://llamapress-ai-image-uploads.s3.us-west-2.amazonaws.com/bdo2k7yvj29r2cvp5vqji03xkiu9)

You're now ready to interact with your AI agent. The Telegram interface provides a seamless experience for commands and chat.

![Message Interface](https://llamapress-ai-image-uploads.s3.us-west-2.amazonaws.com/bl959dvfzgijj852mhk024c4rt86)

Click the **'Start'** button at the bottom of the chat to initialize the conversation with OpenClaw.

![Start Button](https://llamapress-ai-image-uploads.s3.us-west-2.amazonaws.com/93dozm258zt435mpdtaenoie3ejc)

Send your first message to the bot. OpenClaw will process your request and respond in real-time.

![First Message](https://llamapress-ai-image-uploads.s3.us-west-2.amazonaws.com/x4pivl1p5rqyr67xiv5dbsav5iek)

Your agent is now active! You'll notice it can handle complex queries and system-level tasks via the gateway.

![Processing Request](https://llamapress-ai-image-uploads.s3.us-west-2.amazonaws.com/5ad1dqlmbk00mdspvj0k26tgguks)

The agent provides clear feedback and can even use formatting to make technical information easy to read.

![Agent Feedback](https://llamapress-ai-image-uploads.s3.us-west-2.amazonaws.com/0xnf7axcrx6rcdbtqonqvj22vp5z)

Your Telegram connection is fully verified. You can now use your agent from any device with Telegram installed.

![Final Connection](https://llamapress-ai-image-uploads.s3.us-west-2.amazonaws.com/r49ver3r9sn5zvgwpemuswvxo8kk)

STEP 18

## Triage & Debugging with Claude Code

Navigate to your OpenClaw directory and launch Claude in **Danger Mode** to begin the automated health check:

cd ~/.openclaw/
 clauded

![Launch Clauded](https://llamapress-ai-image-uploads.s3.us-west-2.amazonaws.com/sl7dfqpmm1galcof8pokbuy59gzz)

Copy the debugging prompt from the guide. This prompt instructs Claude to download and follow a specific triage order.

![Copy Debug Prompt](https://llamapress-ai-image-uploads.s3.us-west-2.amazonaws.com/wqys40tfel6v4629fw2r5lyqkvtt)

Paste the following prompt into Claude Code to start the automated troubleshooting process:

"Download the OpenClaw debugging guide from https://llamapress.ai/openclaw\_agent\_debug\_instructions and save it to ~/.openclaw/CLAUDE.md. Then read it fully, and follow the triage order from the guide to verify this OpenClaw instance is healthy. Specifically verify the Telegram channel is connected and responding."

![Paste Prompt](https://llamapress-ai-image-uploads.s3.us-west-2.amazonaws.com/qukplxtfjxxwkl5nvkpekiqhotn3)

Claude will start by reading the relevant configuration and log files to understand the current state of your system.

![Claude Reading Files](https://llamapress-ai-image-uploads.s3.us-west-2.amazonaws.com/voecniw7n5gb9vcaxcq8xucqwxs3)

It will analyze the logs and identify any potential issues, such as missing environment variables or connection errors.

![Finding Issues](https://llamapress-ai-image-uploads.s3.us-west-2.amazonaws.com/qwcsl0bl4cdmay1vphczkyma3h2p)

Once an issue is identified, Claude will automatically apply the necessary fixes to your configuration or environment.

![Fix Applied](https://llamapress-ai-image-uploads.s3.us-west-2.amazonaws.com/idehxi6if3lafkrrbri5mo8gs6mm)

Switch back to Telegram. You should see the **'typing...'** indicator as your agent prepares its first response after the fix.

![Typing Indicator](https://llamapress-ai-image-uploads.s3.us-west-2.amazonaws.com/ns6l8qn7s7refzf0izpkscupkkd6)

Success! OpenClaw is now responding correctly. Your agent is live, healthy, and ready for your commands.

![OpenClaw Response](https://llamapress-ai-image-uploads.s3.us-west-2.amazonaws.com/0g0g4bppb8tp3l5zob806epkf5hc)

The entire system has been verified by Claude. You have a professional AI agent running on your own AWS infrastructure.

![System Verified](https://llamapress-ai-image-uploads.s3.us-west-2.amazonaws.com/zw46x2jdg8js6g87ivyy1cbmfke1)

Your OpenClaw instance is now fully operational. You can start building custom tools and automating your business workflows.

![Operational](https://llamapress-ai-image-uploads.s3.us-west-2.amazonaws.com/lq6wm08ihy6xnteo6iheq1qapafy)

## Your OpenClaw is Alive!

Setting up an agent is the first step toward business automation. But managing raw servers and agents is a full-time job.

### Want a Managed AI Application Instead?

At LlamaPress, we do not just build bots. We convert your fragile spreadsheets into robust, database-backed web applications managed by AI. No SSH, no PEM keys, no debugging guides; just software that works.

 [Convert Your Spreadsheet](https://llamapress.ai/#final-cta)

### Related Reading

[#### The Myth of Excel Automation Why macros and scripts are stalling your growth and why you need a database-backed solution.](https://llamapress.ai/the-myth-of-excel-automation-why-your-business-needs-a-database-in-2025) [#### Why AI App Builders Rule 2025 Discover how AI is making custom software development 10x faster and more accessible for mid-market firms.](https://llamapress.ai/why-an-ai-app-builder-is-the-only-way-to-replace-your-spreadsheet-in-2025)
