🚀 GETTING STARTED
4ステップで始める
所要時間:約15分。必要なもの:Proxmox (またはLinuxサーバー)、Cloudflare Tunnel、Claude.aiアカウント。
ステップ1: LXCにデプロイ
ProxmoxのLXCコンテナ(または任意のLinux環境)にインストール。
$ apt update && apt install -y curl git
$ curl -fsSL https://deb.nodesource.com/setup_22.x | bash -
$ apt install -y nodejs
$ git clone https://github.com/DaisukeHori/ssh-mcp-server.git /opt/ssh-mcp-server
$ cd /opt/ssh-mcp-server
$ npm install && npx tsc
⚠️ Node.js 22以上が必要です。node --version で確認してください。
ステップ2: Admin Keyを生成して起動
$ export ADMIN_KEY=$(openssl rand -hex 32)
$ echo "Admin Key: $ADMIN_KEY"
Admin Key: a8f3b2c1d9e4f7a6...
$ node dist/index.js
systemdサービスとして永続化:
$ cat > /etc/systemd/system/ssh-mcp-server.service << EOF
[Unit]
Description=SSH MCP Server
After=network.target
[Service]
Type=simple
WorkingDirectory=/opt/ssh-mcp-server
Environment=ADMIN_KEY=YOUR_ADMIN_KEY_HERE
Environment=BLOCKED_HOSTS=$(hostname -I),$(hostname)
Environment=WEBHOOK_SECRET=$(openssl rand -hex 20)
Environment=PORT=3000
ExecStart=/usr/bin/node dist/index.js
Restart=always
RestartSec=5
[Install]
WantedBy=multi-user.target
EOF
$ systemctl enable --now ssh-mcp-server
$ journalctl -u ssh-mcp-server -f
ステップ3: Cloudflare Tunnel設定
直接ポート公開せず、Cloudflare Tunnel経由でHTTPS公開。
ingress:
- hostname: your-server.example.com
service: http://localhost:3000
- service: http_status:404
✅ Cloudflare TunnelによりLXCのポートを直接公開する必要がありません。全通信がHTTPS暗号化。
ステップ4: Claude.aiでコネクター登録
マルチキー対応。用途に合わせた3つの接続方法。
おすすめ:最強構成
Admin + User Key(管理もSSHも全部1つで)
まずAdmin Keyだけで接続してUser Keyを発行 → コネクターURLに両方入れる。
https://your-server.example.com/mcp?key=YOUR_ADMIN_KEY
https://your-server.example.com/mcp?key=YOUR_ADMIN_KEY&key=uk_84e17ac6...
管理者専用
User Key管理 + 全セッション閲覧。SSH接続はしない。
https://your-server.example.com/mcp?key=YOUR_ADMIN_KEY
ユーザー専用
SSH接続の作成と操作。自分のセッションのみ見える。
https://your-server.example.com/mcp?key=uk_84e17ac6...
🖥️ OTHER CLIENTS
Claude Desktop / Claude Code での使用
Claude Desktop / Cursor / VS Code:
{
"mcpServers": {
"ssh": {
"command": "npx",
"args": ["-y", "mcp-remote",
"https://your-server.example.com/mcp?key=YOUR_KEY"]
}
}
}
Claude Code:
$ claude mcp add --transport http ssh-mcp \
"https://your-server.example.com/mcp?key=YOUR_KEY"
💡 マルチキーも使えます: ?key=ak_xxx&key=uk_aaa
❓ FAQ
よくある質問
session_tokenを忘れた
ssh_list_sessions で自分のセッション一覧を確認できます。
長時間コマンドの扱い
ssh_execute(wait_ms=5000) で途中結果を取得。ssh_command_status(command_id) で後からポーリング。tail_lines で末尾だけ取得も可能。
サーバー自身にSSHできる?
いいえ。BLOCKED_HOSTS でサーバー自身のIPとホスト名をブロック。ADMIN_KEY等の環境変数漏洩を防止します。
GitHub Push で自動デプロイ?
WEBHOOK_SECRET を設定してGitHub Webhookを登録すれば、Push → 約5秒で自動更新。HMAC-SHA256署名検証付き。
Admin + User Keyを1つで?
?key=ak_xxx&key=uk_aaa で管理もSSH接続も全部できます。
サーバー再起動したら?
全SSH接続が切断。User Keysは永続化されているので再接続可能。