sodcalculator

10 Tech How-To

SSH Keys & VPS Deployment via MCP: What the Guided Setup Does

Guide 10-47990 · Updated · Step by step

The guided setup for SSH keys and VPS app deployment via MCP (Model Context Protocol) automates the secure connection between your local machine and a remote server, then configures the server to accept automated deployment commands from an AI assistant or script. It generates a key pair, installs the public key on the VPS, and creates the MCP server configuration that lets tools like Claude Desktop or Cursor deploy your app without manual SSH commands. This eliminates repetitive terminal work and reduces the risk of typos or credential leaks.

Background: Why SSH Keys and MCP Matter

SSH keys are a cryptographic pair—a private key you keep and a public key you place on the server. They replace passwords with a more secure handshake, and they’re essential for automated workflows because they don’t require interactive typing. MCP, introduced by Anthropic in late 2024, is an open protocol that lets AI assistants interact with external tools and data sources. For developers, an MCP server can expose deployment commands (like git push, docker build, or systemctl restart) to an AI assistant, so you can say “deploy to production” and the assistant executes the steps.

The guided setup bridges these two: it prepares the SSH layer so the MCP server can connect to your VPS without a password prompt, then it installs and configures the MCP server on your local machine or on the VPS itself. Without this setup, you’d have to manually generate keys, copy them, and edit JSON config files—each step a chance for error.

How the Guided Setup Works

The exact steps vary by tool (e.g., a hosting panel, a CLI like mcp-ssh, or a platform’s built-in deploy button), but the core flow is consistent:

  1. Key generation: It runs ssh-keygen -t ed25519 -C "your-email" (or RSA if you choose) and stores the private key in ~/.ssh/ with proper permissions (600).
  2. Key installation: It uses ssh-copy-id or manually appends the public key to ~/.ssh/authorized_keys on the VPS, setting the correct ownership and permissions (700 for the folder, 600 for the file).
  3. MCP server configuration: It creates a config file (often ~/.config/mcp/servers.json or a project-level .mcp.json) that defines the MCP server, its command (e.g., npx @some/mcp-ssh), and the SSH connection details (host, user, key path).
  4. Test connection: It runs a quick command like ssh -i ~/.ssh/id_ed25519 user@server "echo ok" to verify the key works, then checks that the MCP server starts and responds to a ping.

Some setups go further: they may create a dedicated deploy user on the VPS, restrict that user to only the commands the MCP server needs (using ForceCommand or a restricted shell), or set up a webhook for automatic deploys after a git push.

What You Get After the Setup

Once the guided setup finishes, you typically have:

  • A passwordless SSH connection from your local machine to the VPS (using key-based auth).
  • An MCP server running locally (or on the VPS) that exposes deployment tools to your AI assistant.
  • A set of allowed actions—like deploy, logs, status—that the assistant can invoke.
  • Logs of every command the assistant runs, so you can audit what happened.

For example, after setup you might type in Claude Desktop: “Deploy the latest commit to staging.” The assistant calls the MCP tool deploy_app, which SSHes into the VPS, pulls the repo, runs the build, and restarts the service—all without you touching a terminal.

Common Problems and How to Avoid Them

The most frequent issues people hit:

  • Permission errors: If authorized_keys is writable by group or others, SSH refuses to use it. The setup should chmod 600 the file and 700 the .ssh directory. If you see “Permission denied (publickey)”, check these.
  • Wrong key path: The MCP config may reference a key that doesn’t exist or has the wrong name. Always verify the path in the config matches the actual file.
  • Passphrase prompts: If your private key has a passphrase, automated commands will hang waiting for input. The setup should either use a key without a passphrase (for non-interactive use) or set up an SSH agent (ssh-add).
  • MCP server not starting: Often due to Node.js version or missing dependencies. The setup should check that npx and the required runtime are installed.

A common misconception is that the guided setup is “one click and done.” In practice, you may need to adjust firewall rules (allow port 22 from your IP only) or configure the MCP server’s allowed commands to match your deployment workflow.

Comparing Guided Setup vs. Manual Configuration

Manual setup gives you full control and understanding—you run each command and see what it does. It’s a good learning exercise. The guided setup is faster and less error-prone, especially if you’re new to SSH or MCP. It also often includes best practices like using Ed25519 keys (more secure and faster than RSA) and setting up a dedicated deploy user. The trade-off is that you might not know exactly what was configured, which can be a problem if something breaks later. Most guided setups log their actions, so you can review what they did.

Security Considerations

Using SSH keys is more secure than passwords, but there are still risks:

  • Private key theft: If your local machine is compromised, the attacker gets your key. Use a passphrase on the key and consider a hardware token.
  • Over-privileged MCP server: If the MCP server can run arbitrary commands, a malicious prompt could delete files or exfiltrate data. The setup should restrict commands to a whitelist (e.g., only git pull, docker compose up).
  • Key reuse: Using the same key for multiple servers means a breach on one server exposes your key to others. Generate separate keys per server or use an SSH agent with key rotation.

The guided setup should never store your private key on the VPS—only the public key goes there. If you see the setup copying the private key to the server, stop and review.

Alternatives to MCP for Deployment

MCP is not the only way to automate deploys. You could use:

  • CI/CD pipelines (GitHub Actions, GitLab CI) that build and deploy on git push.
  • Deployment tools like Capistrano, Fabric, or Ansible that run predefined tasks over SSH.
  • Platform-as-a-Service (Heroku, Vercel) that handle deploys with a simple git push.
  • Direct scripts that you run manually or via cron.

MCP’s advantage is natural-language control—you can ask an AI to “roll back to the previous version” and it figures out the steps. But it adds complexity and a dependency on the MCP server’s reliability. For simple apps, a CI pipeline might be more robust.

Frequently Asked Questions

Do I need a passphrase on my SSH key for MCP deployment?

No, and in fact a passphrase will break automated deployments because the MCP server can’t prompt for it. Use a key without a passphrase, but protect your local machine with full-disk encryption and a strong login password. Alternatively, use an SSH agent that holds the unlocked key in memory, but that requires the agent to be running when the MCP server executes.

Can I use the same SSH key for multiple VPS servers?

Technically yes, but it’s not recommended. If one server is compromised, the attacker gains access to all servers that share the key. Generate a separate key pair per server (or per environment) and add each public key to the respective authorized_keys file. The guided setup usually does this automatically if you run it per server.

What if my VPS provider doesn’t support SSH key injection?

Most providers (DigitalOcean, Linode, AWS) let you add a public key when creating the VPS. If yours doesn’t, you can manually append the public key to ~/.ssh/authorized_keys on the server using a password login for the first time. The guided setup should give you a command to do this, or you can do it yourself with ssh-copy-id.

Is MCP secure enough for production deployments?

It can be, but only if you configure it carefully. Use a dedicated deploy user with minimal permissions, restrict the MCP server’s allowed commands to a whitelist, and enable logging. Also ensure the MCP server itself runs on your local machine or a trusted CI runner, not on a public-facing server. Review the MCP server’s code if it’s third-party.

What does the guided setup do if I already have an SSH key?

It will either reuse the existing key or ask if you want to generate a new one. Reusing is fine if the key is already added to the VPS. The setup will check for existing keys and skip generation if one is found and is valid. If you have multiple keys, it may ask which one to use.

Can I undo the guided setup?

Yes. To undo, you remove the public key from the VPS’s authorized_keys file, delete the MCP server config entry, and optionally delete the generated key pair from your local machine. The setup doesn’t usually create any other system changes. If it created a deploy user, you can remove that user with userdel (but be careful not to delete other data).

Related

General steps for current mainstream versions; menus can differ by device and version. See the disclaimer or report an error.

More in this bed

The whole Tech How-To bed →