#!/usr/bin/env bash # Cehpoint Agentic SOC - server installer, v1.0 (27 Nov 2026) # # Connect: curl -fsSL https://soc.cehpoint.co.in/install | sudo bash -s -- --code CEH-XXXX-XXXX [--antivirus] # Uninstall: curl -fsSL https://soc.cehpoint.co.in/install | sudo bash -s -- --uninstall # # What it does, in order (read it before you run it): # 1. checks it runs as root on a systemd Linux with python3 (installs python3 and nftables with apt if missing) # 2. downloads two readable Python programs and checks them against published SHA-256 sums: # /usr/local/sbin/cehpoint-soc-agent - reports health and security state every minute; runs only a fixed list # of named actions (block an address, quarantine malware, restart a # service, install security updates ...). It can never run any command. # /usr/local/sbin/cehpoint-hygiene - read-only security sweep every 6 hours at the lowest priority # 3. exchanges your one-time code for this server's own token (stored in /etc/cehpoint/soc-agent.json, mode 600) # 4. installs two systemd timers and runs the first report # Nothing listens on a port: the agent only connects OUT to soc.cehpoint.co.in over HTTPS. # Uninstall removes the timers, the programs, the agent's own firewall table and its files. set -euo pipefail BASE="https://soc.cehpoint.co.in" CODE=""; AV=0; UNINSTALL=0; FORCE=0 while [ $# -gt 0 ]; do case "$1" in --code) CODE="${2:-}"; shift 2 ;; --code=*) CODE="${1#*=}"; shift ;; --antivirus) AV=1; shift ;; --uninstall) UNINSTALL=1; shift ;; --force) FORCE=1; shift ;; *) echo "Unknown option: $1"; exit 2 ;; esac done say() { printf '\033[1m[cehpoint-soc]\033[0m %s\n' "$*"; } die() { printf '\033[1;31m[cehpoint-soc] %s\033[0m\n' "$*" >&2; exit 1; } [ "$(id -u)" = "0" ] || die "Run as root (use sudo)." command -v systemctl >/dev/null 2>&1 || die "This server does not use systemd; it is not supported yet." CFG=/etc/cehpoint/soc-agent.json if [ "$UNINSTALL" = "1" ]; then if [ -f "$CFG" ] && ! grep -q '"https://soc.cehpoint.co.in/agent/ingest"' "$CFG" && [ "$FORCE" != "1" ]; then die "This server runs a different Cehpoint agent (not a client install). Not touching it." fi say "Removing Cehpoint Agentic SOC from this server..." if [ -f "$CFG" ]; then TOKEN=$(python3 -c 'import json;print(json.load(open("/etc/cehpoint/soc-agent.json")).get("token",""))' 2>/dev/null || true) [ -n "$TOKEN" ] && curl -fsS -m 15 -X POST "$BASE/agent/goodbye" -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" -d '{}' >/dev/null 2>&1 || true fi systemctl disable --now cehpoint-soc-agent.timer cehpoint-hygiene.timer >/dev/null 2>&1 || true rm -f /etc/systemd/system/cehpoint-soc-agent.{service,timer} /etc/systemd/system/cehpoint-hygiene.{service,timer} systemctl daemon-reload nft delete table inet cehpoint_soc >/dev/null 2>&1 || true rm -f /usr/local/sbin/cehpoint-soc-agent /usr/local/sbin/cehpoint-hygiene "$CFG" rmdir /etc/cehpoint 2>/dev/null || true if [ -d /var/lib/cehpoint-soc/quarantine ] && [ -n "$(ls -A /var/lib/cehpoint-soc/quarantine 2>/dev/null)" ]; then say "Quarantined files are kept in /var/lib/cehpoint-soc/quarantine (delete that folder when you no longer need them)." find /var/lib/cehpoint-soc -mindepth 1 -maxdepth 1 ! -name quarantine -exec rm -rf {} + else rm -rf /var/lib/cehpoint-soc fi say "Done. Nothing from Cehpoint SOC is running on this server any more." exit 0 fi [ -n "$CODE" ] || die "Missing --code. Get a one-time code from https://www.cehpoint.co.in/app/security.html (Connect a server)." if [ -f "$CFG" ] && ! grep -q '"https://soc.cehpoint.co.in/agent/ingest"' "$CFG" && [ "$FORCE" != "1" ]; then die "This server already runs a different Cehpoint agent. Not replacing it." fi # dependencies need="" command -v python3 >/dev/null 2>&1 || need="$need python3" command -v nft >/dev/null 2>&1 || need="$need nftables" command -v curl >/dev/null 2>&1 || need="$need curl" command -v ss >/dev/null 2>&1 || need="$need iproute2" if [ -n "$need" ]; then if command -v apt-get >/dev/null 2>&1; then say "Installing:$need" DEBIAN_FRONTEND=noninteractive apt-get update -qq && DEBIAN_FRONTEND=noninteractive apt-get install -y -qq $need >/dev/null else die "Please install:$need (then run this again)." fi fi python3 -c 'import sys; sys.exit(0 if sys.version_info >= (3, 6) else 1)' || die "python3 3.6 or newer is needed." TMPD=$(mktemp -d); trap 'rm -rf "$TMPD"' EXIT say "Downloading the agent..." for f in cehpoint-soc-agent cehpoint-hygiene SHA256SUMS; do curl -fsSL -m 60 "$BASE/agent/$f" -o "$TMPD/$f" || die "Could not download $f from $BASE (is outbound HTTPS allowed?)" done ( cd "$TMPD" && sha256sum -c SHA256SUMS --quiet ) || die "Checksum mismatch; not installing." say "Connecting this server with your code..." OS=$(. /etc/os-release 2>/dev/null; echo "${PRETTY_NAME:-Linux}") BODY=$(python3 -c 'import json,sys; print(json.dumps({"code": sys.argv[1], "hostname": sys.argv[2], "os": sys.argv[3]}))' "$CODE" "$(hostname)" "$OS") RESP=$(curl -sS -m 30 -X POST "$BASE/agent/enroll" -H "Content-Type: application/json" -d "$BODY" -w '\n%{http_code}') || die "Could not reach $BASE." HTTP=$(printf '%s' "$RESP" | tail -n1); JSON=$(printf '%s' "$RESP" | sed '$d') if [ "$HTTP" != "200" ]; then MSG=$(printf '%s' "$JSON" | python3 -c 'import json,sys try: print(json.load(sys.stdin).get("error","unknown error")) except Exception: print("unknown error")') die "$MSG" fi umask 077 mkdir -p /etc/cehpoint /var/lib/cehpoint-soc printf '%s' "$JSON" | python3 -c 'import json,sys d = json.load(sys.stdin) cfg = {"url": d["url"], "result_url": d["result_url"], "token": d["token"], "host": d["host"], "own_nets": ["127.0.0.0/8", "::1/128"]} open("/etc/cehpoint/soc-agent.json", "w").write(json.dumps(cfg, indent=1))' chmod 600 "$CFG" HOSTNAME_SHOWN=$(printf '%s' "$JSON" | python3 -c 'import json,sys; print(json.load(sys.stdin)["host"])') install -m 755 -o root -g root "$TMPD/cehpoint-soc-agent" /usr/local/sbin/cehpoint-soc-agent install -m 755 -o root -g root "$TMPD/cehpoint-hygiene" /usr/local/sbin/cehpoint-hygiene cat > /etc/systemd/system/cehpoint-soc-agent.service <<'U' [Unit] Description=Cehpoint Agentic SOC agent: report health and security state After=network-online.target [Service] Type=oneshot ExecStart=/usr/bin/python3 /usr/local/sbin/cehpoint-soc-agent Nice=10 TimeoutStartSec=50 U cat > /etc/systemd/system/cehpoint-soc-agent.timer <<'U' [Unit] Description=Run the Cehpoint Agentic SOC agent every minute [Timer] OnBootSec=40s OnUnitActiveSec=60s AccuracySec=5s [Install] WantedBy=timers.target U cat > /etc/systemd/system/cehpoint-hygiene.service <<'U' [Unit] Description=Cehpoint security sweep (read-only, lowest priority) [Service] Type=oneshot ExecStart=/usr/bin/python3 /usr/local/sbin/cehpoint-hygiene Nice=19 IOSchedulingClass=idle CPUQuota=50% MemoryMax=1G TimeoutStartSec=4h U cat > /etc/systemd/system/cehpoint-hygiene.timer <<'U' [Unit] Description=Run the Cehpoint security sweep every 6 hours [Timer] OnBootSec=20min OnUnitActiveSec=6h RandomizedDelaySec=10min Persistent=true [Install] WantedBy=timers.target U if [ "$AV" = "1" ]; then if command -v apt-get >/dev/null 2>&1; then say "Installing ClamAV for the nightly antivirus scan (uses about 1 GB of memory while scanning)..." DEBIAN_FRONTEND=noninteractive apt-get install -y -qq clamav >/dev/null && (systemctl enable --now clamav-freshclam >/dev/null 2>&1 || true) else say "Skipping antivirus: install clamav with your package manager and the sweep will use it." fi fi systemctl daemon-reload systemctl enable --now cehpoint-soc-agent.timer cehpoint-hygiene.timer >/dev/null /usr/bin/python3 /usr/local/sbin/cehpoint-soc-agent || true systemctl start --no-block cehpoint-hygiene.service || true say "Connected as \"$HOSTNAME_SHOWN\". It appears in your dashboard within a minute:" say " https://www.cehpoint.co.in/app/security.html" say "The first security check is running now at the lowest priority (2 to 15 minutes)." say "To remove everything later: curl -fsSL $BASE/install | sudo bash -s -- --uninstall"