Appearance

Language

Mastering AI agents

How to Get an Oracle Cloud Free ARM Instance in 2026: Claude Code 24/7 and a Git Repo Workflow

Oracle Cloud's Always Free Ampere A1 instances keep failing with "Out of host capacity". These are the exact steps that got me a 2 OCPU / 12 GB instance in Tokyo after a day and a half and a few hundred attempts: OCI CLI setup, networking, a retry script that tries every 60 seconds, a reserved IP, Claude Code Remote Control kept running with systemd, and git worktrees so several sessions can work on one repo.

Kelvin Wang · · 15 min read

Key points

  1. Failing to get an A1 instance usually means the region has no capacity, not that your setup is wrong. Retry from the CLI every 60 seconds with the built-in retries turned off, or you get rate-limited with 429s.
  2. Oracle's free A1 allowance is now 2 OCPU / 12 GB, not the 4 / 24 many guides still quote. Asking for more than your limit returns LimitExceeded, not a capacity error.
  3. Once you have the instance, swap the ephemeral IP for a reserved public IP so the address survives a rebuild.
  4. Claude Code Remote Control needs the machine to stay on. On an always-on server, run it as a systemd user service and your phone can connect any time.

I started on November 11, 2026 and got the instance at 17:56 Taipei time on November 12: about a day and a half and a few hundred attempts, in the Tokyo region (ap-tokyo-1). Among the grab stories I’ve read, a day and a half is on the fast side and partly luck; at another time or in another region it may take longer, so just leave the script running. The result is a VM.Standard.A1.Flex with 2 OCPUs, 12 GB of memory and a 50 GB boot volume, running Ubuntu 24.04 ARM. The steps below follow the order I actually did them; replace every <...> with your own value.

Why I wanted an always-on server

Claude Code’s Remote Control lets me drive a session on my own computer from my phone or claude.ai/code, but Claude and its commands run on that computer: if it sleeps or the command stops, the session ends 5. A laptop can’t stay on around the clock, so I needed a Linux machine that does. Oracle Cloud’s Always Free tier includes the ARM-based Ampere A1, with enough memory to run Claude Code comfortably.

The catch is that A1 is hard to get. Click Create in the Console and most of the time you get “Out of host capacity”. That isn’t a mistake on your side; the region simply has no free physical hosts at that moment. The fix is to keep retrying, so I scripted it with the OCI CLI.

What to prepare first

  1. Check your A1 limit. Many guides still say 4 OCPUs / 24 GB, but Oracle’s docs now give the first 1,500 OCPU hours and 9,000 GB hours a month free, which for an Always Free tenancy works out to 2 OCPUs and 12 GB 1. My account showed the same. Your script must not ask for more:

    oci limits value list --compartment-id <TENANCY_OCID> --service-name compute \
      --query "data[?contains(name,'standard-a1')]"
  2. Create an API key for the CLI. Console, profile icon at the top right, My profile, API keys, Add API key. Generate and download the private key, then copy the config snippet shown on screen.

  3. Install the OCI CLI. I put it in its own Python virtual environment:

    python3 -m venv ~/oci-venv
    ~/oci-venv/bin/pip install oci-cli
  4. Write ~/.oci/config and set the private key to mode 600:

    [DEFAULT]
    user=<USER_OCID>
    fingerprint=<API_KEY_FINGERPRINT>
    tenancy=<TENANCY_OCID>
    region=ap-tokyo-1
    key_file=~/.oci/oci_api_key.pem
    chmod 600 ~/.oci/oci_api_key.pem
  5. Prepare an SSH public key. This is a different key from the API key. On your own computer run ssh-keygen -t ed25519, save the contents of ~/.ssh/id_ed25519.pub as ssh.pub, and keep the private key on your computer.

Setting up the network

The instance needs a subnet that can reach the internet. These network resources are free; I created them all in the root compartment:

  1. Create the VCN a1-vcn with CIDR 10.0.0.0/16.
  2. Create the Internet Gateway a1-igw.
  3. Add the rule 0.0.0.0/0 → a1-igw to the default route table.
  4. Check that the default security list allows TCP 22 (it usually does).
  5. Create the public subnet a1-public with CIDR 10.0.0.0/24.
oci network vcn create --compartment-id <TENANCY_OCID> --cidr-block 10.0.0.0/16 --display-name a1-vcn
oci network internet-gateway create --compartment-id <TENANCY_OCID> --vcn-id <VCN_OCID> \
  --is-enabled true --display-name a1-igw
oci network route-table update --rt-id <DEFAULT_RT_OCID> \
  --route-rules '[{"destination":"0.0.0.0/0","networkEntityId":"<IGW_OCID>"}]' --force
oci network subnet create --compartment-id <TENANCY_OCID> --vcn-id <VCN_OCID> \
  --cidr-block 10.0.0.0/24 --display-name a1-public

Then look up two values the script needs: the Ubuntu 24.04 ARM image ID and the availability domain (AD) name. Tokyo has only one AD.

oci compute image list --compartment-id <TENANCY_OCID> \
  --operating-system "Canonical Ubuntu" --operating-system-version "24.04" \
  --shape VM.Standard.A1.Flex --sort-by TIMECREATED --query 'data[0].id' --raw-output

oci iam availability-domain list --query 'data[].name'

How the grab script works

The logic is simple: try to launch once, and on failure read the reason to decide whether to wait and retry or stop.

Error from OCIWhat it meansWhat the script does
Out of host capacityNo free hosts in the region right nowWait 60 s, retry
429 TooManyRequestsCalling the API too often, rate-limitedWait 60 s, retry
500, InternalErrorTemporary error on OCI's sideWait 60 s, retry
Connection timed outTemporary network problemWait 60 s, retry
LimitExceededThe shape is bigger than your limitStop; lower OCPUs / memory
Anything elseUsually a wrong OCID or parameterStop; read the log

Three details matter most:

  • Turn off the CLI’s built-in retries. By default most commands make up to 7 attempts 3. Stack that on top of your own loop and you hit 429 quickly. The launch line gets --no-retry, but that flag only covers the command it’s on: the instance list name check and the list-vnics IP lookup still retry by default, so the script also exports OCI_CLI_MAX_RETRIES=0 at the top. With both, it calls exactly once every 60 seconds.
  • Check for an instance with the same name first, every time. A launch call sometimes times out but actually succeeds; without the check you can end up with two.
  • Decide the disk size up front. --boot-volume-size-in-gbs sets the boot volume size. All Always Free instances share 200 GB of disk, and each boot volume is at least 47 GB 1. If you may add a small AMD instance later, I think 150 GB for the A1 with 50 GB left for the AMD is the most useful split: change the 50 in the script to 150. If you’ll only ever run the A1, you can go up to 200 GB. I used 50 GB at the time; you can still enlarge it after you get the instance, as shown further down.
#!/usr/bin/env bash
set -u
export OCI_CLI_MAX_RETRIES=0
export PATH="$HOME/oci-venv/bin:$PATH" SUPPRESS_LABEL_WARNING=True OCI_CLI_SUPPRESS_FILE_PERMISSIONS_WARNING=True
DIR=$HOME/oci-grab
LOG=$DIR/grab.log; RESULT=$DIR/result.txt
COMP=<TENANCY_OCID>
NAME=${NAME:-a1-free}
OCPUS=${OCPUS:-2}; MEM=${MEM:-12}
IMAGE=<IMAGE_OCID>
SUBNET_ID=<SUBNET_OCID>
ADS=("<AD_NAME>")
DELAY=${DELAY:-60}

log(){ echo "$(date '+%F %T %Z') $*" | tee -a "$LOG"; }
[ -s "$DIR/ssh.pub" ] || { log "ABORT: ssh.pub is empty"; exit 1; }

exists(){
  oci compute instance list --compartment-id "$COMP" --display-name "$NAME" \
    --query 'data[?"lifecycle-state"!=`TERMINATED`&&"lifecycle-state"!=`TERMINATING`].id|[0]' --raw-output 2>/dev/null
}

i=0
while true; do
  ex=$(exists)
  if [ -n "$ex" ] && [ "$ex" != "null" ]; then log "STOP: $NAME already exists: $ex"; echo "existing $ex" >> "$RESULT"; exit 0; fi
  AD=${ADS[$((i % ${#ADS[@]}))]}; i=$((i+1))
  log "attempt $i AD=$AD ${OCPUS}c/${MEM}G"
  out=$(oci --no-retry compute instance launch \
    --compartment-id "$COMP" --availability-domain "$AD" \
    --display-name "$NAME" --shape VM.Standard.A1.Flex \
    --shape-config "{\"ocpus\":$OCPUS,\"memoryInGBs\":$MEM}" \
    --image-id "$IMAGE" --subnet-id "$SUBNET_ID" --assign-public-ip true \
    --boot-volume-size-in-gbs 50 \
    --ssh-authorized-keys-file "$DIR/ssh.pub" \
    --wait-for-state RUNNING 2>&1)
  if [ $? -eq 0 ]; then
    id=$(echo "$out" | python3 -c 'import sys,json; t=sys.stdin.read(); print(json.loads(t[t.index("{"):])["data"]["id"])')
    ip=$(oci compute instance list-vnics --instance-id "$id" --query 'data[0]."public-ip"' --raw-output 2>/dev/null)
    echo "instance=$id public_ip=$ip" | tee -a "$LOG" > "$RESULT"
    log "SUCCESS $id $ip"; exit 0
  fi
  echo "$out" | grep -v '^Warning' | tail -8 >> "$LOG"
  if echo "$out" | grep -qi 'LimitExceeded'; then log "STOP: LimitExceeded (lower OCPUS/MEM)"; exit 2
  elif echo "$out" | grep -qi 'Out of host capacity\|Out of capacity\|TooManyRequests\|(429)\|"status": 429\|InternalError\|(500)\|"status": 500\|timed out\|ConnectionError\|RequestException'; then
    log "retryable; retry in ${DELAY}s"; sleep "$DELAY"
  else log "STOP: non-retryable error"; exit 3; fi
done

Run the script on a machine that stays on. I had Grok Bot run it on its own machine; a machine that never sleeps is the safe choice. If a laptop goes to sleep, nohup won’t save you and the script stops. Save it as ~/oci-grab/grab.sh, put ssh.pub in the same folder, and run it in the background so it survives closing the terminal:

cd ~/oci-grab
chmod +x grab.sh
nohup setsid ./grab.sh > nohup.out 2>&1 &
tail -f grab.log

My first version didn’t treat connection timeouts as retryable, so the script stopped on its own several times and I had to restart it by hand. The version above includes them. I also had an hourly check looking for result.txt and making sure the script was still alive.

After you get it: switch to a fixed IP

The instance comes with an ephemeral IP that changes if the instance is rebuilt. OCI can’t convert an ephemeral IP into a fixed one; you request a reserved public IP, remove the old one and attach the new one. I create the new one first, so if that fails the existing connection is untouched:

VNIC=$(oci compute instance list-vnics --instance-id <INSTANCE_OCID> --query 'data[0].id' --raw-output)
PRIV=$(oci network private-ip list --vnic-id "$VNIC" --query 'data[0].id' --raw-output)

oci network public-ip create --compartment-id <TENANCY_OCID> --lifetime RESERVED --display-name a1-free-ip

EPH=$(oci network public-ip get --private-ip-id "$PRIV" --query 'data.id' --raw-output)
oci network public-ip delete --public-ip-id "$EPH" --force

oci network public-ip update --public-ip-id <RESERVED_IP_OCID> --private-ip-id "$PRIV"

Then log in with ssh ubuntu@<your IP>.

Running out of disk after you get it: how to enlarge it

A boot volume can be enlarged while the instance is running, with no need to grab a new one, but it can’t be shrunk 12.

  1. Enlarge the volume in OCI. In the Console open the instance, Boot volume, Edit, set the size to 150 and save. With the CLI:

    oci bv boot-volume update --boot-volume-id <BOOT_VOLUME_OCID> --size-in-gbs 150
  2. Make the OS see the new size. After you save, the dialog lists rescan commands; SSH in and paste them 13.

  3. Grow the partition and file system. Oracle’s docs use oci-growfs from OCI Utilities, which is for Oracle Linux; on Ubuntu use growpart and resize2fs. Check with lsblk which device holds the root; it’s commonly /dev/sda1:

    lsblk
    sudo growpart /dev/sda 1
    sudo resize2fs /dev/sda1
  4. Check the result: df -h / should show close to 150 GB.

Do the math first: if all disks across the A1 and AMD instances add up to more than 200 GB, the excess is billed.

Running Claude Code Remote Control on the server

claude remote-control starts a long-running server in the current folder. The Claude mobile app or claude.ai/code can connect to it and run several sessions at once. It needs a Pro, Max, Ultra, Team or Enterprise plan; API keys aren’t supported 5. The official docs only suggest tmux or screen to keep it running after you disconnect from SSH. I wanted it to come back after a reboot as well, so I used systemd.

  1. Install Claude Code on the server and sign in. Follow the official install instructions 6, then run claude once by hand in the project folder to trust the folder and finish signing in.

  2. Try Remote Control by hand. The first run asks Enable Remote Control? (y/n); answer it and check that your phone sees the session:

    cd ~/projects/my-site
    claude remote-control --name "a1 - my-site" --spawn=worktree

    --spawn=worktree puts every new session you start from your phone in its own git worktree, so sessions don’t edit the same files. --capacity caps how many sessions run at once (default 32). Once it’s connected, stop it with Ctrl+C.

  3. Write a systemd user service at ~/.config/systemd/user/claude-my-site.service:

    [Unit]
    Description=Claude Code Remote Control (my-site)
    Wants=network-online.target
    After=network-online.target
    
    [Service]
    WorkingDirectory=%h/projects/my-site
    ExecStart=%h/.local/bin/claude remote-control --name "a1 - my-site" --spawn=worktree --capacity 4
    Restart=always
    RestartSec=15
    MemoryMax=3500M
    
    [Install]
    WantedBy=default.target
  4. Enable linger and start the service. Linger keeps the service running after you log out of SSH and starts it again after a reboot:

    sudo loginctl enable-linger "$USER"
    systemctl --user daemon-reload
    systemctl --user enable --now claude-my-site.service
    systemctl --user status claude-my-site.service

Restart=always is there because server mode exits on its own after the network has been down for about 10 minutes 5; systemd brings it back 15 seconds later. MemoryMax is a per-service cap, so a service that eats too much memory only kills itself. If the folder was never trusted, the service fails with Workspace not trusted, which is why step 1 runs claude by hand first.

For several projects on one server, use one service per project.

How several sessions share one Git repo

With --spawn=worktree, the session created at startup stays in the project folder itself, and every session you open later from your phone or the web gets its own git worktree 5. A worktree is another working directory of the same repo: it shares the git objects but checks out its own branch, and by default one branch can’t be checked out in two worktrees at once 7. So two sessions can’t overwrite each other’s half-finished files.

  1. Check where you are before starting. Run pwd, git status -sb and git worktree list in the session to see which worktree and branch it’s on.
  2. One branch per task. Let the session change and commit on its own branch, then push that branch.
  3. Merge back through review. Open a PR and merge into main after review; don’t let two sessions commit to main directly at the same time.
  4. Clean up finished worktrees. After merging, run git worktree remove <path>, or git worktree prune to clear records of worktrees that no longer exist.

Worktrees separate working directories, not permissions: every session under the same Linux user can read the same GitHub keys and sign-ins. For projects that need separate permissions, give each project its own Linux user, with its own Claude sign-in, its own GitHub keys and only the GitHub permissions it needs 7.

Connecting the Oracle server to GitHub

When a session commits, pushes or opens a PR on the server, it uses the server’s GitHub sign-in, not your laptop’s. The simplest setup is one fine-grained token limited to this repo, shared by git and the GitHub CLI (gh).

  1. Install the GitHub CLI:

    sudo apt update && sudo apt install -y gh
  2. Set the commit author, or commits carry the server’s user name:

    git config --global user.name "<your name>"
    git config --global user.email "<your GitHub email>"
  3. Create a fine-grained token on GitHub 9. Profile icon at the top right, Settings, Developer settings, Personal access tokens, Fine-grained tokens, Generate new token:

    • under Repository access choose Only select repositories and pick just this repo;
    • under Permissions set Contents and Pull requests to Read and write;
    • set an expiry date and rotate it when it expires.
  4. Sign in on the server. Paste the token, press Enter, then Ctrl+D. gh auth setup-git makes git push use the same token 8:

    gh auth login --with-token
    gh auth setup-git
    gh auth status
  5. Clone the project over HTTPS:

    git clone https://github.com/<your-account>/<repo>.git ~/projects/my-site

The sign-in is stored in the user’s ~/.config/gh, and the systemd service above runs as the same user, so sessions you open from your phone can push straight away. Tell Claude in a session to “make a branch, push it and open a PR”, and it runs something like:

git switch -c fix/typo
git commit -am "fix: typo on the about page"
git push -u origin fix/typo
gh pr create --title "Fix typo on the about page" --body "..."

Block direct pushes to main. Add a rule under the repo’s Settings, Rules, Rulesets requiring a pull request before merging into main; even if a session tries to push to main, GitHub refuses it. Private repos need GitHub Pro, Team or higher for this; public repos get it on a free account 10.

If you only need to push, not open PRs, a deploy key also works: generate a new SSH key on the server with ssh-keygen -t ed25519, add the public key under the repo’s Settings, Deploy keys, and tick Allow write access. A deploy key works for one repo only, so a compromised server can’t reach your other projects 11.

Mistakes I made

ProblemCauseFix
The script kept returning LimitExceededI asked for 4 OCPU / 24 GB; the limit was 2 / 12Check the limit and request within it
CLI authentication failedPEM header, footer or line breaks lost when pastingRestore BEGIN/END and line breaks, compare the fingerprint
Instance up but SSH refusedUsed the API public key (-----BEGIN PUBLIC KEY-----) as the SSH keyAn SSH public key looks like ssh-ed25519 AAAA…
Constant 429s after a whileCLI retries plus the script loop, too many calls--no-retry on launch, export OCI_CLI_MAX_RETRIES=0 at the top, one call every 60 s
The script stopped overnightA connection timeout was treated as non-retryableAdd timed out and ConnectionError to the retryable list
IP changed after a rebuildIt was an ephemeral IPSwitch to a reserved public IP

FAQ

Is an Always Free instance really free?

Within the free allowance, yes. Boot and block volumes get 200 GB free combined 1, so my 50 GB boot volume fits. Watch for storage beyond that and for unattached reserved IPs. To be safe I set a USD 1 budget alert under Billing, Budgets.

How do I split the 200 GB of disk between A1 and AMD instances?

Thanks to Threads user tzuchingtsai for pointing this out. Besides A1, Always Free also includes up to two small AMD instances (VM.Standard.E2.1.Micro), each with 1/8 OCPU (able to burst a little) and 1 GB of memory; the A1 allowance can be one 2-OCPU instance or two 1-OCPU instances 1. Boot volumes plus any extra block volumes across all instances share 200 GB of free storage; each boot volume is at least 47 GB and 50 GB by default, set with --boot-volume-size-in-gbs 1.

InstancesBoot volume splitTotal
A1 onlyA1 up to 200 GB200 GB
A1 + 1 AMDA1 150 GB, AMD 50 GB200 GB
A1 + 2 AMDA1 100 GB, AMD 50 GB each200 GB

My script launches with 50 GB; to start bigger, change the 50 in the script. The AMD instance has only 1 GB of memory, so I’d use it for light jobs like monitoring and keep Claude Code on the A1.

I keep failing. Should I upgrade to Pay As You Go?

Oracle states that Always Free resources stay free after you upgrade 1. Oracle’s FAQ only says Pay As You Go accounts have different capacity limits from Always Free accounts 2; plenty of people in the community say upgrading makes A1 easier to get, but Oracle doesn’t promise that. After upgrading, anything beyond the free allowance is billed. I submitted the upgrade at 17:31 and got the instance at 17:56, only 25 minutes later, while the upgrade may still have been processing, so I can’t tell whether the upgrade had anything to do with it.

Can Oracle take the instance back?

It can. Oracle’s rule is that if, over 7 days, the 95th percentile of CPU and network use (and memory, for A1) all stay under 20%, the instance counts as idle and may be reclaimed 1. A server that only runs a Claude Code service won’t necessarily clear that bar, so I keep everything important in git and elsewhere; if the instance goes, I grab another.

Do I have to pick Tokyo?

No. Pick one close to you; Always Free resources can only be created in your account’s home region. Tokyo has a single AD, so the script lists one. In a region with three ADs, put all three in ADS and the script rotates through them.

Go deeper Claude Code Tutorial 2026: Install, CLAUDE.md, Skills, and Your First Website From installing and signing in to letting it change a project for the first time.

Sources

  1. 1. Always Free Resources · Oracle Cloud Infrastructure Documentation · checked 2026-11-13
  2. 2. Oracle Cloud Free Tier FAQ · Oracle · checked 2026-11-13
  3. 3. OCI CLI Command Reference · Oracle Cloud Infrastructure Documentation · checked 2026-11-13
  4. 4. Public IP Addresses · Oracle Cloud Infrastructure Documentation · checked 2026-11-13
  5. 5. Remote Control · Claude Code Docs · checked 2026-11-13
  6. 6. Advanced setup · Claude Code Docs · checked 2026-11-13
  7. 7. Running multiple Claude Code Remote Controls on one host: Linux users, systemd and git worktree (Chinese) · Jason Finance · 2026-10-12
  8. 8. gh auth login · GitHub CLI Manual · checked 2026-11-13
  9. 9. Managing your personal access tokens · GitHub Docs · checked 2026-11-13
  10. 10. About rulesets · GitHub Docs · checked 2026-11-13
  11. 11. Managing deploy keys · GitHub Docs · checked 2026-11-13
  12. 12. Resizing a Volume · Oracle Cloud Infrastructure Documentation · checked 2026-11-13
  13. 13. Rescanning the Disk for a Volume · Oracle Cloud Infrastructure Documentation · checked 2026-11-13

About the author

Kelvin Wang

Electrical engineer building tools with AI agents, sharing hands-on notes on engineering and investing.

More about me