Guides 12 min read ·
Edit Your Live Website with Claude Code Safely: SSH, Staging, Git
Let Claude Code, Cursor or Codex edit your WordPress or PHP site safely: SSH keys, a staging copy, Git diffs and a backup you can restore if it breaks.
You can let Claude Code, Cursor or Codex edit your existing website, but don't point it at the live files. Run Claude Code (or any agent) on your own computer, let it reach your hosting over SSH with a key, make every change on a staging copy or in Git, and take a backup before each session. That way you see each change as a diff before visitors do, and a backup lets you roll back a bad session.
This guide covers WordPress, Laravel and custom PHP sites, including SMM panels. If your site isn't online yet, start with hosting a website made with AI. Tool details were checked against the official docs in October 2026, and they change fast.
Two ways to work: the agent on your laptop, or the agent on a server
| Set-up | How it works | Best for |
|---|---|---|
| Agent on your computer, deploy with Git (recommended) | The agent edits a Git repository on your computer. You review the diff and push, and the host deploys it. | Themes, custom plugins, Laravel apps, panel templates |
| Agent on your computer, commands over SSH | The agent runs commands such as ssh mysite "wp plugin list" on your hosting account. | Reading logs, diagnosing problems, WP-CLI tasks on staging |
| Agent running on a server | Claude Code is installed on a VPS and keeps working after you close your laptop. | Long jobs, always-on sessions, projects that need root |
Claude Code and OpenAI's Codex CLI run on your own machine by default, but some modes run on the remote machine. The Claude desktop app's SSH sessions install Claude Code on the server and run it there. VS Code's Remote-SSH installs a VS Code Server on the remote host, and Cursor, which is built on VS Code, works the same way.
That matters on shared hosting. Anthropic lists 4 GB of RAM or more as a requirement for Claude Code, and Microsoft asks for at least 1 GB (2 GB recommended) for the VS Code server. A shared hosting account runs inside CPU and memory limits, and we have not tested these remote modes inside one. On HostEthical shared hosting, run the agent on your computer and let it reach the server over SSH or through Git.
What your hosting needs before an AI agent touches it
WP Mayor's guide to editing WordPress with AI coding agents lists what most developers end up needing. HostEthical hosting includes all of it on every plan, Lite included:
| Need | Why it matters | On HostEthical hosting |
|---|---|---|
| SSH with keys | The agent runs commands without your dashboard password | Key-only SSH on port 2222 |
| Command-line tools | The agent checks and tests instead of guessing | PHP, git, Composer, WP-CLI and the mysql client |
| Staging | Changes are tried on a copy, not on visitors | One-click staging copy of files and database |
| Git deployment | Every change is a commit you can read and revert | Deploy from GitHub, GitLab or Bitbucket, with push-to-deploy |
| Logs | You see the real error when something breaks | Error and access logs for each website |
| Backups | You can undo a bad session | Nightly backups (last 7 kept), on-demand backups, one-click restore |
Hosting starts at ₹99 a month, or about ₹82.50 a month when billed yearly, with the same price at renewal. Our WordPress hosting guide covers what else to look for.
Set up SSH access for Claude Code and test it
Do this yourself before the agent gets involved:
- Create a key with
ssh-keygen -t ed25519 -C "my-laptop"and set a passphrase. On Windows, use PowerShell. If the command is missing, add OpenSSH Client under Optional Features. - Add the public key (the
.pubfile) under SSH in your hosting dashboard and switch SSH on. HostEthical accepts ed25519, ECDSA and RSA keys of at least 2048 bits, up to 10 per account, and logins work with keys only. - Connect once by hand with the command the dashboard shows, such as
ssh your-user@your-server -p 2222, and accept the server's host key. - Run
ssh-addso later commands don't stop for the passphrase. An agent can't type into that prompt, so its SSH commands would fail or hang. On Windows the ssh-agent service is off by default, so first runGet-Service ssh-agent | Set-Service -StartupType Automatic; Start-Service ssh-agentin PowerShell as administrator.
Then give the server a short name in ~/.ssh/config, so you and the agent can both type ssh mysite:
Host mysite
HostName your-server
User your-user
Port 2222
IdentityFile ~/.ssh/id_ed25519
Test it with ssh mysite "php -v && wp --info". If that prints versions without asking anything, the agent can use the same command. With Git for Windows installed, Claude Code usually runs commands in Git Bash, whose own ssh doesn't use that Windows service, so test from Git Bash too. Use a separate key on each computer, and remove a key the day a laptop is lost or a freelancer's job ends.
Rule 1: work on a staging copy, not the live site
A staging site is a private copy of your website where mistakes cost nothing. Open the website in your dashboard, go to Staging and click Create staging copy. Your files and database are copied to staging.yourdomain.com, WordPress addresses are rewritten to match, and search engines are told not to index the copy. If your domain doesn't use our nameservers, add an A record for the staging address.
Tell the agent to work only in the staging copy's folder and database. When a change works, choose Publish to live and pick files, database or both. We back up the whole account first, and your live wp-config.php, .env and similar config files are never overwritten.
The staging copy uses your plan's disk space, so delete it when you're done.
Rule 2: put the site in Git so every AI change is a reviewable diff
Git shows the exact lines an agent added and removed, so it's your most useful safety net:
- Review before you commit. Read
git diffafter each task, and ask the agent to explain anything you don't follow. - Keep commits small. With one task per commit, you can undo a bad change on its own with
git revert. - Don't rely on the agent's undo. Claude Code's checkpoints (
/rewind) don't track changes made through shell commands, which includes anything done over SSH, and Anthropic says they don't replace version control.
What to put in the repository
- WordPress: your child theme or custom plugin, as its own repository. Leave out core, third-party plugins and
wp-content/uploads, and never commitwp-config.php. - Laravel: the standard
.gitignorealready leaves out.envand/vendor. Keep it that way. - Custom PHP and panel scripts: your own code and templates. Add config files that hold passwords to
.gitignore.
Deploy from Git to your hosting
In the website's Git section, connect a GitHub, GitLab or Bitbucket repository and pick the branch and the folder to deploy into. The folder must start empty, apart from our placeholder page. For a WordPress theme, use an empty folder under wp-content/themes. Add the deploy key the dashboard gives you to the repository, read-only. Per GitHub's docs, it opens only that one repository. Then add the webhook so every push deploys automatically.
Each deploy resets the folder to match the branch. Untracked files, such as uploads and .env, are left alone. For a build step, add a .hostethical-deploy.sh file to the repository root (for example, with composer install --no-dev), and it runs after every deploy.
Rule 3: take a backup before each session and know how to restore it
HostEthical backs up every hosting account nightly at 03:30 IST and keeps the last 7 backups. Before an agent session, open Backups and click Take a backup, so your restore point is minutes old, not hours.
To restore, pick a backup, choose files, databases or both, and confirm. The restore replaces what is on the server now, so anything changed since that backup is lost. On WordPress, also export the database over SSH from your site's public_html folder:
wp db export ../before-ai-session.sql
The ../ keeps the file above public_html, out of reach of the web. Delete it once the session has gone well.
A safe session step by step (WordPress, Laravel or an SMM panel)
- Back up, and refresh the staging copy if it's old.
- Start a branch:
git switch -c fix-contact-form. - Start in plan mode:
claude --permission-mode plan. Claude Code then explores and proposes a plan, and doesn't edit your files until you approve it. It can still run shell commands while planning, often without asking, so add the ask rules from the security section first. - Give it one narrow task with clear limits, as in the example below.
- Review the diff and test on staging.
- Commit and push to deploy, or publish the staging files.
- Check the live site and its error log, and clear the page cache.
Work only on the STAGING copy. Run server commands with "ssh mysite".
Do not touch the live site or run commands that write to the database.
Explain each change before you make it.
Task: the contact form shows a PHP warning on submit.
Find the cause and propose the smallest fix.
WordPress
Keep custom code in a child theme or custom plugin, never in core or someone else's plugin, because updates overwrite those files. Our guide to speeding up WordPress lists small, safe tasks to start with.
Laravel
Have the agent write a migration for every database change and run your tests locally. Read each migration yourself before running php artisan migrate on live.
SMM panels and bought scripts
Many SMM panel scripts are sold under a licence, and some ship with encoded PHP files. An agent can't usefully read encoded code, and changing it may breach your licence or break updates. Keep AI edits to what you're allowed to change, such as the theme, templates, language files and your own add-ons. Starting fresh? See how to create an SMM panel.
Reading the error log when the agent breaks something
A blank page or a 500 error after a change usually has a one-line explanation in the PHP error log. Open the website's Logs section, choose Error log, and give the agent the last few relevant lines.
- Find the file. A
PHP Fatal errorline names the file and line number to check. - Get the site back first. If a plugin change took WordPress down,
wp plugin deactivate plugin-nameover SSH restores the site while you fix it. - Roll back if it drags on. Revert the Git commit and push, or restore the backup you took before the session.
Keep "display errors" off on live, because errors shown to visitors can expose file paths.
When to run the agent on a VPS instead (24/7 with tmux)
A VPS makes sense when you want sessions that keep running after you close the laptop, or need root to install software (see VPS vs shared hosting).
- Secure the server first with SSH keys, a firewall and automatic updates. Our VPS setup guide covers each step.
- Create a normal user for the agent, for example with
sudo adduser agent, and don't give it sudo rights. Anthropic's docs say the mode that skips all permission checks belongs only in isolated containers or VMs where it can't cause damage, run as a non-root user. A VPS that holds your live site isn't one, so keep the prompts on. - Install Claude Code as that user:
curl -fsSL https://claude.ai/install.sh | bash. - Run it inside tmux. Start a session with
tmux new -s agent, then runclaude. Detach with Ctrl+b followed by d, and reattach withtmux attach -t agent.
tmux keeps the session alive when your SSH connection drops. Claude Code's Remote Control lets you follow it from the Claude app, though not on every account type.
Every HostEthical Cloud VPS plan has at least 8 GB of RAM, full root access and a dedicated IPv4 address, from ₹860 a month, or about ₹774.17 a month when billed yearly. The plans are unmanaged, so you keep the system patched yourself (see managed vs unmanaged VPS). A VPS doesn't replace staging, Git or backups.
Security: keys, secrets and what never to paste into a prompt
Anthropic's data usage page says Claude Code sends your prompts and the model's outputs over the network, so file contents and command output the agent reads become part of that conversation.
- Never paste database passwords, payment gateway secret keys, SMM provider API keys, SSH private keys or customer lists. If one slips into a chat, change it.
- Keep secrets out of Git. Secrets belong in
.envorwp-config.php. In the project's.claude/settings.json, add deny rules for local copies of those files, and ask rules so every command that reaches the server, including agit pushthat deploys, waits for you:
{
"permissions": {
"ask": ["Bash(ssh *)", "Bash(scp *)", "Bash(rsync *)", "Bash(git push *)"],
"deny": ["Read(./.env)", "Read(./.env.*)", "Read(./wp-config.php)"]
}
}
This matters because recent versions of Claude Code start terminal sessions in auto mode, where a classifier rather than you approves most actions. As of October 2026 that includes pushing to any branch of your repository, and with push-to-deploy a push is a live deploy. Per Anthropic's permissions docs, commands matching an ask rule are never auto-approved. Deny rules cover Claude's file tools and commands like cat, not a file read on the server over SSH. The rules match the command as Claude writes it, so they are a safety net, not a security boundary.
- Keep the agent out of your accounts. It never needs your hosting dashboard or domain account password.
- Approve what goes live. Nothing should reach visitors until you've read the diff.
If you get stuck setting up SSH keys, staging or Git deployment, contact us and we will help.
Frequently asked questions
Can Claude Code connect to a server over SSH?
Yes. When Claude Code runs on your computer, it can run commands on your server with the ssh command, as long as key-based login works without asking for a password or passphrase. The Claude desktop app can also open SSH sessions, which install and run Claude Code on the remote machine, so use that mode on a VPS rather than on shared hosting.
Is it safe to let an AI agent edit a live WordPress site?
Not directly on the live files. Have the agent work on a staging copy or in a Git repository, take a backup before the session, and read every diff before anything reaches the live site. In Claude Code, add ask rules so SSH commands and git push wait for your approval, because with push-to-deploy a push goes straight to live.
Do I need a VPS to use Claude Code with my website?
No. Claude Code runs on your own computer and can reach shared hosting over SSH or deploy through Git. A VPS is only worth it if you want the agent running on a server around the clock or you need root access.
How do I undo changes an AI agent made to my site?
If the change was committed to Git, revert the commit and push to redeploy. Otherwise, restore the backup you took before the session from Backups in your hosting dashboard, choosing files, databases or both. Claude Code's /rewind doesn't track changes made through shell commands, so it can't undo anything done over SSH.