diff --git a/README.md b/README.md index e8889b5..7c2269a 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,8 @@ Run Claude Code on a VPS and access it from your phone, tablet, or any device with a terminal app. Code from anywhere. +> Tested on Ubuntu 20.04+ / Debian 10+. Other distros may require adjustments. + ## What You'll Need - A VPS (Hostinger, Hetzner, DigitalOcean, etc.) - $5/mo tier is plenty @@ -22,16 +24,25 @@ For manual installation on any VPS: # SSH into your VPS ssh root@your-vps-ip -# Install Node.js and npm -apt update && apt install -y nodejs npm +# Install Claude Code (native installer - recommended) +curl -fsSL https://claude.ai/install.sh | bash + +# Ensure the native install symlink is on your PATH +export PATH="$HOME/.local/bin:$PATH" -# Install Claude Code globally -npm install -g @anthropic-ai/claude-code +# Make it persistent for future logins +echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc +source ~/.bashrc + +# Verify installation +claude doctor # Start Claude Code claude ``` +**Note:** The native installer is the recommended path. npm install is deprecated and requires Node.js 18+ only for that legacy method. + --- ### 2. Secure Your VPS (Important!) @@ -39,25 +50,37 @@ claude Before accessing from mobile, lock down your server: ```bash -# Disable password authentication (SSH keys only) -sudo sed -i 's/^#*PasswordAuthentication.*/PasswordAuthentication no/' \ - /etc/ssh/sshd_config /etc/ssh/sshd_config.d/*.conf && \ - sudo systemctl restart ssh +# Make sure you have a non-root user with an SSH key before doing this + +# Add a clear SSH hardening drop-in (SSH keys only) +sudo mkdir -p /etc/ssh/sshd_config.d +sudo tee /etc/ssh/sshd_config.d/99-claude-hardening.conf >/dev/null <<'EOF' +PasswordAuthentication no +KbdInteractiveAuthentication no +PermitRootLogin no +EOF + +# Test SSH config before restarting +sudo sshd -t && sudo systemctl restart ssh # Install fail2ban to block brute force attacks sudo apt install fail2ban -y # Enable firewall - only allow SSH -sudo ufw allow 22 && sudo ufw enable +sudo ufw allow OpenSSH +sudo ufw enable +sudo ufw status ``` +**Tip:** Run Claude Code as a non-root user. Avoid working as `root`. + --- ### 3. Set Up Mobile Access 1. Download **Termius** on your phone (iOS/Android) - it's free 2. Add a new host with your VPS IP address -3. Connect using your SSH key or password +3. Connect using your SSH key (passwords disabled) --- @@ -90,6 +113,29 @@ tmux attach -t claude --- +### 5. Optional: Claude Code Self-Hardening (Recommended) + +Create a project-level `.claude/settings.json` to block access to common secret files: + +```bash +mkdir -p .claude +cat > .claude/settings.json <<'EOF' +{ + "permissions": { + "deny": [ + "Read(./.env)", + "Read(./.env.*)", + "Read(./secrets/**)" + ] + } +} +EOF +``` + +This uses Claude Code permissions to make those files invisible to the tool. Commit the file for team-wide safety, or use `.claude/settings.local.json` if you want it to stay local. + +--- + ## Quick Reference | Command | What it does | @@ -108,12 +154,21 @@ tmux attach -t claude If Claude Code can't complete OAuth login: ```bash -# Option 1: SSH port forwarding (run from your local machine) -ssh -L 15735:localhost:15735 user@your-vps-ip +# If the browser doesn't open, press "c" to copy the OAuth URL +# Paste it into your browser and finish login there +``` -# Option 2: Use API key directly -export ANTHROPIC_API_KEY=your-key-here -claude +If login gets stuck, try: +1. `/logout` +2. Exit Claude +3. Run `claude` again + +### `claude` Command Not Found / PATH Issues + +The native installer creates a symlink at `~/.local/bin/claude`. Make sure `~/.local/bin` is on your PATH, then run: + +```bash +claude doctor ``` ### Can't Scroll in tmux on Mobile @@ -135,7 +190,8 @@ tmux attach -t claude ### Memory Issues on Long Sessions -Claude Code can use significant memory. Monitor with `htop` and restart Claude periodically if needed. +Claude Code can use significant memory. Use `/compact` to reduce context size and restart between major tasks if needed. +If you're on a 4GB VPS and hit memory pressure, consider enabling swap. --- @@ -152,9 +208,17 @@ Claude Code can use significant memory. Monitor with `htop` and restart Claude p ## Resources -- [Claude Code Documentation](https://docs.anthropic.com/en/docs/claude-code) -- [Termius](https://termius.com/) - Mobile SSH client -- [tmux Cheat Sheet](https://tmuxcheatsheet.com/) +| Resource | Notes | +|----------|-------| +| [Claude Code Documentation](https://docs.anthropic.com/en/docs/claude-code) | Official docs | +| [Termius](https://termius.com/) | Mobile SSH client | +| [tmux Cheat Sheet](https://tmuxcheatsheet.com/) | tmux reference | + +--- + +## Security Note + +Treat Claude Code as a powerful local agent. Review permissions, avoid running as root, and audit `.claude/settings.json` in shared repos. ---