# safe-ssh-mcp [Health: Active]

**Category:** 🖥️ Command Line  
**Repository:** https://github.com/Areso/safe-ssh-mcp  
**GitHub Stars:** 9  
**Views:** 5  
**Installs:** 0  
**Upvotes:** 0  
**Directory Page:** https://allmcps.com/mcp/safe-ssh-mcp

## Description
A secured scoped SSH MCP server for executing safe read-only diagnostic DevOps / SysOps commands

## Tools
Capabilities this server exposes over MCP:

- **get_disk_free** — Collects disk usage (df -h) from a remote Linux host via SSH.
- **get_inode_usage** — Collects inode usage (df -i) from a remote Linux host via SSH.
- **get_disk_usage** — Collects disk usage for a specific abs path from a remote Linux host via SSH.
Returns the top 20 largest files/folders in the specified directory.
- **get_list_of_files** — Collects list of files for a specific abs path from a remote Linux host via SSH.
Returns with -lah option
- **get_list_of_files_with_filter** — Collects list of files for a specific abs path with filter (grep) applied from a remote Linux host via SSH.
-lah option is applied.
- **get_lockfiles** — Finds dependency lockfiles under the given absolute app paths on a remote Linux host via SSH:
composer.lock (PHP), package-lock.json, yarn.lock, pnpm-lock.yaml (Node.js),
requirements*.txt, poetry.lock, uv.lock, Pipfile.lock (Python), Gemfile.lock (Ruby),
go.sum (Go) and Cargo.lock (Rust).
Skips node_modules, vendor, .git, venv and .venv directories.
Lists the files found with size and mtime (ls -l). With include_contents=True prints the files
instead (the first 20 found), each after a '===== <path> (<size> bytes) =====' line.
A file is always printed WHOLE or not at all, never cut: a file over 5 MB, or one that would
take the output over 10 MB in total, gets a '===== <path> (skipped: ...) =====' line instead.
The output can be several MB - call without include_contents first to see the sizes,
then narrow abs_paths to the application you need.
- **get_is_installed** — Checks whether a binary/command is installed and callable on a remote Linux host via SSH.
- **get_installed_packages** — Lists installed packages with versions on a remote Linux host via SSH, using the first
available package manager. The FIRST output line starts with '#' and names the package
manager and the columns; the rest is one package per line:
dpkg (Debian/Ubuntu), tab-separated: package, version, architecture, status ('ii' installed,
  'hi' installed and held), source_package, source_version. Security advisories for
  Debian/Ubuntu are keyed by SOURCE package (openssh, not openssh-server).
  Removed packages whose config files are left behind (state 'rc') are not listed.
rpm (RHEL/Fedora/SUSE), tab-separated: package, epoch (0 if the package has none), version,
  release, architecture, source_rpm (file name of the source RPM, e.g.
  openssh-8.7p1-38.el9.src.rpm for openssh-server). Compare versions as epoch:version-release.
  Imported GPG keys (gpg-pubkey) are not listed.
apk (Alpine), tab-separated: package, version, architecture, origin. Security advisories for
  Alpine are keyed by ORIGIN (openssl, not libcrypto3); it has the same version as the package.
- **get_dmesg** — Collects dmesg log from a remote Linux host via SSH.
Reading the kernel log usually requires root: when the login user is not root,
the command is run through passwordless sudo or doas (sudo -n / doas -n).
Optional since limits it to recent messages: '30 min ago', '2 hours ago', 'today',
'yesterday' or 'YYYY-MM-DD HH:MM:SS'. It requires util-linux 2.37+ on the remote host;
on older hosts dmesg fails with an unrecognized option error - then call without since.
- **get_uptime** — Collects uptime from a remote Linux host via SSH
- **get_current_datetime** — Collects current datetime from a remote Linux host via SSH
- **get_hostname** — Collects the hostname of a remote Linux host via SSH, as the host itself reports it.
Output: "hostname: <name>" (the kernel hostname, uname -n), then "fqdn: <name>"
(hostname -f) when the host can resolve its fully qualified name; that line is
absent otherwise.
- **get_distroname_version** — Collects distr details from os-release from a remote Linux host via SSH
- **get_kernel_version** — Collects kernel name, release, build version and architecture (uname -srvm) from a remote Linux host via SSH
- **get_libc_version** — Collects C library implementation and version (glibc or musl) from a remote Linux host via SSH.
Uses ldd --version; musl is detected by the presence of /lib/ld-musl-* loader.
The last line, "package: <name> <version>", is the distro package version
(e.g. 2.39-0ubuntu8.9, 2.34-289.el9, 1.2.6-r3) that security data is keyed by;
it is taken from dpkg, rpm or apk and is absent on other distros.
- **get_sshd_effective_config** — Collects the effective sshd configuration (sshd -T) from a remote Linux host via SSH.
Shows the final values after defaults, includes and Match blocks are applied.
Requires root, since sshd -T reads the host keys: when the login user is not root,
the command is run through passwordless sudo or doas (sudo -n / doas -n).
- **get_php_info** — Collects PHP details from a remote Linux host via SSH: CLI version and SAPI,
installed CGI (php-cgi) and FPM (php-fpm) binaries with their versions/SAPIs,
whether php-fpm or php-cgi processes are currently running, and, if Apache
is installed, whether mod_php is enabled in its config and loaded.
- **get_systemd_list_all** — Lists all systemd units. USE THIS TOOL to check for running, stopped, or FAILED daemon/service/unit.
- **get_systemd_list_failed** — Lists failed systemd units. USE THIS TOOL to check for FAILED daemons/services/units.
- **get_systemd_list_timers** — Lists all systemd timers. USE THIS TOOL to check for timers.
- **get_systemd_status** — Gets the detailed status, logs, and error messages for a SPECIFIC systemd daemon/service/unit.
daemon is a unit name such as nginx, sshd.service or user@1000.service: ASCII letters,
digits and . - _ @ : only, starting with a letter or digit, at most 255 characters.
- **get_ps_aux_top_cpu_consumers** — Lists top 10 cpu consumers, CPU desc (ps aux --sort=-%cpu).
On BusyBox hosts (Alpine), where ps cannot sort, the output comes from `top -b -n 1`
instead: its first line starts with '# BusyBox', the columns differ, and %CPU is the
usage at this moment, not the average over the process lifetime that ps reports.
- **get_ps_aux_top_mem_consumers** — Lists top 10 mem consumers, MEM desc (ps aux --sort=-%mem).
On BusyBox hosts (Alpine), where ps cannot sort and has no %MEM, the output is
`ps -o pid,user,rss,vsz,args` sorted by RSS instead: its first line starts with
'# BusyBox' and sizes are in KB unless they carry an m or g suffix.
- **get_free_memory** — Returns free memory, swap (total/free), page cache, HugePages and so on
- **get_memory_pressure** — DEPRECATED: use get_pressure, which returns CPU, I/O and memory pressure in one call.
Returns memory pressure if supported
- **get_mounts** — Lists mounted filesystems with their mount point, source device, filesystem type and
mount options (findmnt, as a tree; /proc/mounts if findmnt is not installed).
USE THIS TOOL to find a filesystem that was remounted read-only after an error ('ro' in
the options), to check options like noexec/nosuid, and to see network (nfs, cifs),
overlay and tmpfs mounts. For free space use get_disk_free instead.
- **get_pressure** — Returns Linux pressure stall information (PSI) for CPU, I/O and memory in one call.
USE THIS TOOL to tell which resource the host is short of: unlike load average, it shows
how much time tasks actually spent waiting for each resource.
'some' = share of time at least one task was stalled, 'full' = all non-idle tasks were stalled
at once; avg10/avg60/avg300 are percentages over the last 10, 60 and 300 seconds,
total is the cumulative stall time in microseconds.
Prints 'PSI not supported' for a resource if the kernel is older than 4.20 or PSI is disabled.
- **get_vmstat** — Samples system activity for 4 seconds with vmstat (5 reports, 1 second apart): run queue and
blocked processes (r, b), memory, swap-in/out (si, so), block I/O (bi, bo), interrupts and
context switches (in, cs) and the CPU split (us, sy, id, wa, st).
USE THIS TOOL to see what the host is doing right now: swapping, I/O wait, CPU saturation.
The FIRST report line is the average since boot - judge the current state by the other four.
- **get_top** — Collects top's snapshot from a remote Linux host via SSH (top -b -n 2 -d 1 -c -w 512).
Takes two samples 1 second apart and returns the second one, so CPU usage is the current one
(the first sample of top shows averages since boot). The output is cut to the first 30 lines:
the summary and the top CPU consumers.
On BusyBox hosts (Alpine), where top has no -c / -w, the output is plain `top -b -n 1`,
cut to 30 lines too: its first line starts with '# BusyBox' and the columns differ.
- **get_lsblk** — Collects lsblk output from a remote Linux host via SSH
- **get_docker_ps_all** — Collects docker ps --all output from a remote Linux host via SSH
When the login user cannot reach the docker daemon (not root, not in the docker group),
the command is run through passwordless sudo or doas (sudo -n / doas -n).
- **get_docker_images** — Collects docker images --digests output (repository, tag, digest, image ID, age, size) from a remote Linux host via SSH
When the login user cannot reach the docker daemon (not root, not in the docker group),
the command is run through passwordless sudo or doas (sudo -n / doas -n).
- **get_docker_logs** — Gets the last `lines` log lines (stdout and stderr merged) of a SPECIFIC docker container,
given by name or ID, from a remote Linux host via SSH. Works for stopped containers too.
Use get_docker_ps_all first to find container names.
Optional since limits them to a time window: '30 min ago', '2 hours ago', '30m', '1h30m'
or 'YYYY-MM-DD HH:MM:SS' ('today' and 'yesterday' are not supported here).
When the login user cannot reach the docker daemon (not root, not in the docker group),
the command is run through passwordless sudo or doas (sudo -n / doas -n).
- **get_docker_stats** — Collects a one-shot docker stats snapshot from a remote Linux host via SSH:
CPU %, memory usage/limit, network and block I/O, PIDs for every RUNNING container.
When the login user cannot reach the docker daemon (not root, not in the docker group),
the command is run through passwordless sudo or doas (sudo -n / doas -n).
- **get_docker_inspect** — Inspects a SPECIFIC docker container, given by name or ID, on a remote Linux host via SSH.
Returns a curated subset of docker inspect: image, entrypoint/cmd, state (status, exit code,
OOMKilled, start/finish time, health check log), restart count and policy, memory/CPU limits,
networks, ports, mounts and log driver. Environment variables are NOT returned.
When the login user cannot reach the docker daemon (not root, not in the docker group),
the command is run through passwordless sudo or doas (sudo -n / doas -n).
- **get_kubectl_logs** — Gets the last `lines` log lines of a SPECIFIC kubernetes pod (kubectl logs) by running
kubectl on a remote Linux host via SSH. kubectl must be configured for the SSH user there.
container selects a container in a multi-container pod.
previous=True returns logs of the previous, crashed instance - use it for CrashLoopBackOff.
Optional since limits them to a time window: '30 min ago', '2 hours ago', '30m', '1h30m'
or an absolute UTC time 'YYYY-MM-DDTHH:MM:SSZ'.
- **get_kubectl_describe** — Describes a SPECIFIC kubernetes resource (kubectl describe) by running kubectl on a remote
Linux host via SSH: status, conditions, containers and its recent events.
kubectl must be configured for the SSH user there.
resource_type is one of: pod, node, namespace, deployment, statefulset, daemonset, replicaset,
job, cronjob, service, endpoints, ingress, networkpolicy, persistentvolumeclaim, persistentvolume,
storageclass, horizontalpodautoscaler, poddisruptionbudget (plural and short names like
'po', 'deploy', 'svc' work too). Secrets and configmaps are NOT available.
namespace is ignored for cluster-scoped resources (node, namespace, persistentvolume, storageclass).
- **get_kubectl_events** — Gets the most recent `lines` kubernetes events (kubectl get events), oldest first, below the
column header, by running
kubectl on a remote Linux host via SSH. kubectl must be configured for the SSH user there.
USE THIS TOOL FIRST when you don't know what is wrong in a cluster.
Events of ALL namespaces are returned unless namespace is given.
warnings_only=True keeps only events of type Warning (FailedScheduling, BackOff, Unhealthy...).
- **get_crictl_ps** — Collects crictl ps --all output (all CRI containers on a kubernetes node, including exited ones:
container ID, image, state, name, attempt, pod) from a remote Linux host via SSH.
Usually requires root.
- **get_crictl_images** — Collects crictl images output (image, tag, image ID, size of images present in the CRI runtime
of a kubernetes node) from a remote Linux host via SSH. Usually requires root.
- **get_crictl_imagefsinfo** — Collects crictl imagefsinfo output (mountpoint, used bytes and inodes of the CRI image
filesystem of a kubernetes node) from a remote Linux host via SSH.
USE THIS TOOL to investigate image garbage collection and DiskPressure. Usually requires root.
- **get_crictl_logs** — Gets the last `lines` log lines (stdout and stderr merged) of a SPECIFIC CRI container on a
kubernetes node from a remote Linux host via SSH. Works when the API server is down.
Use get_crictl_ps first to find the container ID. Usually requires root.
Optional since limits them to a time window: '30 min ago', '2 hours ago', '30m', '1h30m'
or an absolute UTC time 'YYYY-MM-DDTHH:MM:SSZ'.
- **get_crictl_inspect** — Inspects a SPECIFIC CRI container (crictl inspect, JSON) on a kubernetes node from a remote
Linux host via SSH: state, exit code and reason, timestamps, image, mounts, log path, pid
and the runtime spec. Use get_crictl_ps first to find the container ID. Usually requires root.
Values of environment variables are replaced by '<redacted>'; their names are kept.
- **get_crictl_inspect_image** — Inspects a SPECIFIC image (crictl inspecti, JSON) in the CRI runtime of a kubernetes node
from a remote Linux host via SSH: repo tags and digests, size, user, entrypoint/cmd, layers.
image is an image name ('registry.k8s.io/pause:3.9') or an image ID from get_crictl_images.
Usually requires root.
Values of environment variables are replaced by '<redacted>'; their names are kept.
- **get_crontab_tasks** — Collects crontab -l (crontab list) output from a remote Linux host via SSH
- **get_listening_sockets** — Collects ss -tulpn output (open ports and sockets) from a remote Linux host via SSH.
If ss is not installed (e.g. Alpine), falls back to netstat -tulnp; the output then
starts with a "# ss is not installed: netstat -tulnp" line and has netstat's columns.
If the login user is not root, runs through sudo -n / doas -n to get the process
names of all sockets; if that is not allowed, runs as the login user and says so in
a "# not run as root" line (process names are then shown only for its own sockets).
- **get_process_files** — Shows which packages' code every running process executes on a remote Linux host via
SSH: its executable, the shared libraries it has loaded, and the package that owns each
of those files. USE THIS TOOL to find which services really use a library (e.g. is the
vulnerable libssl loaded by anything that listens on the network?) and which processes
still run a binary or library that was replaced by an upgrade and need a restart.
Combine the pids with get_listening_sockets.
The output has two parts, tab-separated:
1. Per process a line "P <pid> <name> <executable>", followed by one line "F <file>"
   for every file it has mapped as executable code (read from /proc/<pid>/maps).
2. After a line starting with "# owners": the package of each of those files.
   rpm and apk: "<package> <file>". dpkg: "<package>[:arch][, <package>...]: <file>",
   as printed by dpkg-query -S. A file missing here belongs to no package. With a merged
   /usr a file may be listed as /lib/... or /bin/... where part 1 says /usr/lib/... or
   /usr/bin/..., or the other way round.
If the login user is not root, part 1 runs through sudo -n / doas -n to see all
processes; if that is not allowed, it runs as the login user and says so in a
"# not run as root" first line (only that user's own processes are then listed).
- **get_ip_addr** — Collects ip addr show output (network interfaces, their state, MAC, IPv4 and IPv6 addresses)
from a remote Linux host via SSH
- **get_ip_route** — Collects the IPv4 and IPv6 routing tables (ip route show, ip -6 route show: default gateway,
per-interface routes) from a remote Linux host via SSH
- **get_dns_lookup** — Resolves a hostname (or reverse-resolves an IP address) ON a remote Linux host via SSH,
and prints its /etc/resolv.conf. USE THIS TOOL to check what a name resolves to from that host.
By default uses getent, which resolves exactly like applications on the host do
(/etc/hosts, nsswitch.conf, then DNS). A name that does not resolve gives exit code 2.
use_dig=True queries the DNS servers directly with dig (bypassing /etc/hosts) and returns the
full answer: status (NOERROR, NXDOMAIN, SERVFAIL), CNAME chain, TTLs, the server that answered
and query time. It fails with exit code 127 if dig is not installed - then use use_dig=False.
The next two parameters require use_dig=True:
record_type is one of A (default), AAAA, CNAME, MX, NS, TXT, SOA, PTR, SRV, CAA.
server (IP address or hostname, e.g. '8.8.8.8') asks that DNS server instead of the ones in
/etc/resolv.conf - compare both answers to tell a broken resolver from a broken record.
- **check_tcp_connect** — Checks FROM a remote Linux host (reached via SSH) whether a TCP connection to
target_host:target_port can be opened (nc -vz). USE THIS TOOL to tell whether a service
(database, API, another server) is reachable from that host.
target_host is a hostname or an IPv4/IPv6 address, target_port is 1-65535. Do not confuse them
with host/port, which are the SSH connection to the machine the check runs on.
Only the connection is opened and closed, no data is sent. One port per call.
ok=True means the port accepted the connection. Otherwise nc's message tells why:
'Connection refused' - the target is reachable but nothing listens on the port;
'timed out' - no answer in 3 seconds, usually a firewall or a routing problem;
a name resolution error - check the name with get_dns_lookup.
Fails with exit code 127 if nc is not installed on the host.
- **get_service_logs_from_journalctl** — Gets recent journald logs for a specific systemd service.
Optional since limits them to a time window: '30 min ago', '2 hours ago', 'today',
'yesterday' or 'YYYY-MM-DD HH:MM:SS' (the last `lines` entries within it are returned).
- **get_journal_errors** — Gets recent journald entries of priority warning and above (warning, err, crit, alert, emerg)
from ALL units and the kernel. USE THIS TOOL FIRST when you don't know which service is at fault.
With current_boot_only=True only entries since the last boot are returned.
Optional since limits them to a time window: '30 min ago', '2 hours ago', 'today',
'yesterday' or 'YYYY-MM-DD HH:MM:SS' (the last `lines` entries within it are returned).
- **get_last_logins** — Lists recent SUCCESSFUL logins (last, from wtmp) to a remote Linux host via SSH, newest first:
user, terminal, source address, login/logout time. Also shows reboots.
For failed login attempts use get_failed_logins.
On BusyBox hosts (Alpine), where last takes no options, the output is plain `last`
cut to `lines` rows: its first line starts with '# BusyBox', times have no year,
and since is not supported (the tool fails with a message saying so).
Optional since limits them to a time window: '30 min ago', '2 hours ago', 'today',
'yesterday' or 'YYYY-MM-DD HH:MM:SS'.
- **get_failed_logins** — Lists recent FAILED login attempts (lastb, from btmp) on a remote Linux host via SSH, newest first:
attempted user, terminal, source address, time. USE THIS TOOL to check for brute-force attempts.
Requires root, since btmp is not world-readable: when the login user is not root,
the command is run through passwordless sudo or doas (sudo -n / doas -n).
Optional since limits them to a time window: '30 min ago', '2 hours ago', 'today',
'yesterday' or 'YYYY-MM-DD HH:MM:SS'.
- **get_coredumps** — Inspects crashes (core dumps) recorded by systemd-coredump on a remote Linux host via SSH.
command='list' lists the last `lines` core dumps (time, PID, signal, executable), below the column header.
When there are no core dumps, coredumpctl exits with code 1 and ok is False - that is not a failure.
command='info' shows details of a core dump (signal, command line, stack trace if available):
of the given pid, or of the most recent one when pid is omitted.
Optional since limits them to a time window: '30 min ago', '2 hours ago', 'today',
'yesterday' or 'YYYY-MM-DD HH:MM:SS'.
Seeing other users' core dumps usually requires root.

## Claude Desktop Quick Installation
Install path detected from listing signals. Uses `uvx` (confidence: high):

```json
"mcpServers": {
  "safe-ssh-mcp": {
    "command": "uvx",
    "args": ["safe-ssh-mcp"]
  }
}
```

## Documentation & README

# Safe SSH MCP Server
A well-scoped SSH MCP server for executing read-only diagnostic commands over SSH.  
In this project, "safe" refers specifically to the safety of the remote host: the server is designed to prevent modifications to the remote system and reduce the risk of operational harm. Secrets redaction is best-effort but not guaranteed, so keep that in mind with models that retain data or learn from it.  
See [SECURITY.md](https://github.com/Areso/safe-ssh-mcp/blob/HEAD/SECURITY.md) for the threat model and how to report a vulnerability.  

## Badges
[Snyk Vulnerability Database report](https://security.snyk.io/package/pip/safe-ssh-mcp) - security check  
[![PyPI Downloads](https://static.pepy.tech/personalized-badge/safe-ssh-mcp?period=total&units=ABBREVIATION&left_color=BLACK&right_color=GREEN&left_text=downloads)](https://pepy.tech/projects/safe-ssh-mcp)  
[![Areso/safe-ssh-mcp MCP server](https://glama.ai/mcp/servers/Areso/safe-ssh-mcp/badges/score.svg)](https://glama.ai/mcp/servers/Areso/safe-ssh-mcp)  

## Overview

The core philosophy behind this MCP server is safety first. Instead of providing an AI agent with an unrestricted bash shell, this server exposes only carefully curated, read-only commands for system diagnostics and monitoring.

## Feedback

Using safe-ssh-mcp? I'd love to hear from you.

Whether you're using it with Claude Code, Codex, Ollama, or another MCP client, please tell me what works and what doesn't. Even a two-sentence report is valuable.

Share it in [GitHub Discussions](https://github.com/Areso/safe-ssh-mcp/discussions).

## Available Tools (Partial List)
A few examples from each group; `<...>` marks a validated parameter.

**Start here**
- get_host_overview : a first look in one call: identity, uptime, CPU, memory, pressure, disks, mount problems, failed units, top processes, listening sockets, journal errors. Each section is exactly the output of an existing tool; facts only, no thresholds or findings

**Disk and filesystems**
- get_disk_free : `df -h`
- get_disk_usage : `find <path> -mindepth 1 -maxdepth 1 -exec du -sh -- {} + 2>/dev/null | sort -rh | head -n 20`
- get_mounts : `findmnt` (or `cat /proc/mounts`)
- get_fstab : `cat /etc/fstab`
- get_mount_problems : fstab against `/proc/mounts` and `/proc/swaps` (not mounted, read-only, swap off), then `findmnt --verify`

**CPU, memory and processes**
- get_top : `top -b -n 2 -d 1 -c -w 512`, second sample, first 30 lines
- get_vmstat : `vmstat 1 5`
- get_mpstat : `mpstat -P ALL 1 3` (per-core CPU), or computed from `/proc/stat` without sysstat
- get_iostat : `iostat -x -m -y 1 3` (per-disk await and %util), or computed from `/proc/diskstats` without sysstat
- get_pressure : `cat /proc/pressure/{cpu,io,memory}`
- get_cpu_info : `lscpu` (without flags), or a summary of `/proc/cpuinfo` where lscpu is missing

**Systemd and logs**
- get_systemd_list_failed : `systemctl list-units --state=failed --no-pager`
- get_systemd_status : `systemctl status <daemon>`
- get_journal_errors : `journalctl -p warning -n <lines> --no-pager`
- get_journalctl_disk_usage : `journalctl --disk-usage`
- get_dmesg : `dmesg`

**Network**
- get_listening_sockets : `ss -tulpn`
- get_ip_route : `ip route show` and `ip -6 route show`
- get_ip_neigh : `ip [-s] -4 neigh show` and `ip [-s] -6 neigh show` (the ARP / NDP table, like `arp -a`), or `/proc/net/arp`
- get_dns_lookup : `getent ahosts <name>` or `dig <name> <record_type>`
- check_tcp_connect : `nc -vz -w 3 <target_host> <target_port>`
- check_http : `curl -q -sS --fail -o /dev/null -w ...` on `<scheme>://<target_host>[:<target_port>]<path>`: status, TLS check and timings, never the body (or `wget --spider`)

**Docker**
- get_docker_ps_all : `docker ps --all`
- get_docker_logs : `docker logs --tail <lines> <container>`
- get_docker_stats : `docker stats --no-stream`

**Kubernetes**
- get_kubectl_events : `kubectl get events --sort-by=.lastTimestamp`
- get_kubectl_logs : `kubectl logs --tail=<lines> --namespace=<namespace> <pod>`
- get_crictl_ps : `crictl ps --all`

**System, logins and crashes**
- get_distroname_version : `cat /etc/os-release`
- get_installed_packages : `dpkg-query -W` (with source package), `rpm -qa --qf` (with epoch and source RPM) or `/lib/apk/db/installed` (with origin)
- get_process_files : `/proc/<pid>/exe` and `/proc/<pid>/maps` of every process, with the package that owns each file
- get_process_info : one process by `pid` and/or `name`: `ps` (state, elapsed time, threads, wait channel, command line), `/proc/<pid>/status`, `cgroup`, open files against `limits`, `oom_score`, `io` (command line redacted; never the environment)
- get_failed_logins : `lastb -F -n <lines>`
- get_coredumps : `coredumpctl list --no-pager`
- get_cron_jobs : `/etc/crontab`, `/etc/cron.d/*` and every user's crontab (secrets redacted), with a check that a cron daemon runs

Click to open [full list of available tools](https://github.com/Areso/safe-ssh-mcp/blob/HEAD/tools.md)  

## Example of invocation
`okay, could u check disk usage on /root/ path with help of safe-ssh-mcp server on a remote myserver.mydomain.pro using root and /Users/myUser/.ssh/id_rsa to login?`

## Means of connection
The server supports SSH account-password authentication and private-key
authentication. Configure the private-key passphrase source in
`mcp_config.ini`:

```ini
# ENV_VAR (SSH_KEY_PASSPHRASE) or KEYCHAIN (ssh-agent)
ssh_key_passphrase_method=ENV_VAR
```

1. SSH account password: provide `password` to the MCP tool. Do not use this
   for a private-key passphrase.
2. Unprotected SSH key: use `key_path`. The default `ENV_VAR` setting also
   supports unprotected keys; `SSH_KEY_PASSPHRASE` is not required.
3. Passphrase-protected SSH key from an environment variable: leave
   `ssh_key_passphrase_method=ENV_VAR`, set `SSH_KEY_PASSPHRASE` in the
   environment that starts the MCP server, and provide `key_path`.

   ```bash
   export SSH_KEY_PASSPHRASE='your-key-passphrase'
   safe-ssh-mcp
   ```

4. macOS Keychain / SSH agent: set
   `ssh_key_passphrase_method=KEYCHAIN`, then unlock the key in the same user
   session that starts the MCP server. The server receives SSH signatures from
   `ssh-agent`; it does not read the key passphrase or the `key_path`.

   ```bash
   ssh-add --apple-use-keychain ~/.ssh/id_ed25519

   # Optional: make the loaded identity expire after one hour.
   ssh-add -t 1h ~/.ssh/id_ed25519

   # Remove one identity, or clear every loaded identity.
   ssh-add -d ~/.ssh/id_ed25519
   ssh-add -D
   ```

5. Cursor launched from the macOS Dock: use `KEYCHAIN` (recommended). You can
   run `ssh-add` from any Terminal window; it updates the SSH agent for your
   macOS login session, so Cursor does not need to be started from that
   Terminal.

   ```bash
   ssh-add --apple-use-keychain ~/.ssh/id_ed25519
   ssh-add -l
   ```

   After changing `mcp_config.ini`, restart the MCP server in Cursor (or fully
   quit and reopen Cursor). When invoking a tool in `KEYCHAIN` mode, omit
   `key_path`; the agent selects from its loaded identities.

   If you must use `ENV_VAR`, set it in the macOS launchd session before
   opening Cursor from the Dock, then fully quit and reopen Cursor:

   ```bash
   launchctl setenv SSH_KEY_PASSPHRASE 'your-key-passphrase'
   ```

   This value lasts only for the current login session, and putting a
   passphrase directly in a command may save it in shell history. Prefer
   `KEYCHAIN`.

For `KEYCHAIN`, the MCP server must inherit `SSH_AUTH_SOCK` from that user
session. This is normally automatic for a stdio server started from a desktop
application. `ENV_VAR` stores the passphrase in the server process environment,
so restrict access to the process and avoid putting it in source control.

## [Changelog](https://github.com/Areso/safe-ssh-mcp/blob/HEAD/CHANGELOG.md)

## Project Contents
1. mcp_ssh.py - the SSH MCP server
2. mcp_config.ini - the server's config
3. check_health_sse.py - check the server's tools and either it's up (sse transport)
4. check_health_stdio.py - check the server's tools and either it's up (stdio transport)

## Compatibility
**Remote hosts.** Besides the unit tests, the tools are checked live against disposable VMs
(`scripts/ab_test/`, `scripts/redaction_test/`, `scripts/socket_load/`):

| Distro | Login user | What it covers |
|---|---|---|
| Ubuntu 24.04 | root | systemd, dpkg, docker |
| Debian 13 | root | systemd, dpkg, docker |
| Fedora 44 | root | systemd, rpm |
| CentOS Stream 10 | root | systemd, rpm, RHEL-family tooling |
| Alpine 3.24 | unprivileged, `doas -n` | BusyBox, no systemd, apk, no bash |
| Ubuntu + kubeadm | root | kubectl and crictl against a real cluster |

Hosts need only `sh` and the usual base tools: where a tool is missing (sysstat, `ss`,
`lscpu`, pciutils, usbutils, GNU `timeout`), the tool falls back to `/proc`, `/sys`,
`netstat` or BusyBox.

**The server.** Unit tests run in CI on Python 3.11, 3.12, 3.13, 3.14 and 3.15 (Linux).
Tested manually on macOS with Python 3.11.

**MCP clients.** Any client that speaks MCP over `stdio`, SSE or streamable HTTP. Used
day to day with Claude Code. Setup notes above for Cursor; an example config for Cline in
`cline_mcp_settings.json`.

## STDIO vs HTTP/SSE
The default transport is `stdio`: the MCP client starts the server as a local process, and nothing listens on the network.

The HTTP transports (`streamable-http`, `sse`; set in `mcp_config.ini`) are meant to run behind a reverse proxy, which handles authentication and TLS (mTLS, OIDC, or basic auth over TLS, whatever your setup uses).  
The server itself does not authenticate requests, so it binds to `127.0.0.1` by default: expose it only through the proxy, as its callers get
the use of this server's SSH keys.

## The MCP Registry
mcp-name: io.github.Areso/safe-ssh-mcp

## The License
This project is licensed under the GNU AGPLv3 License.

### Why AGPL?
This server acts as core infrastructure and contains no business logic. By using the AGPL license, we ensure that any security improvements, bug fixes, or new diagnostic tools added to the server are shared back with the open-source community.

### Note for Client Developers 
Because MCP clients communicate with this server via standard Inter-Process Communication (IPC) or network protocols (like HTTP/SSE), the AGPL license does not "infect" or restrict the client applications connecting to it.   
You can safely connect proprietary, closed-source, or permissively licensed (e.g., MIT, Apache 2.0) AI agents to this server without violating the license terms.

