DEV Community

Ramandeep Singh
Ramandeep Singh

Posted on

Strands Self-healing Agent for Remote server

Here’s what you need on the remote Linux server -

1. Linux host with SSH

  • Any systemd Linux box (Ubuntu/RHEL/etc.) reachable from the agent machine
  • OpenSSH server running (sshd)
  • Port 22 (or your chosen port) open from the agent host

2. Demo service (systemd unit)

Create a real service the agent can stop/start — e.g. billing-api.service:

# Example unit: /etc/systemd/system/billing-api.service
sudo systemctl daemon-reload
sudo systemctl enable --now billing-api.service
sudo systemctl status billing-api.service --no-pager
Enter fullscreen mode Exit fullscreen mode

It should produce logs matching the story (startup lines, health checks, errors on crash).

3. SSH account for the agent

  • Dedicated user (e.g. ops-agent)
  • Key-based auth preferred (private key on agent side, public key in ~/.ssh/authorized_keys)
  • Permission to run at least:
    • systemctl is-active <service>
    • systemctl status <service>
    • systemctl stop <service> / systemctl start <service> (often via passwordless sudo)

Example sudoers (least privilege):

ops-agent ALL=(root) NOPASSWD: /bin/systemctl is-active billing-api.service, /bin/systemctl status billing-api.service, /bin/systemctl stop billing-api.service, /bin/systemctl start billing-api.service, /bin/systemctl restart billing-api.service
Enter fullscreen mode Exit fullscreen mode

4. Logs readable over SSH

  • Journal access for that unit (journalctl -u billing-api.service), and/or
  • App log path as in the story (e.g. /var/log/billing-api/application.log) readable by the SSH user

5. Smoke-test from your laptop/agent host

ssh ops-agent@<server-ip>
systemctl is-active billing-api.service
systemctl status billing-api.service --no-pager
sudo systemctl stop billing-api.service
sudo systemctl start billing-api.service
Enter fullscreen mode Exit fullscreen mode

6. Demo trigger prep

Before the demo, stop the service (or crash it) so the alert is real:

sudo systemctl stop billing-api.service
Enter fullscreen mode Exit fullscreen mode

Then the agent SSH’s in, sees failed/inactive, restarts, and confirms from status + logs.


Agent side (from setup.txt): point Strands SshSandbox (or constrained tools) at that host with host, identity_file, and port — the remote box itself doesn’t need Strands installed.

Top comments (0)