Back to blog

Letting an AI agent drive your SSH terminal without handing it your keys

November 17, 2026 6 min read Kubexer Team
MCPAI AgentsSSHClaude CodeSecurity

Sooner or later you paste a stack trace into an AI assistant and it says "can you run journalctl -u api -n 100 on the staging box and show me what comes back?" You do, you paste the output, it asks for another command. You have become the agent's hands, copying text between two windows.

The Model Context Protocol (MCP) exists to close that loop: the assistant calls tools directly instead of asking you to. The hard part is not the plumbing. It is deciding what the assistant is allowed to touch on a machine that holds SSH access to your servers.

What people do today

Two approaches are common, and both have a catch. You can give the agent a shell tool on your laptop and let it run ssh itself, which means it uses whatever keys and agents your user can reach, with no per-command review beyond the agent's own permission prompts. Or you can keep copy-pasting, which is safe and slow.

The middle path is an interface designed for this: a small set of named tools, a clear boundary around secrets, and a human approval step where it matters.

Turning it on

In Kubexer Terminal, open Settings → AI MCP and switch on Allow AI agents to control Kubexer Terminal. The server starts on 127.0.0.1, port 47821 by default, which you can change. It only runs while the app is open and you are signed in.

Under Connect an agent you get a ready-made claude mcp add --transport http ... command for Claude Code, and a JSON config block for other MCP clients such as Claude Desktop or Cursor. Both include a bearer token. You can reveal, copy or regenerate it; regenerating disconnects every agent set up with the old one.

What an agent can do

The tools fall into four groups:

  • Vaults and hosts: list vaults; list, read, create, update and delete hosts and groups; list identities.
  • Port forwards: list, create, update, delete, start and stop.
  • Snippets: list, create, update and delete.
  • Terminals: open a terminal (or an SFTP browser) to a host, list open terminals, run a command, read output, send input, and close a terminal.

Every change an agent makes, such as creating a host or starting a forward, raises a notification in the app so you can see what happened.

Where the boundary sits: secrets

The design rule is that no secret leaves through a tool and none enters through one. Passwords, private keys, passphrases, certificates and environment values are stripped from every response; the agent can see that a credential exists, not what it is. There is also no field for a password or key on any tool, and no tool unlocks a vault. Credentials are attached by pointing a host at an existing identity, or entered by you in the app afterwards.

The reason is simple. Whatever a tool returns lands in the model's context and in the agent's transcript. A password typed into a chat has gone through a model provider. Agents can also only reach vaults that you have already unlocked.

The same thinking shows up in a few narrower rules. Deleting a host is refused while another host jumps through it or a port-forward rule uses it. A forward that would listen on anything other than loopback is refused unless the agent explicitly passes an opt-in for network exposure, which its tool description tells it to confirm with you first. And RDP and VNC hosts are not exposed to agents at all; only SSH hosts can be opened.

Who is in control of a terminal: Confirm, Auto, Off

Managing hosts is one thing. Running commands in a live session is the part that needs a real gate. Each terminal tab has an MCP badge you click to cycle through three modes:

  • Confirm (the default). Every command, and every keystroke sent with the send-input tool, waits for you. An approval bar appears in the tab where you can approve, edit or skip it. If you edit the command, the reply to the agent says so and reports what actually ran.
  • Auto. The agent's commands run straight away while you watch the tab.
  • Off. The agent cannot use that tab.

Closing a terminal also needs approval in Confirm mode. The approval happens inside the app window, not in the server, so a tool call has no way to argue its way past it. If the window is hidden to the tray when a request arrives, the app brings it forward. A request nobody answers is eventually reported to the agent as not approved rather than hanging forever.

A practical way to use this: leave production tabs in Confirm, set a scratch tab on a throwaway VM to Auto, and let the agent iterate there quickly.

What it feels like to work with

Because the agent runs commands in the real session, it inherits that session's working directory, environment and remote host, including any jump chain the host needs. Commands that finish are captured with their output and exit code. Interactive or never-ending programs such as vim, top or tail -f are launched live, and the agent follows them by polling the read-output tool and typing into them with send-input, including named keys such as enter, esc or ctrl-c. Reading the visible screen is supported for full-screen programs. Tool descriptions tell the agent never to put a password in a command; if a prompt asks for one, it should ask you to type it in the tab.

What the endpoint exposes to the rest of your machine

The server listens on loopback only, so other machines on your network cannot reach it, and requests that arrive with a web page origin are refused so a site open in your browser cannot talk to it. Every request needs the bearer token. Treat that token like a password: anything that holds it can change your hosts while the app runs.

Honest limits

  • Host, group, forward and snippet edits are not individually approved. The per-command approval applies to terminal tabs. Edits show a notification afterwards, which is a record, not a gate. If that is too loose for you, leave the server off, or review changes in the app.
  • Auto mode means what it says. An agent in an Auto tab can run anything that session's login can run. Do not set it on a tab that is logged in as root on something you care about.
  • The server only exists while the app is open and a vault is unlocked for the agent to see it.
  • The model sees what the terminal prints. Secrets that a command prints to the screen end up in the agent's context. The protection against exposing credentials covers what the tools return from your vault, not what a server writes to stdout.

In short

The Kubexer Terminal MCP server gives an agent hands inside your terminal, with a per-tab dial between "ask me every time", "go ahead" and "keep out", and a hard rule that credentials stay in the vault. The AI MCP server is a Pro feature of Kubexer Terminal. Kubexer for Kubernetes has its own MCP server for clusters, with a different set of controls, covered in a separate post.