Skip to content

Adding Sites

Varun Dubey edited this page Sep 13, 2026 · 2 revisions

Adding Sites

Prerequisites

Each WordPress server needs:

  • SSH access (password or key-based)
  • WP-CLI installed and in PATH
  • WordPress 5.0+

Add a Site with SSH Key Auth (Recommended)

Best for production servers and hosting companies with centralized key management.

wp_add_site(
    name="client-blog",
    host="server1.example.com",
    username="deploy",
    wp_path="/var/www/html",
    auth_type="key",
    key_path="~/.ssh/id_ed25519",
    site_url="https://client-blog.com"
)

No password needed for subsequent commands:

wp_full_scan("client-blog")

Add a Site with Password Auth

Common for InstaWP, managed hosting, or quick testing. Password is passed at runtime and never stored on disk.

wp_add_site(
    name="staging-site",
    host="147.182.198.163",
    username="sshuser",
    wp_path="/home/sshuser/web/example.com",
    auth_type="password",
    site_url="https://staging.example.com"
)

Every command requires the password parameter:

wp_full_scan("staging-site", password="your-ssh-password")

Add a Site on a Non-Standard Port

wp_add_site(
    name="custom-port-site",
    host="server2.example.com",
    port=2222,
    username="admin",
    wp_path="/home/admin/public_html",
    auth_type="key",
    key_path="~/.ssh/server2_key"
)

Test the Connection

Always test after adding:

wp_test_connection("client-blog")

This verifies:

  1. SSH connection works
  2. WP-CLI is available and functional
  3. WordPress path is correct
  4. WordPress is installed and responsive

Managing Sites

# List all sites with status
wp_list_sites()

# Get detailed info for one site
wp_get_site("client-blog")

# Update configuration (e.g., changed SSH key path)
wp_update_site("client-blog", key_path="~/.ssh/new_key")

# Remove a site
wp_remove_site("old-client")

Hosting Company Tip: Bulk Import

If you manage 50+ sites, you can script the addition:

# In Claude Code, just describe your sites:
"Add these 10 sites - all use key auth with ~/.ssh/hosting_key,
username 'deploy', wp_path pattern /var/www/{domain}/htdocs:
site1.com, site2.com, site3.com..."

Claude will call wp_add_site() for each one and test connections.

Data Storage

Site configurations are stored in ~/.wp-malware-cleanup/sites.json. This file contains hostnames, usernames, and paths - but never passwords.

Back up this file to avoid re-adding sites:

cp ~/.wp-malware-cleanup/sites.json ~/backup/

Clone this wiki locally