minorun365

Claude Code On Ec2 — DevOps skill for Claude Code

DevOps community

Remote Control機能でAWS上のClaude Codeをスマホから使おう.

How to install Claude Code On Ec2

This entry records only its repository, not the path inside it, so there is no exact command to give. Open minorun365/claude-code-on-ec2 and copy the folder into ~/.claude/skills/, or the file into ~/.claude/agents/.

What Claude Code On Ec2 does

Remote Control機能でAWS上のClaude Codeをスマホから使おう!

Alternatives in DevOps

  • Cccc — Coordinate your coding agents like a group chat — read receipts, delivery tracking, and remote ops from your p 1.1k ★
  • MCP Boilerplate — A remote Cloudflare MCP server boilerplate with user authentication and Stripe for paid tools 1k ★
  • MCP SSH Manager — MCP SSH Server: 37 tools for remote SSH management Claude Code & OpenAI Codex DevOps automation, backups, data 460 ★

README

Claude Code on EC2

AWS EC2 上で Claude Code を常時稼働させ、スマホ・Mac・VSCode などどこからでも Remote Control でアクセスできる**パーソナル Claude Code サーバー**を CDK で構築します。

スマホ / Mac / VSCode
    ↕ Remote Control(HTTPS)または SSM Session Manager
EC2 t4g.large(Amazon Linux 2023 / Graviton2)
    └── tmux セッション「claude」
          └── Claude Code(systemd + tmux で常時稼働)

特徴

  • ポート開放ゼロ — SSM Session Manager 経由で接続(SSH ポート 22 不要)
  • どこからでもアクセス — スマホ・Mac・VSCode の Remote Control で操作
  • Mac を閉じても継続 — tmux セッションが EC2 上で生き続ける
  • 自動復旧 — systemd により EC2 再起動後も tmux + Claude Code が自動起動
  • ワークスペース変更 — Claude Code 終了後に別のプロジェクトディレクトリで再起動可能

必要なもの

  • AWS アカウント
  • claude.ai の Pro または Max プラン(Remote Control 機能に必要)
  • ローカル PC: AWS CLI、CDK (npm install -g aws-cdk)、session-manager-plugin

セットアップ

1. session-manager-plugin のインストール

# macOS Apple Silicon(AWS 公式 pkg)
curl "https://session-manager-downloads.s3.amazonaws.com/plugin/latest/mac_arm64/sessionmanager-bundle.zip" -o /tmp/sm.zip
unzip /tmp/sm.zip -d /tmp/
sudo /tmp/sessionmanager-bundle/install -i /usr/local/sessionmanagerplugin -b /usr/local/bin/session-manager-plugin

# macOS Intel(Homebrew)
brew install --cask session-manager-plugin

2. CDK デプロイ

git clone https://github.com/minorun365/claude-code-on-ec2.git
cd claude-code-on-ec2/cdk
npm install
./node_modules/.bin/cdk bootstrap  # 初回のみ
./node_modules/.bin/cdk deploy

デプロイ後に `InstanceId` が出力されます。セットアップ完了まで約 5〜10 分かかります。

# 完了確認
aws ssm send-command --instance-id  --region us-east-1 \
  --document-name "AWS-RunShellScript" \
  --parameters 'commands=["cat /home/ec2-user/.setup-complete"]'

3. EC2 に接続して Claude Code にログイン

aws ssm start-session --target  --region us-east-1

接続後:

sudo su - ec2-user   # tmux セッションに自動アタッチされる
claude               # ブラウザ認証 → claude.ai にログイン

AWS コンソールからも接続可: EC2 → 「接続」→「Session Manager」タブ

4. Remote Control を有効化

/config

「すべてのセッションでリモートコントロールを有効