# WSL2 Automation Scripts

Simple, practical scripts to automate WSL2 SSH connectivity between Windows and Mac/Linux.

## Available Scripts

### Windows Scripts (PowerShell)

**setup-wsl2-ssh.ps1**
- Complete automated setup of WSL2 SSH connectivity
- Handles WSL2 installation, SSH server setup, port forwarding, and firewall configuration
- Run once to get everything working

**update-wsl2-ip.ps1**
- Quick fix for when WSL2 IP address changes (after Windows restarts)
- Updates port forwarding rules automatically
- Run whenever you can't connect after a reboot

### Mac/Linux Scripts (Bash)

**connect-wsl2.sh**
- Simple connection helper for Mac/Linux users
- Prompts for Windows IP and username
- Connects via SSH on the correct port (2222)

## Quick Start

### First-Time Setup (Windows)
```powershell
# Run PowerShell as Administrator
.\setup-wsl2-ssh.ps1
```

### Daily Use

**When WSL2 IP changes (Windows):**
```powershell
# Run PowerShell as Administrator
.\update-wsl2-ip.ps1
```

**Connect from Mac/Linux:**
```bash
chmod +x connect-wsl2.sh
./connect-wsl2.sh
```

## Requirements

- Windows 11 Pro (or Windows 10 Pro with WSL2)
- Administrator access on Windows
- Mac/Linux machine on the same network

## What These Scripts Do

1. **Setup Script**: Installs WSL2, configures SSH server, sets up port forwarding (2222→22), and creates firewall rules
2. **Update Script**: Automatically detects new WSL2 IP and updates port forwarding rules
3. **Connect Script**: Simplifies SSH connection from Mac/Linux with proper port and formatting

All scripts include error checking and colored output for easy troubleshooting.
