MikroTik MCP now logs in to your routers with your SSH agent

1 hour ago

MikroTik MCP 0.26.0 adds one thing you'll notice. The server can now log in to your RouterOS devices with the keys your SSH agent holds, instead of a password or a key file path in its config. It's switched off by default, so every existing setup connects exactly the way it did before.

Ask about this presentation

Chapters

  1. 0:00SSH agent sign-in
  2. 0:21What changed in the client
  3. 0:41Turn it on
  4. 1:04Pin one key
  5. 1:26When the key is missing
  6. 1:44Config checks
  7. 2:04Fleets and safe mode
  8. 2:24Upgrade
Show transcript
  1. MikroTik MCP 0.26.0 adds one thing you'll notice. The server can now log in to your RouterOS devices with the keys your SSH agent holds, instead of a password or a key file path in its config. It's switched off by default, so every existing setup connects exactly the way it did before.

    Slide text
    mikrotik-mcp v0.26.0
    RELEASE 0.26.0

    MikroTik MCP now logs in to your routers with your SSH agent

    Off by default. Existing configs connect as before.
    MikroTik MCP logo
  2. Before this release, agent support was switched off in the code itself. Every SSH connection the server opened passed allow agent equals false, whatever keys you had loaded. Now that value follows a new setting called allow SSH agent. Leave it unset and it stays false, which is why nothing changes until you opt in.

    Slide text
    mikrotik-mcp v0.26.0

    Until 0.26, the server never asked your SSH agent for a key

    0.25.2 allow_agent=False,
    0.26.0 allow_agent=self.allow_ssh_agent
  3. You turn it on in the same places as every other connection setting. On the command line it's the allow SSH agent flag. In the environment, set the matching variable to true, and the Docker entrypoint accepts both. In an inventory file it's a field on each device. Either way, the server talks to whichever agent your SSH auth socket points to.

    Slide text
    mikrotik-mcp v0.26.0

    Switch it on wherever you configure the server

    Command line
    --allow-ssh-agent
    Also accepted by the Docker entrypoint
    Environment
    MIKROTIK_ALLOW_SSH_AGENT=true
    Passed through by the Docker entrypoint
    Inventory
    allow_ssh_agent: true
    Per device, in the YAML list
    The server uses the agent that SSH_AUTH_SOCK points to. Default: false.
  4. If your agent holds several keys, you can pick the one a router gets. Set SSH agent key next to allow SSH agent. It accepts the full public key line, just its base64 part, or a SHA256 fingerprint. The server then finds that one key in the agent, logs in with it, and turns general agent use off for that connection.

    Slide text
    mikrotik-mcp v0.26.0

    Name the one agent key a router should get

    inventory.yml
    - title: core-router
      host: 192.168.88.1
      allow_ssh_agent: true
      ssh_agent_key: "SHA256:…"
    Full public-key line
    ecdsa-sha2-nistp256 AAAA… you@host
    Its base64 blob
    AAAA…
    A SHA256 fingerprint
    SHA256:…
  5. If none of the agent's keys match, the server stops before it tries to log in. The connection fails with this error, which tells you to check the SSH auth socket and to list your loaded keys with ssh-add -l. The server closes its connection to the agent either way.

    Slide text
    mikrotik-mcp v0.26.0

    A key the agent doesn't have stops the connection, and the error says what to check

    mikrotik-mcp · log
    Failed to connect to MikroTik: ssh_agent_key did not match any key offered by the SSH agent (check SSH_AUTH_SOCK and that the key is loaded with `ssh-add -l`)
  6. Two mistakes are caught as soon as the configuration loads. A key selector with agent sign-in left off is rejected, and the message says it needs allow SSH agent set to true. With agent sign-in on, an empty or all-blank selector is rejected too. Stray spaces around a real key are simply trimmed.

    Slide text
    mikrotik-mcp v0.26.0

    Two contradictory settings are rejected when the config loads

    ssh_agent_key: "SHA256:…"
    allow_ssh_agent left off
    Rejectedssh_agent_key requires allow_ssh_agent: true
    allow_ssh_agent: true
    ssh_agent_key: " "
    Rejectedssh_agent_key must not be blank
  7. With an inventory, agent sign-in is set per device. So one router can use your agent while another keeps its key file. Once an inventory is set, the single-device agent variables are ignored, like the host and password ones. And a safe mode session connects with the same agent settings as the device it protects.

    Slide text
    mikrotik-mcp v0.26.0

    In a fleet, each router carries its own agent settings

    inventory.yml
    - title: core-router
      host: 192.168.88.1
      allow_ssh_agent: true
    
    - title: branch-office
      host: 10.0.0.1
      key_filename: ~/.ssh/branch
    Single-device variables ignored
    With an inventory set, MIKROTIK_ALLOW_SSH_AGENT and MIKROTIK_SSH_AGENT_KEY are dropped, like the host and password ones.
    Safe mode follows along
    A safe mode session connects with the same agent settings as its device.
  8. The PyPI package for this release is version 0.26.0.0. Upgrading changes nothing on its own, because agent sign-in stays off until you set it. One limit to know: each device takes a single key selector, so a router gets either one agent key, or whatever the agent offers. That's the release. MikroTik MCP now logs in to your routers with your SSH agent.

    Slide text
    mikrotik-mcp v0.26.0

    Upgrade to 0.26.0, then opt in when you're ready

    ✓ Agent sign-in is off until you set it
    ✓ PyPI package version 0.26.0.0
    ✓ Git tag v0.26.0
    One limit

    Each device takes a single key selector: one agent key, or whatever the agent offers.

    New in the contributors list: lucasholman, lilianmoraru, Kn-ut99

What happened in AI today, in your inbox

One short email each evening. Read it and you’re caught up.

Built in New York with ❤️