# SSH Proxy Deployment Guide

## ✅ Files Ready

All deployment files have been created:
- `Dockerfile` - Container configuration
- `fly.toml` - Fly.io app configuration
- `.dockerignore` - Build optimization

## 🚀 Deploy to Fly.io (Recommended - 3 minutes)

### 1. Login to Fly.io

```bash
/home/Nicholai/.fly/bin/flyctl auth login
```

This will open your browser to login/signup. Fly.io has a generous free tier.

### 2. Deploy

```bash
cd /home/Nicholai/Documents/Dev/bandit-runner/ssh-proxy
/home/Nicholai/.fly/bin/flyctl deploy
```

That's it! Fly will:
- Build the Docker container
- Deploy to their edge network
- Give you a URL like: `https://bandit-ssh-proxy.fly.dev`

### 3. Verify Deployment

```bash
curl https://bandit-ssh-proxy.fly.dev/ssh/health
```

Should return: `{"status":"ok","activeConnections":0}`

### 4. Update Cloudflare Worker

Update your SSH_PROXY_URL:

```bash
cd ../bandit-runner-app
wrangler secret put SSH_PROXY_URL
# Enter: https://bandit-ssh-proxy.fly.dev
```

Then redeploy:

```bash
pnpm run deploy
```

### 5. Test End-to-End!

Open: **https://bandit-runner-app.nicholaivogelfilms.workers.dev**

- Select GPT-4o Mini
- Set levels 0-2
- Click START
- Watch it work! 🎉

## 🔄 Alternative: Railway (Simpler, No CLI)

### 1. Install Railway CLI (Optional)

```bash
npm install -g railway
railway login
railway init
railway up
```

### 2. Or Use Railway Dashboard

1. Go to https://railway.app
2. Click "New Project"
3. Select "Deploy from GitHub"
4. Connect your repo
5. Railway auto-detects the Dockerfile
6. Click Deploy
7. Copy the public URL

## 🐳 Alternative: Any Docker Platform

The Dockerfile works on:
- **Fly.io** (recommended - edge, fast)
- **Railway** (easiest - GUI)
- **Render** (free tier)
- **Heroku** (classic)
- **Digital Ocean App Platform**
- **AWS ECS/Fargate**

## ⚡ Quick Commands

```bash
# Add flyctl to PATH (one time)
echo 'export PATH="$HOME/.fly/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc

# Then you can use 'flyctl' directly
flyctl auth login
flyctl deploy
flyctl logs
flyctl status
```

## 📊 What to Expect

**Deployment:**
- Build time: ~2-3 minutes
- Free tier: ✅ 256MB RAM, shared CPU
- Location: Global edge (choose region in fly.toml)
- Cost: FREE

**URL:**
- Format: `https://bandit-ssh-proxy.fly.dev`
- SSL: ✅ Automatic HTTPS
- Health check: `/ssh/health`

## 🧪 Test After Deployment

```bash
# Test connection
curl -X POST https://bandit-ssh-proxy.fly.dev/ssh/connect \
  -H "Content-Type: application/json" \
  -d '{
    "host":"bandit.labs.overthewire.org",
    "port":2220,
    "username":"bandit0",
    "password":"bandit0"
  }'

# Should return connection ID
# {"connectionId":"conn-xxx","success":true,"message":"Connected successfully"}
```

## 🎯 Ready to Deploy!

Run these commands:

```bash
cd /home/Nicholai/Documents/Dev/bandit-runner/ssh-proxy
/home/Nicholai/.fly/bin/flyctl auth login
/home/Nicholai/.fly/bin/flyctl deploy
```

Then update the Cloudflare Worker with the new URL! 🚀

