Advanced Extended

Managing your VPS with Claude Code

By Angus Published 7 May 2026 Updated 14 May 2026 12 min read

Claude Code is Anthropic’s AI coding assistant a CLI tool that runs in your terminal, reads your actual files and executes commands on your behalf. Rather than searching for answers and manually piecing together fixes, you describe a problem in plain language and Claude Code reads the relevant files, understands the context of your task and can then act on your server directly.

This guide covers practical scenarios for using Claude Code on a VPS: diagnosing broken sites, writing shell scripts, managing Docker containers, hardening security and more. Each section includes example prompts you can use immediately.

Before you begin

  • You need root or sudo access to your VPS via SSH. See our guide on connecting to your server via SSH.
  • Claude Code requires an active Anthropic account (Pro, Max, Teams, Enterprise or API Console plan).
  • Node.js 18 or later must be installed if you plan to use the npm installation method.
  • We recommend reviewing the acceptable use policy before running automated commands on a production server.

Installing Claude Code on your VPS

The native installer is the most direct way to get Claude Code running on a Linux VPS. SSH into your server and run the following command:

curl -fsSL https://claude.ai/install.sh | bash

Once installation completes, verify it is working:

claude --version

On first run, Claude opens a browser-based OAuth flow to authenticate your Anthropic account. After authentication, navigate to a working directory and start a session:

cd /var/www/yoursite
claude

Claude now has context of your current directory and can read, write and execute from there. The directory you start from matters but we’ll go over that in more detail in the tips section below.

Diagnosing a broken site

When a site returns a 500 error, the usual process involves checking logs manually, searching for the error message and working through a checklist of possible causes. Claude Code shortens this considerably by reading your logs and config files together and giving you a specific diagnosis.

Navigate to your web root and describe what you are seeing:

My WordPress site at /var/www/example.com is returning a 500 error. Can you look at the recent error logs and tell me what's happening?

Claude Code reads your Apache or Nginx error logs (typically /var/log/apache2/error.log or /var/log/nginx/error.log), cross-references them with your site’s configuration files and returns a specific diagnosis. It can identify PHP fatal errors, database connection failures, file permission issues, .htaccess rewrite conflicts and memory limit exhaustion.

Once you have a diagnosis, you can ask Claude Code to act on it directly:

The error is coming from a plugin. Can you check if the file permissions on /var/www/example.com/wp-content/uploads are correct and fix them if not?

Claude Code checks the permissions, identifies the issue and runs the chmod or chown commands needed to resolve it.

Writing and testing shell scripts

Writing a shell script from scratch takes time, especially when you need to handle edge cases, logging and error conditions correctly. Claude Code writes scripts in context – checking what tools are available on your server and what your actual directory structure looks like before producing anything.

Describe what you need in plain language:

Write a bash script that finds all .tar.gz files in /opt/backups older than 30 days and deletes them. It should log what it deletes to /var/log/backup-cleanup.log with a timestamp. I want to run it as a daily cron job.

Claude Code writes the script, makes it executable, tests it in dry-run mode if you ask and gives you the cron entry to add. Other examples that work well:

  • Monitoring disk usage on / and sending an alert email if it exceeds a threshold
  • Checking whether Docker containers are running and notifying you if any have stopped
  • A deployment script that pulls from a Git branch, runs composer install, clears the cache and restarts PHP-FPM

Nginx and Apache configuration

Web server configuration files are precise – a missing semicolon or a conflicting server block can take a site offline. Claude Code reads your existing configuration before writing anything new, which prevents it from producing a config that conflicts with what is already there.

Navigate to your config directory and describe what you need:

I need to add a virtual host for staging.example.com that serves files from /var/www/staging and requires HTTP basic auth. Can you write the Nginx config and test it?

Claude Code writes the config, checks it against your existing Nginx setup, runs nginx -t to validate it and tells you how to enable it. For debugging, you can point it at a specific problem:

My redirects from http to https aren't working for example.com. Can you look at my current Nginx config and tell me what's wrong?

Claude Code reads the config files, identifies the issue – a missing return 301, conflicting server blocks or an incorrect SSL certificate path – and shows you the corrected version. You can also ask it to add security headers with appropriate values and an explanation of what each one does.

Managing Docker containers

Docker Compose projects involve multiple files – the compose file, environment variables, volume mounts and network configuration. When something goes wrong, Claude Code can read all of these together rather than requiring you to check each one separately.

Navigate to your Docker project directory and start a session there:

cd /opt/n8n
claude

Then describe the problem:

My n8n container keeps restarting. Can you check the logs and tell me why?

Claude Code runs docker compose logs, reads the output and gives you a specific diagnosis. For configuration changes, you can ask it to modify the compose file directly:

I want to add PostgreSQL as the database backend for n8n instead of SQLite. Can you update the docker-compose.yml to add a Postgres container and configure n8n to use it?

Claude Code modifies the compose file, adds the correct environment variables, explains what it changed and tells you how to migrate your existing data. For networking between separate Compose projects, it can write the necessary network configuration and tell you the internal hostname to use.

Debugging PHP and WordPress

WordPress issues often involve multiple interacting components – PHP configuration, the database, plugins and themes. Claude Code can read across all of these at once, which makes it faster to identify the actual cause rather than working through possibilities one at a time.

For an intermittent database connection error:

I'm seeing intermittent "Error establishing database connection" on my WordPress site. It comes and goes. Can you help me diagnose it?

Claude Code reads wp-config.php to check credentials, checks MySQL or MariaDB status, looks at recent error logs and identifies whether the cause is a connection limit, a MySQL crash or a credential problem. For plugin conflicts after an update:

After updating my theme, the site broke with a PHP fatal error about a function already being declared. Can you look at the error log and identify which files are conflicting?

Claude Code reads the error, traces the conflicting function declarations across plugin and theme files and tells you exactly which file to edit and what to change. For performance issues, it can read your php.ini and MySQL config to identify obvious bottlenecks such as OPcache being disabled or low memory limits. See our guide on increasing the WordPress memory limit for one common fix.

SSH and user management

Adding users, configuring SSH key authentication and restricting access correctly involves several steps that are easy to get wrong. Claude Code walks you through the process and can make the changes directly.

For adding a restricted deployment user:

I need to add a new SSH user called "deploy" that can only access /var/www/example.com and run specific deployment commands. How do I set this up securely?

Claude Code walks you through creating the user, configuring SSH key authentication, setting directory permissions and optionally configuring a restricted shell or sudo rules for specific commands only. For auditing existing access:

Can you check which SSH keys are authorised on this server, when they were last used, and flag any that look like they shouldn't be there?

Claude Code reads /root/.ssh/authorized_keys and all user .ssh/authorized_keys files, checks auth logs for recent usage and gives you a summary. See our guide on adding your SSH key to your VPS for the underlying process.

Reviewing and hardening server security

A security review normally requires knowing which tools to run, what to look for in the output and how to prioritise what you find. Claude Code runs the checks systematically and gives you a prioritised list of issues with the exact commands to fix them.

Can you do a basic security review of this server? Check for: open ports that shouldn't be open, any world-writable files in the web root, SSH configuration best practices, and whether fail2ban is configured correctly.

Claude Code uses ss -tlnp for open ports, find for permission issues, reads /etc/ssh/sshd_config for misconfigurations and checks fail2ban’s jail config. For firewall-specific checks:

I'm running UFW. Can you check my current rules and tell me if anything looks unnecessarily exposed?

Claude Code reads the UFW rules, explains each one, flags anything that seems overly permissive and suggests tighter rules where appropriate. Our guide on opening ports in UFW covers the underlying firewall commands, and our guide on securing your VPS covers broader hardening steps.

Cron job management

Cron job syntax is easy to get wrong, and a collection of jobs built up over time can become difficult to audit. Claude Code reads every crontab on the server and translates schedule expressions into plain language so you can see exactly what is running and when.

Can you look at all the cron jobs on this server - root crontab, user crontabs, and /etc/cron.d - and give me a plain-English summary of what each one does and when it runs?

Claude Code reads every crontab, describes what each command does and flags any that look broken – for example, jobs referencing scripts that no longer exist. For adding a new job:

I want to run /opt/scripts/db-backup.sh every night at 2am UK time and email the output to admin@example.com if it fails. Can you add this correctly?

Claude Code adds the cron entry with the correct syntax, handles the timezone and configures the failure notification.

Tips for getting the most out of Claude Code on a VPS

A few habits make Claude Code significantly more effective as a server management tool.

  • Work from the right directory. Claude Code uses your current directory as context. If you are debugging an Nginx config, cd /etc/nginx first. If you are working on a WordPress site, cd /var/www/yoursite. The more relevant files are in scope, the more accurate the output.
  • Be specific about what you want done versus explained. “Explain what’s causing this error” and “Fix this error” produce different results. Claude Code asks for confirmation before making changes to sensitive files, but be explicit if you want it to act directly rather than advise.
  • Use it for unfamiliar territory. The biggest value is on tasks you do not know well. If you are setting up a new service or working with an unfamiliar config format, Claude Code reduces the learning curve because it explains what it is doing as it goes.
  • Keep sessions focused. Start a new claude session for each distinct task. Short, focused sessions with a clear objective are more effective than long sessions with lots of context switching.

Further reading on VPS management

Claude Code works alongside standard VPS management practices rather than replacing them. Understanding the underlying tools makes it easier to verify what Claude Code does and to act independently when needed.

Our VPS management guide covers the core tasks involved in running a server: monitoring resources, managing services and keeping software up to date. The initial server setup guide for Debian 12 walks through the steps to take on a fresh VPS before deploying anything, including creating a non-root user, configuring SSH and setting up a firewall.

For Docker-specific work, our guide on installing Docker Compose covers getting Compose running on your VPS. If you are running Node.js applications, the guides on installing Node.js on Linux and managing Node.js versions with nvm are useful references.

For security hardening beyond what Claude Code can audit, the VPS security tips on our blog covers additional steps including intrusion detection, log monitoring and keeping attack surfaces small. The official Claude Code documentation covers advanced configuration options including hooks, permissions and environment variable management.

Wrapping up

You now have a practical picture of what Claude Code can do on a VPS – from diagnosing 500 errors and writing shell scripts to auditing security and managing Docker containers. The common thread across all of these scenarios is that Claude Code reads your actual files and environment before acting, which makes its output specific to your server rather than generic.

Start with a task you find time-consuming or error-prone – a cron job you need to add, a config you need to debug or a security check you have been putting off. From there, explore the other scenarios in this guide as the need arises. Our guides on securing your VPS, managing firewall rules and connecting via SSH cover the foundational tasks that Claude Code builds on.

If you are not yet running a VPS, our VPS hosting plans give you a Linux server with full root access – everything Claude Code needs to work as described in this guide.

Need more power?

Get scalable resources with our VPS hosting with root access and optional software.

Get VPS Hosting

Starting something new?

Perfect for websites and small businesses unlimited bandwidth with cPanel hosting.

Get cPanel Hosting